I am having a great deal of trouble today with a seemingly simple piece of code. I have 1 indicator giving an entry condition. How can I keep this entry condition open/ running until something cancels it. In essence what I want to do is, the first condition triggers, and then some time passes until the second condition is met, and only then enter. What is currently happening is that if condition 1 and 2 occurs the same time, only then enter. I need to let is still enter when condition 1 has not been cancelled.
//OB/OS Identification
oversold = moneyFlowIndex[1] > os[1] and moneyFlowIndex < os
overbought = moneyFlowIndex[1] < ob[1] and moneyFlowIndex > ob
long = overbought and buydiv //The overbought triggered a few candles ago, and now the buydiv triggers but doesnt enter because the 2 are not triggering together.
short = oversold and selldiv
strategy.entry("long",strategy.long, when = long)
strategy.entry("short",strategy.short,when = short)