How can I have my pinescript strategy enter after two conditions are met? (But not necessarily at the same time)
Posted: Thu Sep 01, 2022 6:39 pm
for example:
When the MFI gives me a signal for an overbought stock, i wait for a bearish cross of the MACD lines. If this happens, we go short.
Similarly, it acts the same way in the opposite direction. An oversold MFI reading and a bullish cross of the MACD lines generates a long signal but we wait for the bullish cross AFTER the MFI reading, they don't have to happen at the same time.
I've coded out the whole strategy in pinescript but I'm stuck trying to figure out how to allow for the initial MFI signal to uphold long enough to find the cross of the MACD lines- so that I can enter when either the conditions are met at the same time or the MACD cross comes after the MFI signal.
I hope I've making sense
I can share my current code if needed
When the MFI gives me a signal for an overbought stock, i wait for a bearish cross of the MACD lines. If this happens, we go short.
Similarly, it acts the same way in the opposite direction. An oversold MFI reading and a bullish cross of the MACD lines generates a long signal but we wait for the bullish cross AFTER the MFI reading, they don't have to happen at the same time.
I've coded out the whole strategy in pinescript but I'm stuck trying to figure out how to allow for the initial MFI signal to uphold long enough to find the cross of the MACD lines- so that I can enter when either the conditions are met at the same time or the MACD cross comes after the MFI signal.
I hope I've making sense
I can share my current code if needed