Good afternoon,
Please I need help with the following code. I seek to enter the S & P500 bought when the market meets the following conditions:
– Bullish engulfing candle on Timeframe 5 minutes
– Daily timeframe: Price above the exponential average of 11 periods and closing of the previous day greater than the opening of the previous day.
// Definición de los parámetros del código
DEFPARAM CumulateOrders = False // Acumulación de posiciones desactivada
TradeON = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5
noEntryBeforeTime = 090500
timeEnterBefore = time > noEntryBeforeTime
noEntryAfterTime = 215500
timeEnterAfter = time < noEntryAfterTime
timeframe(daily)
c10 = (close > open)
indicator11 = ExponentialAverage[12](close)
c11 = (close >= indicator11)
//5 minute
timeframe(default)
c13 = Close[1] < Open[1] AND Open < Close[1] AND Close > Open[1]
IF c10 and c11 and c13 and timeEnterBefore and timeEnterAfter and TradeOn and Not OnMarket THEN
BUY 1 SHARE AT HIGH STOP
SET STOP pLOSS 20
ENDIF
//trailing stop function
trailingstart = 20 //trailing will start @trailinstart points profit
trailingstep = 5 //trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
I understand that the c10 condition should enter only if the close of the previous day is greater than the opening of the previous day but not that way. See images 04/23/21, on the 22nd the candle is red and it goes in the same way.
timeframe(daily)
c10 = (close > open)
I would appreciate if you tell me exactly what this line means and how I have to write to get what I’m looking for.
Thank you ,
regards
Reemplace la línea 15 con:
c10 = (close[1] > open[1])
está utilizando precios de la vela actual.