ChartDirector General Forum Home   Search
How to add extended trendline in finacial chart?
Posted by poohwen on May-14-2019 16:20
I found that you give an example of trendline in financial chart.

If I want to draw an extended trendline when I click twice in a financial chart then
the trendline will automatically extend both side to infinite.

Would you give me an example?

Thanks.

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-15-2019 01:51
Hi poohwen,

From your previous post, I think you already know how to obtain the x-index and y-value at the mouse position.

When the user clicks the mouse, your code should store the x-index and the y-value at the mouse. After clicking two times, your code will have 2 points. You can then add a trend line using a TrendLayer. There are some examples included in ChartDirector:

For the financial chart, it is like:

// data array for the trend line, initialize to Chart.NoValue
double[] trendLineData= new double[closeData.Length];
for (int i = 0; i < trendLineData.Length; ++i)
trendLineData[i] = Chart.NoValue;

// put two points in the trendLine array
trendLineData[xIndex1] = yValue1;
trendLineData[xIndex2] = yValue2;

// put the trend line at the main price chart

Hope this can help.

Regards
Peter Kwan

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-15-2019 17:21
Hi Peter,

// put two points in the trendLine array
trendLineData[xIndex1] = yValue1;
trendLineData[xIndex2] = yValue2;

I want to know what is the yValue1?

I can get the mouse.y but don't know how to convert it to the yValue1.

Would you mind give me an example?

Thanks

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-16-2019 02:55
Hi poohwen,

In my response to your previous enquiry a few months ago, I have provided an example to obtain the y-value given the y mouse coordinates. See:

The above example draws the y-axis data value at the mouse position. It includes code to obtain the y-axis data value from the mouse position, that's why it can draw cross-hair y value on the y-axis. It also includes the code to obtain the xIndex given the x mouse coordinate.

I forgot to mention that if your code is using a non-zero "extraPoints" parameter (called "extraDays" and set to 30 in the above example), you would need to add it to the xIndex to create the array:

Hope this can help.

Regards
Peter Kwan

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-16-2019 23:41
Hi, peter

If i want to directly draw a line instead of in the Paint event handler
but draw in the
public void drawChart(WinChartViewer viewer).

How to draw a line directly in stead of using trendlayer.

The reason why i want to do that is I could store many trendlines(points in array)
and draw them directly in the mainChart.

Thanks.

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-17-2019 03:39
Hi poohwen,

To draw the trend line in "drawChart", just all the code to draw the trend line in "drawChart". In the mouse event handler, you can obtain the coordinates, then call "winChartViewer.updateViewPort". This will trigger a ViewPortChanged event. In the ViewPortChanged event handler, it can call "drawChart". In "drawChart", it can check if there are data points selected by the user and draw the trend line accordingly.

If you have multiple trend lines, you can store the coordinates for the trend lines in a data structure (such as a List). Then in your drawChart routine, it can iterate the List or array to draw all the trend lines.

Regards
Peter Kwan

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-16-2019 23:51
Hi, peter

i try to modify your suggestion in the

it work

the code like

double[] trendLineData = new double[closeData.Length];
for (int i = 0; i < trendLineData.Length; ++i)
trendLineData[i] = Chart.NoValue;

// put two points in the trendLine array
trendLineData[80] = 150;
trendLineData[50] = 100;

// put the trend line at the main price chart

But in my application it fail to draw a trend line.

i try to use the code like
curBar.trendLineData[9000] = 10500;
curBar.trendLineData[9400] = 10650;
// put the trend line at the main price chart
m_mainChart.addTrendLayer((double[])Chart.arraySlice(curBar.trendLineData, startIndex, noOfPoints), 0x008000, "Trend Line");

I know the current total bars data is 9999.

So I fixed the x-index and the y-value.

But it did not draw a trendline.

Any problem?

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-17-2019 03:09
Hi poohwen,

I am suspecting the problem is due to incorrect data.

For example, if your startIndex and noOfPoints are not within the range of your trendLineData, then the trend line will not appear, because your code uses arraySlice to cut the trend line data away. Or after slicing, there may still be trendLineData left, but it is less than the "extraDays" or "extraPoints" parameter in "FinanceChart.setData" so the line will not be displayed.

If you would like me to diagnose the problem further, is it possible to provide a more complete example using hard coded data. Everything (including the startIndex and noOfPoints and all the data) should be hard coded for testing. This provides a way to reproduce the problem.

As an example, the following is a fully hard coded charting code that works. Please try to modify it (eg. by adding the arraySlice line) until it does not show the trend line and then inform me what is the code.

public void drawChart(WinChartViewer viewer)
{
int noOfDays = 100;

RanTable rantable = new RanTable(9, 6, noOfDays + extraDays);
rantable.setDateCol(0, new DateTime(2002, 9, 4), 86400, true);
rantable.setHLOCCols(1, 100, -5, 5);
rantable.setCol(5, 50000000, 250000000);

double[] timeStamps = rantable.getCol(0);
double[] highData = rantable.getCol(1);
double[] lowData = rantable.getCol(2);
double[] openData = rantable.getCol(3);
double[] closeData = rantable.getCol(4);
double[] volData = rantable.getCol(5);

FinanceChart c = new FinanceChart(800);
c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays);

double[] trendLineData = new double[closeData.Length];
for (int i = 0; i < trendLineData.Length; ++i)
trendLineData[i] = Chart.NoValue;

// put two points in the trendLine array
trendLineData[80] = 150;
trendLineData[50] = 100;

// put the trend line at the main price chart

// Output the chart
viewer.Chart = c;
}

Regards
Peter Kwan

Re: How to add extended trendline in finacial chart?
Posted by poohwen0908 on May-17-2019 20:36
Attachments:
Hi Peter,

I modified the dragtodrawline example in the attached zip.

Extrack T1-*.zip and copy T1-*.txt into the executable directory.

You might see a FinanceDemo Chart using my data.

1.If you unchecked the checkbox "AddTrendLine"

the chart is what I want and I am using now.

But it will not show the trendline.

2.If you checked the checkbox "AddTrendLine"

the chart will show the correct trendline.

But it is not what I want to see.

3.I hardcode the trendline without using the mouse XYValues.
As you taught me that I can use the mouse XY to get the related xIndex and YValue.
In this demo, I just hardcode the value to simply the code.

Would you help me to find what's wrong in my program?

Thanks.
 dragtodrawline.zip26.86 Kb
 T1-20190513.zip120.48 Kb
 T1-20190514.zip181.37 Kb
 T1-20190515.zip218.22 Kb
 T1-20190516.zip127.64 Kb
 T1-20190517.zip218.22 Kb

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-20-2019 19:01
Hi poohwen0908,

I am unable to run your code, because I do not have CVSReader.cs StringConverter.cs and Struct.cs. Also, it seems the file T1-20190517.zip is incorrect. Internally it contains the same file as T1-20190515.zip.

Anyway, just by reading the code, in your code, you call the addTrendLine with hard coded data. Please change it so that it uses data obtained from the mouse.

In your code, you also draw another line in the mouse event handler using e.Graphics. Please do not draw in the mouse event handler if you are drawing in the drawChart method. Instead, just obtain the coordinates in the mouse event handler, so that the addTrendLine code in drawChart can draw the trend line. (A few months ago, you have enquire for the code to draw the crosshair cursor. You can find the code to obtain the coordinates there.)

Below is an example for your reference:

Regards
Peter Kwan

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-20-2019 20:18
Attachments:
Thank you peter,

the reason why i hardcode the trendline array is that I already know the Y-VALUE after mouse click or mouse.

And the T1XXX even the same file does not matter with the result.

They just for test.

Please check my problem if you checked the "AddTrendLine" checkbox in the upperight corner.

