Acumulacion pasadas X barras

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #244102 quote
    Dari
    Participant
    New

    Hola a todos,

     

    Quiero acumular si se cumplen las mismas condiciones que hicieron entrar la primera entrada –esa parte la tengo ok poniendo el TRUE en acumulación-

     

    Pero la idea es :

    -Poder limitar esa entrada a que hayan transcurrido X barras desde q entró la primera orden

    – Poder limitar a que solo haga 1 acumulacion (max 2 contratos= inicial+acumulacion)

     

    A ver si alguien me puede guiar, gracias

    #244119 quote
    robertogozzi
    Moderator
    Master

    Aquí está el código:

    DEFPARAM CumulateOrders = true
    ONCE X = 10
    Ema20  = average[20,1](close)
    c1     = close > Ema20
    c2     = highest[3](high) < high[3]
    c3     = (high = highest[3](high))
    IF Not OnMarket THEN
       Bars     = 1
       BarEntry = 0
    ELSE
       Bars     = BarIndex - EntryBar
    ENDIF
    Cond  = c1 AND c2 AND c3 AND abs(CountOfPosition) < 2 AND (Bars <= X)
    IF Cond THEN
       BUY 1 CONTRACT AT MARKET
       CRV = abs(close - Ema20) * 2
       SET TARGET PROFIT CRV
       SET STOP   PRICE Ema20
       EntryBar = BarIndex
    ENDIF
    Iván González thanked this post
    #244148 quote
    Dari
    Participant
    New

    Gracias Nicolas, he probado de insertarlo pero no me ejecuta bien, podrías intentar añadirlo a éste código ?

     

    // Definición de los parámetros del código
    DEFPARAM CumulateOrders = false // Acumulación de posiciones desactivada
    
    // Impide al sistema lanzar nuevas órdenes para entrar al mercado o aumentar el tamaño de la posición después de una hora precisa
    noEntryAfterTime = 213000
    timeEnterAfter = time < noEntryAfterTime
    
    // Impide al sistema operar en días precisos de la semana
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Condiciones para entrada de posiciones largas
    indicator1, ignored, ignored = CALL "INDICADORINTRA"
    c1 = (indicator1[1] CROSSES OVER 25)
    
    IF c1 AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Condiciones de salida de posiciones largas
    indicator2, ignored, ignored = CALL "INDICADORINTRA"
    c2 = (indicator2 CROSSES UNDER 68)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Stops y targets
    SET STOP %LOSS 0.5
    
    #244167 quote
    robertogozzi
    Moderator
    Master

    Es una estrategia, hay que usarla tal como es, sustituyendo tus condiciones por las mías.
    Como publicaste el código, lo codificaré para ti directamente, sin poder probarlo ya que no tengo tu indicador.
    Allí está:

    DEFPARAM CumulateOrders = true // Acumulación de posiciones activada
    ONCE X = 10
    IF Not OnMarket THEN
    Bars     = 1
    BarEntry = 0
    ELSE
    Bars     = BarIndex - EntryBar
    ENDIF
    // Impide al sistema lanzar nuevas órdenes para entrar al mercado o aumentar el tamaño de la posición después de una hora precisa
    noEntryAfterTime = 213000
    timeEnterAfter = time < noEntryAfterTime
    // Impide al sistema operar en días precisos de la semana
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    // Condiciones para entrada de posiciones largas
    indicator1, ignored, ignored = CALL "INDICADORINTRA"
    c1 = (indicator1[1] CROSSES OVER 25)
    IF c1 AND timeEnterAfter AND not daysForbiddenEntry AND abs(CountOfPosition) < 2 AND (Bars <= X) THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    // Condiciones de salida de posiciones largas
    indicator2, ignored, ignored = CALL "INDICADORINTRA"
    c2 = (indicator2 CROSSES UNDER 68)
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    // Stops y targets
    SET STOP %LOSS 0.5
    #244169 quote
    Dari
    Participant
    New

    Gracias, me da el mismo error, dice hay q definir la variable “entrybar”

    #244254 quote
    robertogozzi
    Moderator
    Master

    Lo siento, cometí un error tipográfico.
    Reemplace la línea 5 con esto:

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

Acumulacion pasadas X barras


ProOrder: Trading Automático y Backtesting

New Reply
Author
author-avatar
Dari @dari Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by robertogozzi
1 year ago.

Topic Details
Forum: ProOrder: Trading Automático y Backtesting
Language: Spanish
Started: 02/20/2025
Status: Active
Attachments: No files
Logo Logo
Loading...