hi,
how to code if i want to go long when there’s a bull candle just before macd line crosses over macd signal line?
thank you
You can only know that a bar is the one before a crossover occurs AFTER the next one has crossed over.
Which is late according to your conditions, so there’s no way to code them.
But by using a simple comparison between previous value to the current one, it is actually possible to test the crossing of these 2:
timeframe(1 hour) //timeframe of your strategy
bull = close[1]>open[1] //previous candle was green
imacd = macd[12,26,9]
signal = average[9,1](imacd)
imacdp = macd[12,26,9][1]
signal = average[9,1](imacd)[1]
timeframe(default) //timeframe inferior in order to test intrabar the crossing
test = bull and imacd<signal and imacdp>signalp
no tested, but that’s the idea ^^
sorry i mean bull candle after macd cross over.