like 1.png and 2.png.
```﻿/* CSVReader - a simple open source C# class library to read CSV data
* by Andrew Stellman - http://www.stellman-greene.com/CSVReader
*
* CSVReader.cs - Class to read CSV data from a string, file or stream
*
*
* (c) 2008, Stellman & Greene Consulting
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of Stellman & Greene Consulting nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY STELLMAN & GREENE CONSULTING ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL STELLMAN & GREENE CONSULTING BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Data;
using System.Text;

{
/// <summary>
/// </summary>
{
public const string NEWLINE = "\r\n";

/// <summary>
/// </summary>

/// <summary>
/// The number of rows to scan for types when building a DataTable (0 to scan the whole file)
/// </summary>
public int ScanRows = 0;

#region Constructors

/// <summary>
/// Read CSV-formatted data from a file
/// </summary>
/// <param name="filename">Name of the CSV file</param>
{
if (csvFileInfo == null)
throw new ArgumentNullException("Null FileInfo passed to CSVReader");

}

/// <summary>
/// Read CSV-formatted data from a string
/// </summary>
/// <param name="csvData">String containing CSV data</param>
{
if (csvData == null)
throw new ArgumentNullException("Null string passed to CSVReader");

}

/// <summary>
/// </summary>
{

}

#endregion

string currentLine = "";
/// <summary>
/// Read the next row from the CSV data
/// </summary>
/// <returns>A list of objects read from the row, or null if there is no next row</returns>
{
// ReadLine() will return null if there's no next line
return null;

StringBuilder builder = new StringBuilder();

{
builder.Append(c);
}

currentLine = builder.ToString();
if (currentLine.EndsWith(NEWLINE))
currentLine = currentLine.Remove(currentLine.IndexOf(NEWLINE), NEWLINE.Length);

// Build the list of objects in the line
List<object> objects = new List<object>();
while (currentLine != "")
return objects;
}

/// <summary>
/// Read the next object from the currentLine string
/// </summary>
/// <returns>The next object in the currentLine string</returns>
{
if (currentLine == null)
return null;

// Check to see if the next value is quoted
bool quoted = false;
if (currentLine.StartsWith("\""))
quoted = true;

// Find the end of the next value
string nextObjectString = "";
int i = 0;
int len = currentLine.Length;
bool foundEnd = false;
while (!foundEnd && i <= len)
{
// Check if we've hit the end of the string
if ((!quoted && i == len) // non-quoted strings end with a comma or end of line
|| (!quoted && currentLine.Substring(i, 1) == ",")
// quoted strings end with a quote followed by a comma or end of line
|| (quoted && i == len - 1 && currentLine.EndsWith("\""))
|| (quoted && currentLine.Substring(i, 2) == "\","))
foundEnd = true;
else
i++;
}
if (quoted)
{
if (i > len || !currentLine.Substring(i, 1).StartsWith("\""))
throw new FormatException("Invalid CSV format: " + currentLine.Substring(0, i));
i++;
}
nextObjectString = currentLine.Substring(0, i).Replace("\"\"", "\"");

if (i < len)
currentLine = currentLine.Substring(i + 1);
else
currentLine = "";

if (quoted)
{
if (nextObjectString.StartsWith("\""))
nextObjectString = nextObjectString.Substring(1);
if (nextObjectString.EndsWith("\""))
nextObjectString = nextObjectString.Substring(0, nextObjectString.Length - 1);
return nextObjectString;
}
else
{
object convertedValue;
StringConverter.ConvertString(nextObjectString, out convertedValue);
return convertedValue;
}
}

/// <summary>
/// Read the row data read using repeated ReadRow() calls and build a DataColumnCollection with types and column names
/// </summary>
/// <returns>System.Data.DataTable object populated with the row data</returns>
{
// Read the CSV data into rows
List<List<object>> rows = new List<List<object>>();

// The types and names (if headerRow is true) will be stored in these lists
List<Type> columnTypes = new List<Type>();
List<string> columnNames = new List<string>();

// Read the column names from the header row (if there is one)
foreach (object name in rows[0])

// Read the column types from each row in the list of rows
foreach (List<object> row in rows)
for (int i = 0; i < row.Count; i++)
// If we're adding a new column to the columnTypes list, use its type.
// Otherwise, find the common type between the one that's there and the new row.
if (columnTypes.Count < i + 1)
else
columnTypes[i] = StringConverter.FindCommonType(columnTypes[i], row[i].GetType());
else

// Create the table and add the columns
DataTable table = new DataTable();
for (int i = 0; i < columnTypes.Count; i++)
{
table.Columns[i].DataType = columnTypes[i];
if (i < columnNames.Count)
table.Columns[i].ColumnName = columnNames[i];
}

// Add the data from the rows
foreach (List<object> row in rows)
{
DataRow dataRow = table.NewRow();
for (int i = 0; i < row.Count; i++)
dataRow[i] = row[i];
}
else

return table;
}

/// <summary>
/// Read a CSV file into a table
/// </summary>
/// <param name="filename">Filename of CSV file</param>
/// <param name="headerRow">True if the first row contains column names</param>
/// <param name="scanRows">The number of rows to scan for types when building a DataTable (0 to scan the whole file)</param>
/// <returns>System.Data.DataTable object that contains the CSV data</returns>
{
{
}
}

/// <summary>
/// Read a CSV file into a table
/// </summary>
/// <param name="filename">Filename of CSV file</param>
/// <param name="headerRow">True if the first row contains column names</param>
/// <returns>System.Data.DataTable object that contains the CSV data</returns>
{
}

#region IDisposable Members

public void Dispose()
{
{
try
{
// Can't call BinaryReader.Dispose due to its protection level
}
catch { }
}
}

#endregion
}
}

```
StringConverter.cs
```﻿/* CSVReader - a simple open source C# class library to read CSV data
* by Andrew Stellman - http://www.stellman-greene.com/CSVReader
*
* StringConverter.cs - Class to convert strings to typed objects
*
*
* (c) 2008, Stellman & Greene Consulting
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of Stellman & Greene Consulting nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY STELLMAN & GREENE CONSULTING ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL STELLMAN & GREENE CONSULTING BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/

using System;
using System.Collections.Generic;

{
/// <summary>
/// Static class to convert strings to typed values
/// </summary>
public static class StringConverter
{
public static Type ConvertString(string value, out object convertedValue)
{
// First check the whole number types, because floating point types will always parse whole numbers
byte byteResult;
if (byte.TryParse(value, out byteResult))
{
convertedValue = byteResult;
return typeof(byte);
}

short shortResult;
if (short.TryParse(value, out shortResult))
{
convertedValue = shortResult;
return typeof(short);
}

int intResult;
if (int.TryParse(value, out intResult))
{
convertedValue = intResult;
return typeof(int);
}

long longResult;
if (long.TryParse(value, out longResult))
{
convertedValue = longResult;
return typeof(long);
}

ulong ulongResult;
if (ulong.TryParse(value, out ulongResult))
{
convertedValue = ulongResult;
return typeof(ulong);
}

// No need to check the rest of the unsigned types, which will fit into the signed whole number types

// Next check the floating point types
float floatResult;
if (float.TryParse(value, out floatResult))
{
convertedValue = floatResult;
return typeof(float);
}

// It's not clear that there's anything that double.TryParse() and decimal.TryParse() will parse
// but which float.TryParse() won't
double doubleResult;
if (double.TryParse(value, out doubleResult))
{
convertedValue = doubleResult;
return typeof(double);
}

decimal decimalResult;
if (decimal.TryParse(value, out decimalResult))
{
convertedValue = decimalResult;
return typeof(decimal);
}

// It's not a number, so it's either a bool, char or string
bool boolResult;
if (bool.TryParse(value, out boolResult))
{
convertedValue = boolResult;
return typeof(bool);
}

char charResult;
if (char.TryParse(value, out charResult))
{
convertedValue = charResult;
return typeof(char);
}

convertedValue = value;
return typeof(string);
}

/// <summary>
/// Compare two types and find a type that can fit both of them
/// </summary>
/// <param name="typeA">First type to compare</param>
/// <param name="typeB">Second type to compare</param>
/// <returns>The type that can fit both types, or string if they're incompatible</returns>
public static Type FindCommonType(Type typeA, Type typeB)
{
// Build the singleton type map (which will rebuild it in a typesafe manner
// if it's not already built).
BuildTypeMap();

if (!typeMap.ContainsKey(typeA))
return typeof(string);

if (!typeMap[typeA].ContainsKey(typeB))
return typeof(string);

return typeMap[typeA][typeB];
}

// Dictionary to map two types to a common type that can hold both of them
private static Dictionary<Type, Dictionary<Type, Type>> typeMap = null;

// Locker object to build the singleton typeMap in a typesafe manner
private static object locker = new object();

/// <summary>
/// Build the singleton type map in a typesafe manner.
/// This map is a dictionary that maps a pair of types to a common type.
/// So typeMap[typeof(float)][typeof(uint)] will return float, while
/// typemap[typeof(char)][typeof(bool)] will return string.
/// </summary>
private static void BuildTypeMap()
{
lock (locker)
{
if (typeMap == null)
{
typeMap = new Dictionary<Type, Dictionary<Type, Type>>()
{
// Comparing byte
{typeof(byte), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(byte) },
{ typeof(short), typeof(short) },
{ typeof(int), typeof(int) },
{ typeof(long), typeof(long) },
{ typeof(ulong), typeof(ulong) },
{ typeof(float), typeof(float) },
{ typeof(double), typeof(double) },
{ typeof(decimal), typeof(decimal) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

// Comparing short
{typeof(short), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(short) },
{ typeof(short), typeof(short) },
{ typeof(int), typeof(int) },
{ typeof(long), typeof(long) },
{ typeof(ulong), typeof(ulong) },
{ typeof(float), typeof(float) },
{ typeof(double), typeof(double) },
{ typeof(decimal), typeof(decimal) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

// Comparing int
{typeof(int), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(int) },
{ typeof(short), typeof(int) },
{ typeof(int), typeof(int) },
{ typeof(long), typeof(long) },
{ typeof(ulong), typeof(ulong) },
{ typeof(float), typeof(float) },
{ typeof(double), typeof(double) },
{ typeof(decimal), typeof(decimal) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

// Comparing long
{typeof(long), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(long) },
{ typeof(short), typeof(long) },
{ typeof(int), typeof(long) },
{ typeof(long), typeof(long) },
{ typeof(ulong), typeof(ulong) },
{ typeof(float), typeof(float) },
{ typeof(double), typeof(double) },
{ typeof(decimal), typeof(decimal) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

// Comparing ulong
{typeof(ulong), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(ulong) },
{ typeof(short), typeof(ulong) },
{ typeof(int), typeof(ulong) },
{ typeof(long), typeof(ulong) },
{ typeof(ulong), typeof(ulong) },
{ typeof(float), typeof(float) },
{ typeof(double), typeof(double) },
{ typeof(decimal), typeof(decimal) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

// Comparing float
{typeof(float), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(float) },
{ typeof(short), typeof(float) },
{ typeof(int), typeof(float) },
{ typeof(long), typeof(float) },
{ typeof(ulong), typeof(float) },
{ typeof(float), typeof(float) },
{ typeof(double), typeof(double) },
{ typeof(decimal), typeof(decimal) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

// Comparing double
{typeof(double), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(double) },
{ typeof(short), typeof(double) },
{ typeof(int), typeof(double) },
{ typeof(long), typeof(double) },
{ typeof(ulong), typeof(double) },
{ typeof(float), typeof(double) },
{ typeof(double), typeof(double) },
{ typeof(decimal), typeof(decimal) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

// Comparing decimal
{typeof(decimal), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(decimal) },
{ typeof(short), typeof(decimal) },
{ typeof(int), typeof(decimal) },
{ typeof(long), typeof(decimal) },
{ typeof(ulong), typeof(decimal) },
{ typeof(float), typeof(decimal) },
{ typeof(double), typeof(decimal) },
{ typeof(decimal), typeof(decimal) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

// Comparing bool
{typeof(bool), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(string) },
{ typeof(short), typeof(string) },
{ typeof(int), typeof(string) },
{ typeof(long), typeof(string) },
{ typeof(ulong), typeof(string) },
{ typeof(float), typeof(string) },
{ typeof(double), typeof(string) },
{ typeof(decimal), typeof(string) },
{ typeof(bool), typeof(bool) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

// Comparing char
{typeof(char), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(string) },
{ typeof(short), typeof(string) },
{ typeof(int), typeof(string) },
{ typeof(long), typeof(string) },
{ typeof(ulong), typeof(string) },
{ typeof(float), typeof(string) },
{ typeof(double), typeof(string) },
{ typeof(decimal), typeof(string) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(char) },
{ typeof(string), typeof(string) },
}},

// Comparing string
{typeof(string), new Dictionary<Type, Type>() {
{ typeof(byte), typeof(string) },
{ typeof(short), typeof(string) },
{ typeof(int), typeof(string) },
{ typeof(long), typeof(string) },
{ typeof(ulong), typeof(string) },
{ typeof(float), typeof(string) },
{ typeof(double), typeof(string) },
{ typeof(decimal), typeof(string) },
{ typeof(bool), typeof(string) },
{ typeof(char), typeof(string) },
{ typeof(string), typeof(string) },
}},

};
}
}
}
}
}

```
Struct.cs
```﻿/*
* Created by SharpDevelop.
* Date: 2014/6/12
* Time: 下午 09:30
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using ChartDirector;

namespace WindowsApplication1
{
public class testClass
{
public int arrayLen;
public int[] array { get; set; }

public testClass(int len)
{
arrayLen = len;
array = new int[arrayLen];
}

public string printArray()
{
return ("array len" + this.array[1]);
}

}

/* Old Capital API
public class FullTick
{
public TICK tick;
public short marketNo;
public short stockIdx;
}
*/

public class FullTick
{
public string marketNo;
public short stockIdx;
public int m_nPtr; // KEY
public int m_nTime; //時間
public int m_nBid; // 買價
public int m_nClose; //成交價
public int m_nQty; // 成交量
public int nSimulate;//揭示
public int infobarPos;
}

public struct ValueItem
{
public DateTime time;
public string item;
public string value;
}

public struct Item
{
public string item;
public string value;
}

{
public int m_nBid1;
public int m_nBidQty1;
public int m_nBid2;
public int m_nBidQty2;
public int m_nBid3;
public int m_nBidQty3;
public int m_nBid4;
public int m_nBidQty4;
public int m_nBid5;
public int m_nBidQty5;
public int m_nExtendBid;
public int m_nExtendBidQty;

}
{
#region "Constant"
public int barPos { get; set; }
public int barLength { get; set; }
public DateTime[] barTime { get; set; }
public int[] time { get; set; }

public int[] dailyTradeVol { get; set; }

public string futureStockNo { get; set; }
public int[] buyTotalCount { get; set; }
public int[] sellTotalCount { get; set; }

public int[] buyTotalQty { get; set; }
public int[] sellTotalQty { get; set; }

public int[] buyDealTotalQty { get; set; }
public int[] sellDealTotalQty { get; set; }
#endregion

{
barPos = -1;
futureStockNo = futureNo;
}
}

public class KBar
{
#region "Constant"
public int VAR9BURN { get; set; }
public int VAR9HEAT { get; set; }
public int VAR9OVER { get; set; }
public int VAR9STRONG { get; set; }
public int VAR9UP { get; set; }
public int VAR9ABOVE { get; set; }
public int VAR9MID { get; set; }
public int VAR9BELOW { get; set; }
public int VAR9DOWN { get; set; }
public int VAR9WEAK { get; set; }
public int VAR9UNDER { get; set; }
public int VAR9COLD { get; set; }
public int VAR9ICED { get; set; }

public int KDBURN { get; set; }
public int KDHEAT { get; set; }
public int KDOVER { get; set; }
public int KDSTRONG { get; set; }
public int KDUP { get; set; }
public int KDABOVE { get; set; }
public int KDMID { get; set; }
public int KDBELOW { get; set; }
public int KDDOWN { get; set; }
public int KDWEAK { get; set; }
public int KDUNDER { get; set; }
public int KDCOLD { get; set; }
public int KDICED { get; set; }
#endregion

#region "Constructor"
public void Init0(double[] val)
{

for (int i = 0; i < barLength; i++)
{
val[i] = 0;
}

}

public void InitVal(DateTime[] val)
{
// Initialize data buffer to no data.
for (int i = 0; i < barLength; ++i)
{
barTime[i] = DateTime.MinValue;
}
}

public void InitVal(double[] val)
{

for (int i = 0; i < barLength; i++)
{
val[i] = Chart.NoValue;
}

}

public void InitBarArray()
{
InitVal(trendLineData);

InitVal(ma2);
InitVal(ma5);
InitVal(ma7);
InitVal(ma10);
InitVal(ma18);
InitVal(ma20);
InitVal(ma30);
InitVal(ma60);
InitVal(ma90);
InitVal(ma120);
InitVal(ma180);
InitVal(ma300);
InitVal(ma540);
InitVal(ma900);
InitVal(ma1500);
InitVal(ma2700);
InitVal(ma8100);

InitVal(ema5);
InitVal(ema7);
InitVal(ema10);
InitVal(ema20);
InitVal(ema30);
InitVal(ema60);
InitVal(ema90);
InitVal(ema150);
InitVal(ema180);
InitVal(ema300);
InitVal(ema900);

InitVal(ama10);
InitVal(ama20);
InitVal(ama30);
InitVal(ama60);
InitVal(ama90);
InitVal(ama180);
InitVal(ama300);
InitVal(ama900);

InitVal(hma10);
InitVal(hma20);
InitVal(hma30);
InitVal(hma60);
InitVal(hma90);
InitVal(hma180);
InitVal(hma300);
InitVal(hma900);

InitVal(swing10);
InitVal(swing20);
InitVal(swing30);
InitVal(swing60);
InitVal(swing90);
InitVal(swing180);
InitVal(swing300);
InitVal(swing900);

InitVal(hswing10);
InitVal(hswing20);
InitVal(hswing30);
InitVal(hswing60);
InitVal(hswing90);
InitVal(hswing180);
InitVal(hswing300);
InitVal(hswing900);

InitVal(m1var9a);
InitVal(m1var9);
InitVal(m2var9a);
InitVal(m2var9);
InitVal(m3var9a);
InitVal(m3var9);
InitVal(m5var9a);
InitVal(m5var9);
InitVal(m9var9a);
InitVal(m9var9);
InitVal(m15var9a);
InitVal(m15var9);
InitVal(m27var9a);
InitVal(m27var9);
InitVal(m45var9a);
InitVal(m45var9);
InitVal(m81var9a);
InitVal(m81var9);

InitVal(upma60);
InitVal(downma60);
InitVal(upma90);
InitVal(downma90);
InitVal(upma180);
InitVal(downma180);
InitVal(upma300);
InitVal(downma300);

InitVal(MPM1SELL);
InitVal(MPM2SELL);
InitVal(MPM3SELL);

InitVal(MA20SELL);
InitVal(MA30SELL);
InitVal(MA60SELL);
InitVal(MA90SELL);

InitVal(KD1SELL);
InitVal(KD2SELL);
InitVal(KD3SELL);
InitVal(KD5SELL);

InitVal(M1SELL);
InitVal(M2SELL);
InitVal(M3SELL);
InitVal(M5SELL);
InitVal(M9SELL);
InitVal(M15SELL);
InitVal(M27SELL);
InitVal(M45SELL);
InitVal(M81SELL);

InitVal(KD1BURN);
InitVal(KD1HEAT);
InitVal(KD1OVER);
InitVal(KD1STRONG);
InitVal(KD1UP);
InitVal(KD1DOWN);
InitVal(KD1WEAK);
InitVal(KD1UNDER);
InitVal(KD1COLD);
InitVal(KD1ICED);

InitVal(KD2BURN);
InitVal(KD2HEAT);
InitVal(KD2OVER);
InitVal(KD2STRONG);
InitVal(KD2UP);
InitVal(KD2DOWN);
InitVal(KD2WEAK);
InitVal(KD2UNDER);
InitVal(KD2COLD);
InitVal(KD2ICED);

InitVal(KD3BURN);
InitVal(KD3HEAT);
InitVal(KD3OVER);
InitVal(KD3STRONG);
InitVal(KD3UP);
InitVal(KD3DOWN);
InitVal(KD3WEAK);
InitVal(KD3UNDER);
InitVal(KD3COLD);
InitVal(KD3ICED);

InitVal(KD5BURN);
InitVal(KD5HEAT);
InitVal(KD5OVER);
InitVal(KD5STRONG);
InitVal(KD5UP);
InitVal(KD5DOWN);
InitVal(KD5WEAK);
InitVal(KD5UNDER);
InitVal(KD5COLD);
InitVal(KD5ICED);

InitVal(M1BURN);
InitVal(M1HEAT);
InitVal(M1OVER);
InitVal(M1STRONG);
InitVal(M1UP);
InitVal(M1DOWN);
InitVal(M1WEAK);
InitVal(M1UNDER);
InitVal(M1COLD);
InitVal(M1ICED);

InitVal(M2BURN);
InitVal(M2HEAT);
InitVal(M2OVER);
InitVal(M2STRONG);
InitVal(M2UP);
InitVal(M2DOWN);
InitVal(M2WEAK);
InitVal(M2UNDER);
InitVal(M2COLD);
InitVal(M2ICED);

InitVal(M3BURN);
InitVal(M3HEAT);
InitVal(M3OVER);
InitVal(M3STRONG);
InitVal(M3UP);
InitVal(M3DOWN);
InitVal(M3WEAK);
InitVal(M3UNDER);
InitVal(M3COLD);
InitVal(M3ICED);

InitVal(M5BURN);
InitVal(M5HEAT);
InitVal(M5OVER);
InitVal(M5STRONG);
InitVal(M5UP);
InitVal(M5DOWN);
InitVal(M5WEAK);
InitVal(M5UNDER);
InitVal(M5COLD);
InitVal(M5ICED);

InitVal(M9BURN);
InitVal(M9HEAT);
InitVal(M9OVER);
InitVal(M9STRONG);
InitVal(M9UP);
InitVal(M9DOWN);
InitVal(M9WEAK);
InitVal(M9UNDER);
InitVal(M9COLD);
InitVal(M9ICED);

InitVal(M15BURN);
InitVal(M15HEAT);
InitVal(M15OVER);
InitVal(M15STRONG);
InitVal(M15UP);
InitVal(M15DOWN);
InitVal(M15WEAK);
InitVal(M15UNDER);
InitVal(M15COLD);
InitVal(M15ICED);

InitVal(M27BURN);
InitVal(M27HEAT);
InitVal(M27OVER);
InitVal(M27STRONG);
InitVal(M27UP);
InitVal(M27DOWN);
InitVal(M27WEAK);
InitVal(M27UNDER);
InitVal(M27COLD);
InitVal(M27ICED);

InitVal(M45BURN);
InitVal(M45HEAT);
InitVal(M45OVER);
InitVal(M45STRONG);
InitVal(M45UP);
InitVal(M45DOWN);
InitVal(M45WEAK);
InitVal(M45UNDER);
InitVal(M45COLD);
InitVal(M45ICED);

InitVal(M81BURN);
InitVal(M81HEAT);
InitVal(M81OVER);
InitVal(M81STRONG);
InitVal(M81UP);
InitVal(M81DOWN);
InitVal(M81WEAK);
InitVal(M81UNDER);
InitVal(M81COLD);
InitVal(M81ICED);

Init0(M1VAR9ABNK);
Init0(M1VAR9ASNK);
Init0(M2VAR9ABNK);
Init0(M2VAR9ASNK);
Init0(M3VAR9ABNK);
Init0(M3VAR9ASNK);
Init0(M5VAR9ABNK);
Init0(M5VAR9ASNK);
Init0(M9VAR9ABNK);
Init0(M9VAR9ASNK);
Init0(M15VAR9ABNK);
Init0(M15VAR9ASNK);
Init0(M27VAR9ABNK);
Init0(M27VAR9ASNK);
Init0(M45VAR9ABNK);
Init0(M45VAR9ASNK);
Init0(M81VAR9ABNK);
Init0(M81VAR9ASNK);

Init0(HLM1OVER);
Init0(HLM1UNDER);
Init0(HLM2OVER);
Init0(HLM2UNDER);

Init0(TRENDSELL);

Init0(BIGTRENDSELL);

Init0(supportA1);
Init0(supportA2);
Init0(supportB1);
Init0(supportB2);
Init0(supportC1);
Init0(supportC2);
Init0(supportD1);
Init0(supportD2);
Init0(supportE1);
Init0(supportE2);

Init0(bsLine1);
Init0(bsLine1);

Init0(diffDealTotalQty);
Init0(diffTotalCount);
Init0(diffTotalQty);
}

public void setSupport(double curSA1, double curSA2, double curSB1, double curSB2, double curSC1, double curSC2, double curSD1, double curSD2, double curSE1, double curSE2, double curBS1, double curBS2)
{
nSupportA1 = curSA1;
nSupportA2 = curSA2;
nSupportB1 = curSB1;
nSupportB2 = curSB2;
nSupportC1 = curSC1;
nSupportC2 = curSC2;
nSupportD1 = curSD1;
nSupportD2 = curSD2;
nSupportE1 = curSE1;
nSupportE2 = curSE2;

nBSLine1 = curBS1;
nBSLine2 = curBS2;

}
public KBar(int len, bool bTickBar, int nCount, int nK, bool drawChartDirector, string sName = "", string sNo = "", short sMarket = 0, short nIdx = -1)
{
VAR9BURN = 142;
VAR9HEAT = 130;
VAR9OVER = 123;
VAR9STRONG = 117;
VAR9UP = 110;
VAR9ABOVE = 95;
VAR9MID = 75;
VAR9BELOW = 55;
VAR9DOWN = 40;
VAR9WEAK = 33;
VAR9UNDER = 27;
VAR9COLD = 20;
VAR9ICED = 8;

KDBURN = 90;
KDHEAT = 87;
KDOVER = 84;
KDSTRONG = 81;
KDUP = 77;
KDABOVE = 70;
KDMID = 50;
KDBELOW = 30;
KDDOWN = 23;
KDWEAK = 19;
KDUNDER = 16;
KDCOLD = 13;
KDICED = 10;

previousEndPos = -1;
barPos = -1;
barLength = len;

isTickBar = bTickBar;
tickCount = nCount;
nKBar = nK;

stockName = sName;
stockNo = sNo;
marketNo = sMarket;
stockIdx = nIdx;

barTime = new DateTime[barLength];
date = new int[barLength];
time = new int[barLength];

todayHigh = new double[barLength];
todayLow = new double[barLength];
todayOpen = new double[barLength];
lastClose = new double[barLength];

vol = new double[barLength];
high = new double[barLength];
open = new double[barLength];
low = new double[barLength];
close = new double[barLength];
bChartDirector = drawChartDirector;

if (bChartDirector)
{
InitVal(todayHigh);
InitVal(todayLow);
InitVal(todayOpen);
InitVal(lastClose);

InitVal(vol);
InitVal(high);
InitVal(open);
InitVal(low);
InitVal(close);

trendLineData = new double[barLength];

val0 = new double[barLength];
val1 = new double[barLength];
val2 = new double[barLength];
val3 = new double[barLength];
val4 = new double[barLength];
val5 = new double[barLength];
val6 = new double[barLength];
val7 = new double[barLength];
val8 = new double[barLength];
val9 = new double[barLength];

ma2 = new double[barLength];
ma5 = new double[barLength];
ma7 = new double[barLength];
ma10 = new double[barLength];
ma18 = new double[barLength];
ma20 = new double[barLength];
ma30 = new double[barLength];
ma60 = new double[barLength];
ma90 = new double[barLength];
ma120 = new double[barLength];
ma180 = new double[barLength];
ma300 = new double[barLength];
ma540 = new double[barLength];
ma900 = new double[barLength];
ma1500 = new double[barLength];
ma2700 = new double[barLength];
ma8100 = new double[barLength];

ema5 = new double[barLength];
ema7 = new double[barLength];
ema10 = new double[barLength];
ema20 = new double[barLength];
ema30 = new double[barLength];
ema60 = new double[barLength];
ema90 = new double[barLength];
ema150 = new double[barLength];
ema180 = new double[barLength];
ema300 = new double[barLength];
ema900 = new double[barLength];

ama10 = new double[barLength];
ama20 = new double[barLength];
ama30 = new double[barLength];
ama60 = new double[barLength];
ama90 = new double[barLength];
ama180 = new double[barLength];
ama300 = new double[barLength];
ama900 = new double[barLength];

hma10 = new double[barLength];
hma20 = new double[barLength];
hma30 = new double[barLength];
hma60 = new double[barLength];
hma90 = new double[barLength];
hma180 = new double[barLength];
hma300 = new double[barLength];
hma900 = new double[barLength];

dma10 = new double[barLength];
dma20 = new double[barLength];
dma30 = new double[barLength];
dma60 = new double[barLength];
dma90 = new double[barLength];
dma180 = new double[barLength];
dma300 = new double[barLength];
dma900 = new double[barLength];

swing10 = new double[barLength];
swing20 = new double[barLength];
swing30 = new double[barLength];
swing60 = new double[barLength];
swing90 = new double[barLength];
swing180 = new double[barLength];
swing300 = new double[barLength];
swing900 = new double[barLength];

hswing10 = new double[barLength];
hswing20 = new double[barLength];
hswing30 = new double[barLength];
hswing60 = new double[barLength];
hswing90 = new double[barLength];
hswing180 = new double[barLength];
hswing300 = new double[barLength];
hswing900 = new double[barLength];

noise10 = new double[barLength];
noise20 = new double[barLength];
noise30 = new double[barLength];
noise60 = new double[barLength];
noise90 = new double[barLength];
noise180 = new double[barLength];
noise300 = new double[barLength];
noise900 = new double[barLength];

powerama10 = new double[barLength];
powerama20 = new double[barLength];
powerama30 = new double[barLength];
powerama60 = new double[barLength];
powerama90 = new double[barLength];
powerama180 = new double[barLength];
powerama300 = new double[barLength];
powerama540 = new double[barLength];
powerama900 = new double[barLength];

powerhma10 = new double[barLength];
powerhma20 = new double[barLength];
powerhma30 = new double[barLength];
powerhma60 = new double[barLength];
powerhma90 = new double[barLength];
powerhma180 = new double[barLength];
powerhma300 = new double[barLength];
powerhma540 = new double[barLength];
powerhma900 = new double[barLength];

sumama10 = new double[barLength];
sumama20 = new double[barLength];
sumama30 = new double[barLength];
sumama60 = new double[barLength];
sumama90 = new double[barLength];
sumama180 = new double[barLength];
sumama300 = new double[barLength];
sumama540 = new double[barLength];
sumama900 = new double[barLength];

sumhma10 = new double[barLength];
sumhma20 = new double[barLength];
sumhma30 = new double[barLength];
sumhma60 = new double[barLength];
sumhma90 = new double[barLength];
sumhma180 = new double[barLength];
sumhma300 = new double[barLength];
sumhma540 = new double[barLength];
sumhma900 = new double[barLength];

highPos6 = new int[barLength];
highPos9 = new int[barLength];
highPos18 = new int[barLength];
highPos27 = new int[barLength];
highPos45 = new int[barLength];
highPos81 = new int[barLength];
highPos102 = new int[barLength];
highPos135 = new int[barLength];
highPos243 = new int[barLength];
highPos306 = new int[barLength];
highPos405 = new int[barLength];
highPos729 = new int[barLength];

lowPos6 = new int[barLength];
lowPos9 = new int[barLength];
lowPos18 = new int[barLength];
lowPos27 = new int[barLength];
lowPos45 = new int[barLength];
lowPos81 = new int[barLength];
lowPos102 = new int[barLength];
lowPos135 = new int[barLength];
lowPos243 = new int[barLength];
lowPos306 = new int[barLength];
lowPos405 = new int[barLength];
lowPos729 = new int[barLength];

highest6 = new double[barLength];
highest9 = new double[barLength];
highest18 = new double[barLength];
highest27 = new double[barLength];
highest45 = new double[barLength];
highest81 = new double[barLength];
highest102 = new double[barLength];
highest135 = new double[barLength];
highest243 = new double[barLength];
highest306 = new double[barLength];
highest405 = new double[barLength];
highest729 = new double[barLength];

lowest6 = new double[barLength];
lowest9 = new double[barLength];
lowest18 = new double[barLength];
lowest27 = new double[barLength];
lowest45 = new double[barLength];
lowest81 = new double[barLength];
lowest102 = new double[barLength];
lowest135 = new double[barLength];
lowest243 = new double[barLength];
lowest306 = new double[barLength];
lowest405 = new double[barLength];
lowest729 = new double[barLength];

MRSH1 = new double[barLength];
MRSH2 = new double[barLength];
MRSH3 = new double[barLength];
MRSH5 = new double[barLength];
MRSH9 = new double[barLength];
MRSH15 = new double[barLength];
MRSH27 = new double[barLength];
MRSH45 = new double[barLength];
MRSH81 = new double[barLength];

k1 = new double[barLength];
d1 = new double[barLength];
k2 = new double[barLength];
d2 = new double[barLength];
k3 = new double[barLength];
d3 = new double[barLength];
k5 = new double[barLength];
d5 = new double[barLength];
k9 = new double[barLength];
d9 = new double[barLength];
k15 = new double[barLength];
d15 = new double[barLength];
k27 = new double[barLength];
d27 = new double[barLength];
k45 = new double[barLength];
d45 = new double[barLength];
k81 = new double[barLength];
d81 = new double[barLength];

m1var9a = new double[barLength];
m1var9 = new double[barLength];
m2var9a = new double[barLength];
m2var9 = new double[barLength];
m3var9a = new double[barLength];
m3var9 = new double[barLength];
m5var9a = new double[barLength];
m5var9 = new double[barLength];
m9var9a = new double[barLength];
m9var9 = new double[barLength];
m15var9a = new double[barLength];
m15var9 = new double[barLength];
m27var9a = new double[barLength];
m27var9 = new double[barLength];
m45var9a = new double[barLength];
m45var9 = new double[barLength];
m81var9a = new double[barLength];
m81var9 = new double[barLength];

wu3var12 = new double[barLength];
wu9var12 = new double[barLength];
wu3testc = new double[barLength];
wu9testc = new double[barLength];

MPM1HH = new double[barLength];
MPM2HH = new double[barLength];
MPM3HH = new double[barLength];

MPM1LL = new double[barLength];
MPM2LL = new double[barLength];
MPM3LL = new double[barLength];

MPM1VAR3 = new int[barLength];
MPM2VAR3 = new int[barLength];
MPM3VAR3 = new int[barLength];

MA20SELL = new double[barLength];
MA30SELL = new double[barLength];
MA60SELL = new double[barLength];
MA90SELL = new double[barLength];

MPM1SELL = new double[barLength];
MPM2SELL = new double[barLength];
MPM3SELL = new double[barLength];

M1VAR9ABNK = new double[barLength];
M1VAR9ASNK = new double[barLength];

M2VAR9ABNK = new double[barLength];
M2VAR9ASNK = new double[barLength];

M3VAR9ABNK = new double[barLength];
M3VAR9ASNK = new double[barLength];

M5VAR9ABNK = new double[barLength];
M5VAR9ASNK = new double[barLength];

M9VAR9ABNK = new double[barLength];
M9VAR9ASNK = new double[barLength];

M15VAR9ABNK = new double[barLength];
M15VAR9ASNK = new double[barLength];

M27VAR9ABNK = new double[barLength];
M27VAR9ASNK = new double[barLength];

M45VAR9ABNK = new double[barLength];
M45VAR9ASNK = new double[barLength];

M81VAR9ABNK = new double[barLength];
M81VAR9ASNK = new double[barLength];

upma60 = new double[barLength];
downma60 = new double[barLength];
upma90 = new double[barLength];
downma90 = new double[barLength];
upma180 = new double[barLength];
downma180 = new double[barLength];
upma300 = new double[barLength];
downma300 = new double[barLength];

KD1SELL = new double[barLength];
KD2SELL = new double[barLength];
KD3SELL = new double[barLength];
KD5SELL = new double[barLength];

M1SELL = new double[barLength];
M2SELL = new double[barLength];
M3SELL = new double[barLength];
M5SELL = new double[barLength];
M9SELL = new double[barLength];
M15SELL = new double[barLength];
M27SELL = new double[barLength];
M45SELL = new double[barLength];
M81SELL = new double[barLength];

KD1BURN = new double[barLength];
KD1HEAT = new double[barLength];
KD1OVER = new double[barLength];
KD1STRONG = new double[barLength];
KD1UP = new double[barLength];
KD1DOWN = new double[barLength];
KD1WEAK = new double[barLength];
KD1UNDER = new double[barLength];
KD1COLD = new double[barLength];
KD1ICED = new double[barLength];

KD2BURN = new double[barLength];
KD2HEAT = new double[barLength];
KD2OVER = new double[barLength];
KD2STRONG = new double[barLength];
KD2UP = new double[barLength];
KD2DOWN = new double[barLength];
KD2WEAK = new double[barLength];
KD2UNDER = new double[barLength];
KD2COLD = new double[barLength];
KD2ICED = new double[barLength];

KD3BURN = new double[barLength];
KD3HEAT = new double[barLength];
KD3OVER = new double[barLength];
KD3STRONG = new double[barLength];
KD3UP = new double[barLength];
KD3DOWN = new double[barLength];
KD3WEAK = new double[barLength];
KD3UNDER = new double[barLength];
KD3COLD = new double[barLength];
KD3ICED = new double[barLength];

KD5BURN = new double[barLength];
KD5HEAT = new double[barLength];
KD5OVER = new double[barLength];
KD5STRONG = new double[barLength];
KD5UP = new double[barLength];
KD5DOWN = new double[barLength];
KD5WEAK = new double[barLength];
KD5UNDER = new double[barLength];
KD5COLD = new double[barLength];
KD5ICED = new double[barLength];

M1BURN = new double[barLength];
M1HEAT = new double[barLength];
M1OVER = new double[barLength];
M1STRONG = new double[barLength];
M1UP = new double[barLength];
M1DOWN = new double[barLength];
M1WEAK = new double[barLength];
M1UNDER = new double[barLength];
M1COLD = new double[barLength];
M1ICED = new double[barLength];

M2BURN = new double[barLength];
M2HEAT = new double[barLength];
M2OVER = new double[barLength];
M2STRONG = new double[barLength];
M2UP = new double[barLength];
M2DOWN = new double[barLength];
M2WEAK = new double[barLength];
M2UNDER = new double[barLength];
M2COLD = new double[barLength];
M2ICED = new double[barLength];

M3BURN = new double[barLength];
M3HEAT = new double[barLength];
M3OVER = new double[barLength];
M3STRONG = new double[barLength];
M3UP = new double[barLength];
M3DOWN = new double[barLength];
M3WEAK = new double[barLength];
M3UNDER = new double[barLength];
M3COLD = new double[barLength];
M3ICED = new double[barLength];

M5BURN = new double[barLength];
M5HEAT = new double[barLength];
M5OVER = new double[barLength];
M5STRONG = new double[barLength];
M5UP = new double[barLength];
M5DOWN = new double[barLength];
M5WEAK = new double[barLength];
M5UNDER = new double[barLength];
M5COLD = new double[barLength];
M5ICED = new double[barLength];

M9BURN = new double[barLength];
M9HEAT = new double[barLength];
M9OVER = new double[barLength];
M9STRONG = new double[barLength];
M9UP = new double[barLength];
M9DOWN = new double[barLength];
M9WEAK = new double[barLength];
M9UNDER = new double[barLength];
M9COLD = new double[barLength];
M9ICED = new double[barLength];

M15BURN = new double[barLength];
M15HEAT = new double[barLength];
M15OVER = new double[barLength];
M15STRONG = new double[barLength];
M15UP = new double[barLength];
M15DOWN = new double[barLength];
M15WEAK = new double[barLength];
M15UNDER = new double[barLength];
M15COLD = new double[barLength];
M15ICED = new double[barLength];

M27BURN = new double[barLength];
M27HEAT = new double[barLength];
M27OVER = new double[barLength];
M27STRONG = new double[barLength];
M27UP = new double[barLength];
M27DOWN = new double[barLength];
M27WEAK = new double[barLength];
M27UNDER = new double[barLength];
M27COLD = new double[barLength];
M27ICED = new double[barLength];

M45BURN = new double[barLength];
M45HEAT = new double[barLength];
M45OVER = new double[barLength];
M45STRONG = new double[barLength];
M45UP = new double[barLength];
M45DOWN = new double[barLength];
M45WEAK = new double[barLength];
M45UNDER = new double[barLength];
M45COLD = new double[barLength];
M45ICED = new double[barLength];

M81BURN = new double[barLength];
M81HEAT = new double[barLength];
M81OVER = new double[barLength];
M81STRONG = new double[barLength];
M81UP = new double[barLength];
M81DOWN = new double[barLength];
M81WEAK = new double[barLength];
M81UNDER = new double[barLength];
M81COLD = new double[barLength];
M81ICED = new double[barLength];

HLM1OVER = new double[barLength];
HLM1UNDER = new double[barLength];
HLM2OVER = new double[barLength];
HLM2UNDER = new double[barLength];

TRENDSELL = new double[barLength];

BIGTRENDSELL = new double[barLength];

supportA1 = new double[barLength];
supportA2 = new double[barLength];
supportB1 = new double[barLength];
supportB2 = new double[barLength];
supportC1 = new double[barLength];
supportC2 = new double[barLength];
supportD1 = new double[barLength];
supportD2 = new double[barLength];
supportE1 = new double[barLength];
supportE2 = new double[barLength];

bsLine1 = new double[barLength];
bsLine2 = new double[barLength];

diffDealTotalQty = new double[barLength]; ;
diffTotalCount = new double[barLength];
diffTotalQty = new double[barLength];

InitBarArray();
}
}

#endregion

#region "Class elements"

//For TickInfo
public double[] diffDealTotalQty { get; set; }
public double[] diffTotalCount { get; set; }
public double[] diffTotalQty { get; set; }
public double nSupportA1 { get; set; }
public double nSupportA2 { get; set; }
public double nSupportB1 { get; set; }
public double nSupportB2 { get; set; }
public double nSupportC1 { get; set; }
public double nSupportC2 { get; set; }
public double nSupportD1 { get; set; }
public double nSupportD2 { get; set; }
public double nSupportE1 { get; set; }
public double nSupportE2 { get; set; }
public double nBSLine1 { get; set; }
public double nBSLine2 { get; set; }

public string stockName { get; set; }
public string stockNo { get; set; }
public short marketNo { get; set; }
public short stockIdx { get; set; }
public int previousEndPos { get; set; }
public bool isTickBar { get; set; }
public bool bChartDirector { get; set; }
public int nKBar { get; set; }
public int barPos { get; set; }
public int tickCount { get; set; }
public int barLength { get; set; }
public DateTime[] barTime { get; set; }
public int[] date { get; set; }
public int[] time { get; set; }
public double[] vol { get; set; }

public double[] todayHigh { get; set; }
public double[] todayLow { get; set; }
public double[] todayOpen { get; set; }
public double[] lastClose { get; set; }

public double[] open { get; set; }
public double[] high { get; set; }
public double[] low { get; set; }
public double[] close { get; set; }

public double[] trendLineData { get; set; }

public double[] ma2 { get; set; }
public double[] ma5 { get; set; }
public double[] ma7 { get; set; }
public double[] ma10 { get; set; }
public double[] ma18 { get; set; }
public double[] ma20 { get; set; }
public double[] ma30 { get; set; }
public double[] ma60 { get; set; }
public double[] ma90 { get; set; }
public double[] ma120 { get; set; }
public double[] ma180 { get; set; }
public double[] ma300 { get; set; }
public double[] ma540 { get; set; }
public double[] ma900 { get; set; }
public double[] ma1500 { get; set; }
public double[] ma2700 { get; set; }
public double[] ma8100 { get; set; }

public double[] ema5 { get; set; }
public double[] ema7 { get; set; }
public double[] ema10 { get; set; }
public double[] ema20 { get; set; }
public double[] ema30 { get; set; }
public double[] ema60 { get; set; }
public double[] ema90 { get; set; }
public double[] ema150 { get; set; }
public double[] ema180 { get; set; }
public double[] ema300 { get; set; }
public double[] ema900 { get; set; }

public double[] ama10 { get; set; }
public double[] ama20 { get; set; }
public double[] ama30 { get; set; }
public double[] ama60 { get; set; }
public double[] ama90 { get; set; }
public double[] ama180 { get; set; }
public double[] ama300 { get; set; }
public double[] ama900 { get; set; }

public double[] hma10 { get; set; }
public double[] hma20 { get; set; }
public double[] hma30 { get; set; }
public double[] hma60 { get; set; }
public double[] hma90 { get; set; }
public double[] hma180 { get; set; }
public double[] hma300 { get; set; }
public double[] hma900 { get; set; }

public double[] dma10 { get; set; }
public double[] dma20 { get; set; }
public double[] dma30 { get; set; }
public double[] dma60 { get; set; }
public double[] dma90 { get; set; }
public double[] dma180 { get; set; }
public double[] dma300 { get; set; }
public double[] dma900 { get; set; }

public double[] swing10 { get; set; }
public double[] swing20 { get; set; }
public double[] swing30 { get; set; }
public double[] swing60 { get; set; }
public double[] swing90 { get; set; }
public double[] swing180 { get; set; }
public double[] swing300 { get; set; }
public double[] swing900 { get; set; }

public double[] hswing10 { get; set; }
public double[] hswing20 { get; set; }
public double[] hswing30 { get; set; }
public double[] hswing60 { get; set; }
public double[] hswing90 { get; set; }
public double[] hswing180 { get; set; }
public double[] hswing300 { get; set; }
public double[] hswing900 { get; set; }

public double[] noise10 { get; set; }
public double[] noise20 { get; set; }
public double[] noise30 { get; set; }
public double[] noise60 { get; set; }
public double[] noise90 { get; set; }
public double[] noise180 { get; set; }
public double[] noise300 { get; set; }
public double[] noise900 { get; set; }

public double[] powerama10 { get; set; }
public double[] powerama20 { get; set; }
public double[] powerama30 { get; set; }
public double[] powerama60 { get; set; }
public double[] powerama90 { get; set; }
public double[] powerama180 { get; set; }
public double[] powerama300 { get; set; }
public double[] powerama540 { get; set; }
public double[] powerama900 { get; set; }

public double[] powerhma10 { get; set; }
public double[] powerhma20 { get; set; }
public double[] powerhma30 { get; set; }
public double[] powerhma60 { get; set; }
public double[] powerhma90 { get; set; }
public double[] powerhma180 { get; set; }
public double[] powerhma300 { get; set; }
public double[] powerhma540 { get; set; }
public double[] powerhma900 { get; set; }

public double[] sumama10 { get; set; }
public double[] sumama20 { get; set; }
public double[] sumama30 { get; set; }
public double[] sumama60 { get; set; }
public double[] sumama90 { get; set; }
public double[] sumama180 { get; set; }
public double[] sumama300 { get; set; }
public double[] sumama540 { get; set; }
public double[] sumama900 { get; set; }

public double[] sumhma10 { get; set; }
public double[] sumhma20 { get; set; }
public double[] sumhma30 { get; set; }
public double[] sumhma60 { get; set; }
public double[] sumhma90 { get; set; }
public double[] sumhma180 { get; set; }
public double[] sumhma300 { get; set; }
public double[] sumhma540 { get; set; }
public double[] sumhma900 { get; set; }

public double[] val0 { get; set; }
public double[] val1 { get; set; }
public double[] val2 { get; set; }
public double[] val3 { get; set; }
public double[] val4 { get; set; }
public double[] val5 { get; set; }
public double[] val6 { get; set; }
public double[] val7 { get; set; }
public double[] val8 { get; set; }
public double[] val9 { get; set; }

public int[] highPos6 { get; set; }
public int[] highPos9 { get; set; }
public int[] highPos18 { get; set; }
public int[] highPos27 { get; set; }
public int[] highPos45 { get; set; }
public int[] highPos81 { get; set; }
public int[] highPos102 { get; set; }
public int[] highPos135 { get; set; }
public int[] highPos243 { get; set; }
public int[] highPos306 { get; set; }
public int[] highPos405 { get; set; }
public int[] highPos729 { get; set; }

public int[] lowPos6 { get; set; }
public int[] lowPos9 { get; set; }
public int[] lowPos18 { get; set; }
public int[] lowPos27 { get; set; }
public int[] lowPos45 { get; set; }
public int[] lowPos81 { get; set; }
public int[] lowPos102 { get; set; }
public int[] lowPos135 { get; set; }
public int[] lowPos243 { get; set; }
public int[] lowPos306 { get; set; }
public int[] lowPos405 { get; set; }
public int[] lowPos729 { get; set; }

public double[] highest6 { get; set; }
public double[] highest9 { get; set; }
public double[] highest18 { get; set; }
public double[] highest27 { get; set; }
public double[] highest45 { get; set; }
public double[] highest81 { get; set; }
public double[] highest102 { get; set; }
public double[] highest135 { get; set; }
public double[] highest243 { get; set; }
public double[] highest306 { get; set; }
public double[] highest405 { get; set; }
public double[] highest729 { get; set; }

public double[] lowest6 { get; set; }
public double[] lowest9 { get; set; }
public double[] lowest18 { get; set; }
public double[] lowest27 { get; set; }
public double[] lowest45 { get; set; }
public double[] lowest81 { get; set; }
public double[] lowest102 { get; set; }
public double[] lowest135 { get; set; }
public double[] lowest243 { get; set; }
public double[] lowest306 { get; set; }
public double[] lowest405 { get; set; }
public double[] lowest729 { get; set; }

public double[] MRSH1 { get; set; }
public double[] MRSH2 { get; set; }
public double[] MRSH3 { get; set; }
public double[] MRSH5 { get; set; }
public double[] MRSH9 { get; set; }
public double[] MRSH15 { get; set; }
public double[] MRSH27 { get; set; }
public double[] MRSH45 { get; set; }
public double[] MRSH81 { get; set; }

public double[] k1 { get; set; }
public double[] d1 { get; set; }
public double[] k2 { get; set; }
public double[] d2 { get; set; }
public double[] k3 { get; set; }
public double[] d3 { get; set; }
public double[] k5 { get; set; }
public double[] d5 { get; set; }
public double[] k9 { get; set; }
public double[] d9 { get; set; }
public double[] k15 { get; set; }
public double[] d15 { get; set; }
public double[] k27 { get; set; }
public double[] d27 { get; set; }
public double[] k45 { get; set; }
public double[] d45 { get; set; }
public double[] k81 { get; set; }
public double[] d81 { get; set; }

public double[] m1var9a { get; set; }
public double[] m1var9 { get; set; }
public double[] m2var9a { get; set; }
public double[] m2var9 { get; set; }
public double[] m3var9a { get; set; }
public double[] m3var9 { get; set; }
public double[] m5var9a { get; set; }
public double[] m5var9 { get; set; }
public double[] m9var9a { get; set; }
public double[] m9var9 { get; set; }
public double[] m15var9a { get; set; }
public double[] m15var9 { get; set; }
public double[] m27var9a { get; set; }
public double[] m27var9 { get; set; }
public double[] m45var9a { get; set; }
public double[] m45var9 { get; set; }
public double[] m81var9a { get; set; }
public double[] m81var9 { get; set; }

public double[] wu3var12 { get; set; }
public double[] wu9var12 { get; set; }

public double[] wu3testc { get; set; }
public double[] wu9testc { get; set; }

public double[] MPM1HH { get; set; }
public double[] MPM2HH { get; set; }
public double[] MPM3HH { get; set; }

public double[] MPM1LL { get; set; }
public double[] MPM2LL { get; set; }
public double[] MPM3LL { get; set; }

public int[] MPM1VAR3 { get; set; }
public int[] MPM2VAR3 { get; set; }
public int[] MPM3VAR3 { get; set; }

public double[] M1VAR9ABNK { get; set; }
public double[] M2VAR9ABNK { get; set; }
public double[] M3VAR9ABNK { get; set; }
public double[] M5VAR9ABNK { get; set; }
public double[] M9VAR9ABNK { get; set; }
public double[] M15VAR9ABNK { get; set; }
public double[] M27VAR9ABNK { get; set; }
public double[] M45VAR9ABNK { get; set; }
public double[] M81VAR9ABNK { get; set; }

public double[] M1VAR9ASNK { get; set; }
public double[] M2VAR9ASNK { get; set; }
public double[] M3VAR9ASNK { get; set; }
public double[] M5VAR9ASNK { get; set; }
public double[] M9VAR9ASNK { get; set; }
public double[] M15VAR9ASNK { get; set; }
public double[] M27VAR9ASNK { get; set; }
public double[] M45VAR9ASNK { get; set; }
public double[] M81VAR9ASNK { get; set; }

public double[] HLM1OVER { get; set; }
public double[] HLM1UNDER { get; set; }
public double[] HLM2OVER { get; set; }
public double[] HLM2UNDER { get; set; }

public double[] TRENDBUY { get; set; }
public double[] TRENDSELL { get; set; }

public double[] BIGTRENDBUY { get; set; }
public double[] BIGTRENDSELL { get; set; }

public double[] supportA1 { get; set; }
public double[] supportA2 { get; set; }
public double[] supportB1 { get; set; }
public double[] supportB2 { get; set; }
public double[] supportC1 { get; set; }
public double[] supportC2 { get; set; }
public double[] supportD1 { get; set; }
public double[] supportD2 { get; set; }
public double[] supportE1 { get; set; }
public double[] supportE2 { get; set; }
public double[] bsLine1 { get; set; }
public double[] bsLine2 { get; set; }
#endregion

#region "ChartDirector Elements"
public double[] upma60 { get; set; }
public double[] downma60 { get; set; }
public double[] upma90 { get; set; }
public double[] downma90 { get; set; }
public double[] upma180 { get; set; }
public double[] downma180 { get; set; }
public double[] upma300 { get; set; }
public double[] downma300 { get; set; }

public double[] MA20BUY { get; set; }
public double[] MA20SELL { get; set; }
public double[] MA30BUY { get; set; }
public double[] MA30SELL { get; set; }
public double[] MA60BUY { get; set; }
public double[] MA60SELL { get; set; }
public double[] MA90BUY { get; set; }
public double[] MA90SELL { get; set; }

public double[] MPM1BUY { get; set; }
public double[] MPM1SELL { get; set; }
public double[] MPM2BUY { get; set; }
public double[] MPM2SELL { get; set; }
public double[] MPM3BUY { get; set; }
public double[] MPM3SELL { get; set; }

public double[] KD1BUY { get; set; }
public double[] KD2BUY { get; set; }
public double[] KD3BUY { get; set; }
public double[] KD5BUY { get; set; }

public double[] KD1SELL { get; set; }
public double[] KD2SELL { get; set; }
public double[] KD3SELL { get; set; }
public double[] KD5SELL { get; set; }

public double[] M1BUY { get; set; }
public double[] M2BUY { get; set; }
public double[] M3BUY { get; set; }
public double[] M5BUY { get; set; }
public double[] M9BUY { get; set; }
public double[] M15BUY { get; set; }
public double[] M27BUY { get; set; }
public double[] M45BUY { get; set; }
public double[] M81BUY { get; set; }

public double[] M1SELL { get; set; }
public double[] M2SELL { get; set; }
public double[] M3SELL { get; set; }
public double[] M5SELL { get; set; }
public double[] M9SELL { get; set; }
public double[] M15SELL { get; set; }
public double[] M27SELL { get; set; }
public double[] M45SELL { get; set; }
public double[] M81SELL { get; set; }

public double[] KD1BURN { get; set; }
public double[] KD1HEAT { get; set; }
public double[] KD1OVER { get; set; }
public double[] KD1STRONG { get; set; }
public double[] KD1UP { get; set; }
public double[] KD1DOWN { get; set; }
public double[] KD1WEAK { get; set; }
public double[] KD1UNDER { get; set; }
public double[] KD1COLD { get; set; }
public double[] KD1ICED { get; set; }

public double[] KD2BURN { get; set; }
public double[] KD2HEAT { get; set; }
public double[] KD2OVER { get; set; }
public double[] KD2STRONG { get; set; }
public double[] KD2UP { get; set; }
public double[] KD2DOWN { get; set; }
public double[] KD2WEAK { get; set; }
public double[] KD2UNDER { get; set; }
public double[] KD2COLD { get; set; }
public double[] KD2ICED { get; set; }

public double[] KD3BURN { get; set; }
public double[] KD3HEAT { get; set; }
public double[] KD3OVER { get; set; }
public double[] KD3STRONG { get; set; }
public double[] KD3UP { get; set; }
public double[] KD3DOWN { get; set; }
public double[] KD3WEAK { get; set; }
public double[] KD3UNDER { get; set; }
public double[] KD3COLD { get; set; }
public double[] KD3ICED { get; set; }

public double[] KD5BURN { get; set; }
public double[] KD5HEAT { get; set; }
public double[] KD5OVER { get; set; }
public double[] KD5STRONG { get; set; }
public double[] KD5UP { get; set; }
public double[] KD5DOWN { get; set; }
public double[] KD5WEAK { get; set; }
public double[] KD5UNDER { get; set; }
public double[] KD5COLD { get; set; }
public double[] KD5ICED { get; set; }

public double[] M1BURN { get; set; }
public double[] M1HEAT { get; set; }
public double[] M1OVER { get; set; }
public double[] M1STRONG { get; set; }
public double[] M1UP { get; set; }
public double[] M1DOWN { get; set; }
public double[] M1WEAK { get; set; }
public double[] M1UNDER { get; set; }
public double[] M1COLD { get; set; }
public double[] M1ICED { get; set; }

public double[] M2BURN { get; set; }
public double[] M2HEAT { get; set; }
public double[] M2OVER { get; set; }
public double[] M2STRONG { get; set; }
public double[] M2UP { get; set; }
public double[] M2DOWN { get; set; }
public double[] M2WEAK { get; set; }
public double[] M2UNDER { get; set; }
public double[] M2COLD { get; set; }
public double[] M2ICED { get; set; }

public double[] M3BURN { get; set; }
public double[] M3HEAT { get; set; }
public double[] M3OVER { get; set; }
public double[] M3STRONG { get; set; }
public double[] M3UP { get; set; }
public double[] M3DOWN { get; set; }
public double[] M3WEAK { get; set; }
public double[] M3UNDER { get; set; }
public double[] M3COLD { get; set; }
public double[] M3ICED { get; set; }

public double[] M5BURN { get; set; }
public double[] M5HEAT { get; set; }
public double[] M5OVER { get; set; }
public double[] M5STRONG { get; set; }
public double[] M5UP { get; set; }
public double[] M5DOWN { get; set; }
public double[] M5WEAK { get; set; }
public double[] M5UNDER { get; set; }
public double[] M5COLD { get; set; }
public double[] M5ICED { get; set; }

public double[] M9BURN { get; set; }
public double[] M9HEAT { get; set; }
public double[] M9OVER { get; set; }
public double[] M9STRONG { get; set; }
public double[] M9UP { get; set; }
public double[] M9DOWN { get; set; }
public double[] M9WEAK { get; set; }
public double[] M9UNDER { get; set; }
public double[] M9COLD { get; set; }
public double[] M9ICED { get; set; }

public double[] M15BURN { get; set; }
public double[] M15HEAT { get; set; }
public double[] M15OVER { get; set; }
public double[] M15STRONG { get; set; }
public double[] M15UP { get; set; }
public double[] M15DOWN { get; set; }
public double[] M15WEAK { get; set; }
public double[] M15UNDER { get; set; }
public double[] M15COLD { get; set; }
public double[] M15ICED { get; set; }

public double[] M27BURN { get; set; }
public double[] M27HEAT { get; set; }
public double[] M27OVER { get; set; }
public double[] M27STRONG { get; set; }
public double[] M27UP { get; set; }
public double[] M27DOWN { get; set; }
public double[] M27WEAK { get; set; }
public double[] M27UNDER { get; set; }
public double[] M27COLD { get; set; }
public double[] M27ICED { get; set; }

public double[] M45BURN { get; set; }
public double[] M45HEAT { get; set; }
public double[] M45OVER { get; set; }
public double[] M45STRONG { get; set; }
public double[] M45UP { get; set; }
public double[] M45DOWN { get; set; }
public double[] M45WEAK { get; set; }
public double[] M45UNDER { get; set; }
public double[] M45COLD { get; set; }
public double[] M45ICED { get; set; }

public double[] M81BURN { get; set; }
public double[] M81HEAT { get; set; }
public double[] M81OVER { get; set; }
public double[] M81STRONG { get; set; }
public double[] M81UP { get; set; }
public double[] M81DOWN { get; set; }
public double[] M81WEAK { get; set; }
public double[] M81UNDER { get; set; }
public double[] M81COLD { get; set; }
public double[] M81ICED { get; set; }
#endregion

#region "Class Utilites Function"
public void GetAllHighest()
{

}

double Summation(int pos, double[] price, int len)
{
return 0;
}

public void Lowest(int pos, double[] price, int len, double[] lowest, int[] lowPos)
{
}

public void Highest(int pos, double[] price, int len, double[] highest, int[] highPos)
{
}

public void XVerageOrig(int pos, double[] price, int len, double[] result)
{
}

public void XVerage(int pos, double[] price, int len, double[] result)
{
}

public void CalWU(int pos, double highest, double lowest, double high, double low, double close, int wuLen, int var12Len, int ntcLen, int ntc1Len, double[] VAR12, double[] TESTC)
{
}

public void CalVAR9A(int pos, double highest, double lowest, double close, int stochLen, int len1, int len2, int var9Len,
double[] MRSH, double[] KA, double[] DA, double[] VAR9A, double[] VAR9,
double[] BURN, double[] HEAT, double[] OVER, double[] STRONG, double[] UP,
double[] ICED, double[] COLD, double[] UNDER, double[] WEAK, double[] DOWN,
)
{
}

public void CalVAR9A(int pos, double highest, double lowest, double close, int stochLen, int len1, int len2, int var9Len,
double[] MRSH, double[] KA, double[] DA, double[] VAR9A, double[] VAR9,
double[] KdBURN, double[] KdHEAT, double[] KdOVER, double[] KdSTRONG, double[] KdUP,
double[] KdICED, double[] KdCOLD, double[] KdUNDER, double[] KdWEAK, double[] KdDOWN,
double[] BURN, double[] HEAT, double[] OVER, double[] STRONG, double[] UP,
double[] ICED, double[] COLD, double[] UNDER, double[] WEAK, double[] DOWN,
)
{
}

public void CalVAR9A(int pos, double highest, double lowest, double close, int stochLen, int len1, int len2, int var9Len,
double[] MRSH, double[] KA, double[] DA, double[] VAR9A, double[] VAR9,
double[] BURN, double[] HEAT, double[] OVER, double[] STRONG, double[] UP,
double[] ICED, double[] COLD, double[] UNDER, double[] WEAK, double[] DOWN,
bool showKD
)
{
}

public void CheckMA(int pos)
{
}

public void CheckHLM(int pos)
{
}

public void CalHLM(int pos, double highest, double lowest, double[] close, int HLMLen, double[] MPMHH, double[] MPMLL, int[] MPMVAR3, double[] MPMBUY, double[] MPMSELL, double[] maCross)
{
}

public void SlowKD()
{

}

public void HMA(int pos, double[] hma, double[] price, double[] swing, double[] bema, double[] sema, double[] power, double[] sum, double[] filter, int len, int nstdLen, double drawPos)
{
}

public void AMA(int pos, double[] ama, double[] price, double[] swing, double[] noise, double[] dma, double[] power, double[] sum, double[] filter, int len, int nstdLen, double drawPos)
{
}

public void EMA(int pos, double[] ema, double price, int len)
{
}

public void MovingAverage(int pos, double[] ma, double[] price, int len)
{
}

public void SetUpDownArray(int pos, double[] original, double[] up, double[] down)
{
}

public bool Cross(int barPos, double[] val1, double[] val2)
{
return false;
}

public void CheckDailyHighLow(int pos)
{
}

#endregion

#region "Class Output Function"
public void CalBarIndicator()
{
// Get TodayHigh and TodayLow and LastClose
CheckDailyHighLow(barPos);

MovingAverage(barPos, ma2, close, 2);
MovingAverage(barPos, ma5, close, 5);
MovingAverage(barPos, ma7, close, 7);
MovingAverage(barPos, ma10, close, 10);
MovingAverage(barPos, ma18, close, 18);
MovingAverage(barPos, ma20, close, 20);
MovingAverage(barPos, ma30, close, 30);
MovingAverage(barPos, ma60, close, 60);
MovingAverage(barPos, ma90, close, 90);
MovingAverage(barPos, ma120, close, 120);
MovingAverage(barPos, ma180, close, 180);
MovingAverage(barPos, ma300, close, 300);
MovingAverage(barPos, ma540, close, 540);
MovingAverage(barPos, ma900, close, 900);
MovingAverage(barPos, ma1500, close, 1500);
MovingAverage(barPos, ma2700, close, 2700);
MovingAverage(barPos, ma8100, close, 8100);

SetUpDownArray(barPos, ma60, upma60, downma60);
SetUpDownArray(barPos, ma90, upma90, downma90);
SetUpDownArray(barPos, ma180, upma180, downma180);
SetUpDownArray(barPos, ma300, upma300, downma300);

EMA(barPos, ema5, close[barPos], 5);
EMA(barPos, ema7, close[barPos], 7);
EMA(barPos, ema10, close[barPos], 10);
EMA(barPos, ema20, close[barPos], 20);
EMA(barPos, ema30, close[barPos], 30);
EMA(barPos, ema60, close[barPos], 50);
EMA(barPos, ema90, close[barPos], 90);
EMA(barPos, ema150, close[barPos], 150);
EMA(barPos, ema180, close[barPos], 180);
EMA(barPos, ema300, close[barPos], 300);
EMA(barPos, ema900, close[barPos], 900);

SlowKD();

//AMA(barPos, ama10, close, swing10, noise10, dma10, powerama10, sumama10, val0, 10, 13, MPM1BUY[barPos]);
//AMA(barPos, ama20, close, ref swing20[barPos], noise20, dma20, powerama20, sumama20, ref val0[barPos], 20);
//AMA(barPos, ama30, close, ref swing30[barPos], noise30, dma30, powerama30, sumama30, ref val0[barPos], 30);
//AMA(barPos, ama60, close, ref swing50[barPos], noise50, dma60, powerama60, sumama60, ref val0[barPos], 50);
//AMA(barPos, ama90, close, ref swing90[barPos], noise90, dma90, powerama90, sumama90, ref val0[barPos], 90);
/*
AMA(barPos, ama180, close, swing180, noise180, dma180, powerama180, sumama180, val0, 180, 234, (MPM1BUY[barPos]==Chart.NoValue ? MPM1HH[barPos] : MPM1LL[barPos]));
AMA(barPos, ama300, close, swing300, noise300, dma300, powerama300, sumama300, val0, 300, 390, (MPM2BUY[barPos]==Chart.NoValue ? MPM2HH[barPos] : MPM2LL[barPos]));
AMA(barPos, ama900, close, swing900, noise900, dma900, powerama900, sumama900, val0, 900, 1170, ma300[barPos]);

HMA(barPos, hma180, close, hswing180, ema180, ema90, powerhma180, sumhma180, val0 , 13, 234, (MPM1BUY[barPos]==Chart.NoValue ? MPM1HH[barPos] : MPM1LL[barPos]));
HMA(barPos, hma300, close, hswing300, ema300, ema300, powerhma300, sumhma300, val0, 17, 390, (MPM2BUY[barPos]==Chart.NoValue ? MPM2HH[barPos] : MPM2LL[barPos]));
HMA(barPos, hma900, close, hswing900, ema900, ema900, powerhma900, sumhma900, val0, 30, 1170, ma300[barPos]);
// <summary>
*/
/// </summary>
AMA(barPos, ama180, close, swing180, noise180, dma180, powerama180, sumama180, val0, 180, 234, ma300[barPos] + 10);
AMA(barPos, ama300, close, swing300, noise300, dma300, powerama300, sumama300, val0, 300, 390, ma300[barPos] + 15);
AMA(barPos, ama900, close, swing900, noise900, dma900, powerama900, sumama900, val0, 900, 1170, ma300[barPos] + 20);

HMA(barPos, hma180, close, hswing180, ema180, ema180, powerhma180, sumhma180, val0, 180, 234, ma300[barPos] + 10);
HMA(barPos, hma300, close, hswing300, ema300, ema300, powerhma300, sumhma300, val0, 300, 390, ma300[barPos] + 15);
HMA(barPos, hma900, close, hswing900, ema900, ema900, powerhma900, sumhma900, val0, 900, 1170, ma300[barPos] + 20);

CalHLM(barPos, highest9[barPos], lowest9[barPos], close, 50, MPM1HH, MPM1LL, MPM1VAR3, MPM1BUY, MPM1SELL, ma2);
CalHLM(barPos, highest27[barPos], lowest27[barPos], close, 150, MPM2HH, MPM2LL, MPM2VAR3, MPM2BUY, MPM2SELL, ma5);
CalHLM(barPos, highest81[barPos], lowest81[barPos], close, 450, MPM3HH, MPM3LL, MPM3VAR3, MPM3BUY, MPM3SELL, ma18);

CheckHLM(barPos);

CheckMA(barPos);
}
#endregion

#region "Bar Strategy"
public void CalBarStrategy()
{
}

#endregion

}

}```
 T1-20190515.zip218.22 Kb
 T1-20190517.zip231.14 Kb

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-20-2019 20:28
Attachments:
Hi Peter,

