If my program exit a trade and I want it too wait for 1 or two candles (5min) before it take another position, how do I write that code?
You have to:
- set a flag to enable or disable trading, default=enable
- set a counter, default=0
- disable trading when you are OnMarket
- start counting as soon as a trade exited (you are not OnMarket, but were OnMarket the previous bar)
- reenable trading as the counter reaches the limit you require
Once TradeON = 1 //1=enabled 0=disabled
Once Counter = 0
If OnMarket then
TradeON = 0
Counter = 0
Endif
If Counter >= 1 then
Counter = Counter + 1
If Counter >= 3 then //reenable trading after 3 bars
TradeON = 1
Counter = 0
Endif
Endif
If not OnMarket and OnMarket[1] then
Counter = 1
TradeON = 0
Endif
Add TRADEON to your conditions.