TIMEFRAME ( DAYLY) — CLOSE > OPEN

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #173914 quote
    Nicolas Castro
    Participant
    Junior

    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

    Buy-04-23-21.jpg Buy-04-23-21.jpg 04-22-2021-Close-not-greater-open.jpg 04-22-2021-Close-not-greater-open.jpg
    #173927 quote
    robertogozzi
    Moderator
    Master

    Reemplace la línea 15 con:

    c10 = (close[1] > open[1])

    está utilizando precios de la vela actual.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

TIMEFRAME ( DAYLY) — CLOSE > OPEN


Trading General: Análisis de Mercado y Manual

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
4 years, 8 months ago.

Topic Details
Forum: Trading General: Análisis de Mercado y Manual
Language: Spanish
Started: 07/20/2021
Status: Active
Attachments: 2 files
Logo Logo
Loading...