I modify the form1.cs like your example

the same problem occurred.

Thanks!
 WindowsApplication1.zip6.08 Kb

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-21-2019 20:53
Hi poohwen,

In my testing, with the given data, I found that the error is caused by using the incorrect coordinates and data array for the trend layer.

(a) All the data arrays that passed to the FinanceChart must be consistent and of the same size. In your code, the data that is passed to the FinanceChart is viewPortTimeStamps, etc.. In my test case with the data files, the array length is 844. However, you use the curBar.trendLineData array, which is has 7000 elements. This is inconsistent and causes the problem.

(b) I found that the full length of your data (curBar.barPos) is 3370. However, you put the trend line at 3800 to 4000, which is beyond your data range. So even if you fix (a), you cannot see the trend line. The trend should use coordinates that is within your data range.

For my "drag to draw trend line" code, it works once the code uses the correct data array.

if (chkTrendLine.Checked)
{
curBar.trendLineData[3000] = 10500;
curBar.trendLineData[3200] = 10600;
double[] viewPortTrendLineData = (double[])Chart.arraySlice(curBar.trendLineData, startIndex, noOfPoints);

}
else
{
curBar.trendLineData[3000] = Chart.NoValue;
curBar.trendLineData[3200] = Chart.NoValue;

}

// put two points in the trendLine array
if ((y1 != Chart.NoValue) && (y2 != Chart.NoValue))
{
double[] viewPortTrendLineData = (double[])Chart.arraySlice(curBar.trendLineData, startIndex, noOfPoints);
viewPortTrendLineData[x1] = y1;
viewPortTrendLineData[x2] = y2;

}

