hello, I would like help coding an automatic script that buys in 15 min graph when parabolic sar is green and sells when parabolic sar is red and the daily graph macd cross over zero and go short when parabolic sar 15 min is red and sell when it is green and daily chart macd is below 0
Try this:
defParam cumulateOrders = false
defParam preLoadBars = 10000
defParam flatAfter = 220000
positionSize = 1
//------------------------------------------------------------
timeframe(1 day, updateOnClose)
myMacd = average[12,1] - average[26,1]
c1L = myMacd crosses over 0
c1S = myMacd crosses under 0
//--------------------------------------------------------------
timeframe(15 minutes, updateOnClose)
mySAR = sar[0.02,0.02,0.2]
greenSar = close > MySAR
redSar = close < MySAR
changeColor = (greenSar and redSar[1]) or (greenSar[1] and redSar)
c2L = greenSar
c2S = redSar
if not onMarket and c1L and c2L then
buy positionSize contracts at market
endif
if longOnMarket and changeColor and redSar then
sell positionSize contracts at market
endif
if not onMarket and c1S and c2S then
sellShort positionSize contracts at market
endif
if shortOnMarket and changeColor and greenSar then
exitShort positionSize contracts at market
endif
Thank you so much for fast Replay . I shall try it 😁