hi,
I trying to go long when the 4h chart has macd green histogram with other conditions on 15mins my positions are entering when the histogram is red as well on the 4h chart. Does anyone got any ideas?
thank you
timeframe(4h,updateonclose)
c3= macdredline - macdblueline > 0
timeframe(default)
IF (c1 or c2) and c3 and not shortonmarket and not endtime then
BUY 1 CONTRACT AT MARKET
ENDIF
sorry
“but on 15mins my positions are entering when the histogram is red as well on the 4h chart.”
You have not shown in your code how you define macdredline and macdblueline. You talk about the histogram so why are you referring to lines?
The instruction to return the histogram value is MACD.
MACD
The lines are MACDSIGNAL and MACDLINE:
MACDsignal
MACDLine
macdredline=MACDSignal[12,26,9](close)//macd signal line
macdblueline=MACDline[12,26,9](close)//macd line
timeframe(4h,updateonclose)
c3= macdredline - macdblueline > 0
timeframe(default)
IF (c1 or c2) and c3 and not shortonmarket and not endtime then
BUY 1 CONTRACT AT MARKET
ENDIF
You are declaring the MACDSIGNAL and MACDLINE values in the default time frame and not in the 4 hour timeframe.
timeframe(4h,updateonclose)
c3= MACD[12,26,9](close) > 0
timeframe(default)
IF (c1 or c2) and c3 and not shortonmarket and not endtime then
BUY 1 CONTRACT AT MARKET
ENDIF