Hope this can help.

Regards
Peter Kwan

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-21-2019 23:55
Attachments:
Hi Peter,

Thank you for reminding me to use Chart.arraySlice.

m_mainChart.addTrendLayer((double[])Chart.arraySlice(curBar.trendLineData, startIndex, noOfPoints), 0x008000, "Trend Line");

It work now.

But I found another problem.

The image shift slightly if I addTrendLine.

The highest price position without trendline(in T2.png) is lower if I addTrendLine(iin attached T1.png).

How to fix this problem?

Thanks

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-22-2019 00:18
Hi, Peter,

I have one more question.

How to check if I click in the trendline?(not in the postion where I click the start or end position of the trendline)

Then I can move or delete the trendline if I have many trendline in the graph.

Thanks.

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-22-2019 17:33
Hi poohwen,

The maxmium value of your original data is around 10565. However, the trend line you added includes a value at 10600. So if the trend line is added, ChartDirector must extend the y-axis to fit the trend line.

In brief, if you do not want the axis to be changed, please use data values that are within the data range if your original data. If the code uses values outside the data range, ChartDirector will adjust the axis scale to include those values.

Hope this can help.

Regards
Peter Kwan

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-22-2019 21:16
Hi poohwen,

You can create an image map for the trend line(s). This allows you to detect if the mouse is on top of the trend line by using hot spot events.

