In the variable section, I added to the Wizard code:
private int tradeOnceOnly = 1;
This is the code for my OnBarUpdate with the tradeOnceOnly flag added:
if (EMA(10)[0] > EMA(20)[0]
&& GetCurrentAsk() <= EMA(10)[0]
&& tradeOnceOnly == 1)
{
EnterLong(DefaultQuantity, "");
tradeOnceOnly = 2;
}
I thought that after the trade, it would stop trading because tradeOnceOnly went to 2. I could then turn the strategy off and when I was ready to trade again turn it on, but what's happening is that now that I've added the flag no trade is being taken. I ran a print statement on the flag and it starts for a few ticks at 1 and then goes to 2 although no trade has been taken.
Please bear in mind that I'm not looking to have only 1 active trade but to stop trading after my first trade until I turn the strategy off and then on again.
If anyone could help me, I would be most appreciaite.

Comment