sometimes its just a change of price but sometimes its also change the direction from buy to sell for example.
I send a cancel order before sending a new order. But it seams the cancel confirmation takes some time and so the submission of a new order is premature.
I understand that the managed method does not allow the change of direction if we have an open order.
So I am thinking I need some SLEEP / delay put in between the cancel and the new order Enter() command. while I process the bar.
I am looking to have a delay of some milliseconds. I am working with hourly bars so I think its shouldn't affect the process.
also I am running the same strategy simultaneously on several stocks , so I am not sure that the definition of the system timer is the same for all strategies ?!
I was looking at the
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer {Interval = 100};
timer.Tick += delegate
{
timer.Stop(); // make sure to stop the timer to only fire ones (if desired)
timer.Dispose(); // make sure to dispose of the timer
};
timer.Start(); // start the timer immediately following the "before" logic
I am not sure that I am doing it right.
can you please assist how should I do that ? some direction how to define this timer and use it inside the OnBarUpdate ()

Comment