For example:

... create chart with trend line as usual ....

// Output the chart
viewer.Chart = m;

// Create the image map only after displaying the chart
if (null != myTrendLayer)
{
StringBuilder imageMap = new StringBuilder();

// xxx is an identifier to help you determine which trend line the mouse is on top
imageMap.Append(myTrendLayer.getHTMLImageMap("clickable", "trendId=xxx", "", m_mainChart.getAbsOffsetX(), m_mainChart.getAbsOffsetY()));

.... if you have multiple trend lines, please append their image map to together

viewer.ImageMap = imageMap.ToString();
}

The trend line can then trigger hot spot events. For example, you can handle the MouseEnterHotSpot event to detect if the mouse enters into the region of the trend line:

private void winChartViewer1_MouseEnterHotSpot(object sender, WinHotSpotEventArgs e)
{
if (e.AttrValues.ContainsKey("trendId"))
{
// The id of the trend line
string id = e["trendId"].ToString();

......
}
}

Similarly, you can use the MouseLeaveHotSpot to determine if the mouse leaves the trend line. There are also other hot spot mouse events, like MouseDownHotSpot, etc..

Regards
Peter Kwan

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-22-2019 23:26
Hi Peter,

Thank you for your kindly help!!

All Works.

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-26-2019 08:17
Hi Peter,

