I have a strategy that works as follows (without all the necessary parenthesis stuff):
public class Strategy123
{
int StoppedOut = 0;
protected override void OnBarUpdate()
{
if StoppedOut == 1
{Say "You are stopped out" or do nothing}
else if StoppedOut == 0
--> set up a stop loss STPLMT order "SL123"
}
protected override void OnExecution(Iexecution execution)
{
if SL123.Token == execution.Order.Token
{StoppedOut = 1; DrawText(I am stopped out);}
}
}
What happens is: The Stop Loss order SL123 gets set up correctly within the OnBarUpdate() method and eventually triggers and executes correctly. The system then correctly recognizes via OnExecution that the SL123 order has been executed and amends the value of the StoppedOut variable to 1. However, once the next bar updates and OnBarUpdate() should now see the StoppedOut variable as 1, it simply does not do so.
Instead, for example if I tell it to DrawText using the now-should-be-1-StoppedOut variable, it simply does not draw any text; it seems to have "lost" the variable.
Any info about how I can tell the system to "memorize" the change in the StoppedOut variable, so that the next OnBarUpdate() can make use of it?
Thank you all for taking the time to read.
Best regards,
noincomenojobnoassets
Comment