I have a List variable which includes all the executions (read from the external application) and I am trying to add Up and Down arrows to the execution points on the chart but I cannot get it to work correctly. Arrows are not shown everytime and they disappear and comes back when I scroll the chart.
I have checked by printing this "Kaupat" List object to the output window so it really includes all the execution data and everything is in order.
Here are the key points of the script:
// This is the structure for the execution information
public struct Kauppa
{
public string symbol;
public string dir;
public int position;
public double price;
public DateTime dateTime;
public Kauppa(string sy, string di, int po, double pr, DateTime dt)
{
symbol = sy;
dir = di;
position = po;
price = pr;
dateTime = dt;
}
}
// This list holds the executions. This list is initialized from the disk
// file elsewhere in the script
private List<Kauppa> Kaupat;
// Here I try to update the chart. Is this the correct place for this purpose?
protected override void OnBarUpdate()
{
foreach(Kauppa k in Kaupat)
{
if(k.dateTime <= Time[0] && k.dateTime > Time[1])
if(k.dir.CompareTo("BOT") == 0)
DrawArrowUp("", true, 0, Low[0]-TickSize*2, Color.Green);
else
DrawArrowDown("", true, 0, High[0]+TickSize*2, Color.Red);
}
}
SG
Comment