It's all my fault.

I should not use hardcode X, Y value.

I found that I can show the correct value in TrackFinance is that it get the value of xIndex in the layer of the chart(drawingArea) instead of the correct xIndex of my data array.

Then in my example I can't get the correct xIndex to show the correct TrendLine.

The main reason is that I set the viewer to part of the chart.
viewer.setFullRange("x", curBar.barTime[0], curBar.barTime[curBar.barPos]);

// Initialize the view port to show the latest 20% of the time range
viewer.ViewPortWidth = 0.25;
viewer.ViewPortLeft = 1 - viewer.ViewPortWidth;

// Set the maximum zoom to 10 points
viewer.ZoomInWidthLimit = 25.0 / curBar.barPos;

Can you help me to slove this problem?

Thanks.

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-26-2019 08:25
Hi Peter,

In the mouseClick or mouseMovePlotArea,
if (e.Button == MouseButtons.Left)
{
MultiChart m = winChartViewer1.Chart as MultiChart;
if ((null == m) || (m.getChartCount() == 0))
return;

XYChart c = (XYChart)m.getChart(0);
//int xValue = (int)c.getNearestXValue(e.X);
int xValue = (int)c.getNearestXValue(viewer.PlotAreaMouseX);

No matter I use
c.getNearestXValue(e.X); or c.getNearestXValue(viewer.PlotAreaMouseX);

The xValue I get is not the correct one I need.
It return the xValue of the layer
like in the trackFinace
for (int j = 0; j < c.getLayerCount(); ++j) {
Layer layer = c.getLayerByZ(j);
int xIndex = layer.getXIndexOf(xValue);
highValue = layer.getDataSet(0).getValue(xIndex);
****   this xIndex will show the correct high value in the legend,  but I need a absolute xIndex value of my dataset not the layer subdataset

Thank you for your kindly help!

Best Regards,

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-27-2019 13:23
Hi poohwen,

From your previous code, the data you passed to FinanceChart is the "viewPortTimeStamps" and other viewPort* arrays. Your code create these arrays from your other "full data" arrays using arraySlice, which means your viewPort* arrays are offsetted from your other arrays by the startIndex.

When you pass the data to FinanceChart, you can ask it to remove the lead data using the "extraPoints" variable. In your earlier code, the "extraPoints" is set to 0. However, if you do not set the "extraPoints" to 0, you would need to add this back to the index too.

Have you added back the "startIndex" and the "extraPoints" to obtain the index to your original arrays?

Regards
Peter Kwan

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-27-2019 14:31
Hi Peter,

You got it.

I did not add it even I copy slice of my array.

Thank you.

Re: How to add extended trendline in finacial chart?
Posted by poohwen on May-28-2019 00:11
Hi Peter,

If I want to draw two diamonds in the the trendline(where I click the mouse in the chart to set the trendline), what should I do?

I can get the x, y now(thank for your help).

Can you give me an example?

Thanks.

Re: How to add extended trendline in finacial chart?
Posted by Peter Kwan on May-28-2019 13:29
Hi poohwen,

You can add a scatter layer using the same data arrays as the trend layer:

m_mainChart.addScatterLayer(null, viewPortTrendLineData, "", Chart.DiamondShape, 11, 0x0000ff);

Hope this can help.

Regards
Peter Kwan