Hi,
I am trying to program a strategy that if there is a long entry signal,such as RSI oversold, then take the trade, if the next candle is green( Close[bar]>Open[bar]) and there is another long entry signal, ignore the signal and don't take another trade, until there is at least one red candle between the two long entry signals, and for short entry signals, it's the opposite, i.e, don't act on the second short signal until there is at least one green candle between the two short signals. The following is an example:
Candle 1: Green, Signal:Long( Long signal #1), Action: Take the long trade ( Long trade #1)
Candle 2: Green, Signal:None, Action: None
Candle 3: Green, Signal:Long( Long signal #2), Action: None ( Do NOT take the long trade)
Candle 4: Red, Signal:None, Action: None
Candle 5: Green, Signal:Long( Long signal #3), Action: Take the long trade ( Long trade #2)
Candle 6: Red, Signal:Short( Short signal #1), Action: Take the short trade ( Short trade #1)
Candle 7: Red, Signal:Short( Short signal #2), Action: None ( Do NOT take the short trade)
Candle 8: Green, Signal:None, Action: None
Candle 9: Green, Signal:None, Action: None
Candle 10: Red, Signal:Short( Short signal #3), Action: Take the short trade ( Short trade #2)
Here is my test code and it's not working, can anyone help me to solve this problem? Your help will be greatly appreciated.
Best regards
Greg
CODE:
Please log in to see this code.