This code snippet demonstrates how to implement a simple trading strategy using Heikin Ashi candlesticks calculated from a higher timeframe (1 hour) and executed on a lower timeframe (1 minute) using the ProBuilder programming language.
TIMEFRAME(1 hour,updateonclose) // Heikin-Ashii candle setup
if barindex > 0 then
xClose = (open+close+low+high)/4
xOpen = (xOpen[1]+xClose[1])/2
//haHigh = Max(xOpen, xClose)
//haLow = Min(xOpen, xClose)
//xHigh = Max(High,haHigh)
//xLow = Min(Low,haLow)
else
xClose = (open+close+low+high)/4
xOpen = (Open[1]+Close[1])/2
//haHigh = Max(xOpen, xClose)
//haLow = Min(xOpen, xClose)
//xHigh = Max(High,haHigh)
//xLow = Min(Low,haLow)
endif
Cond1 = xOpen > xClose //BEARish HA candlestick
TIMEFRAME(1 minute,updateonclose)
Cond2 = close < average[5,0](close) //current price < SMA5
TIMEFRAME(default)
IF Cond1 AND Cond2 AND Not OnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
SET TARGET pPROFIT 50
SET STOP pLOSS 20
Explanation of the Code:
This snippet is a practical example of how to implement a multi-timeframe strategy in ProBuilder, utilizing different timeframes for signal confirmation and trade execution.
Check out this related content for more information:
https://www.prorealcode.com/topic/strategy-in-two-different-timeframes/#post-91072
Visit Link