Condiciones para hacer una entrada

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #78744 quote
    tradingthelifetradingthelife
    Participant
    Senior

    Hola amigos, tengo una duda a ver si me podéis ayudar.

    Me gustaría condicionar las entradas a que se cumpla una condición en barras anteriores. La idea es que si por ejemplo, el mínimo del RSI anterior estuvo por debajo de 20, sólo abrir posiciones largas, y si el máximo anterior fue mayor que 80 abrir sólo posiciones cortas, como un filtro intentando ir a favor del movimiento completo de la onda.

    Por el momento lo tengo resuelto de esta manera (ejemplos).

    Posiciones largas:

    c7 = ((lowest[RSINUMBARS](RSI)) < 20) and ((highest[RSINUMBARS](RSI)) < 80)

    Posiciones cortas:

    c17 = ((highest[RSINUMBARS](RSI)) > 80) and ((lowest[RSINUMBARS](RSI)) > 20)

    De esta manera le indico que en un número específico de barras se produzcan ciertos máximos/mínimos a favor de la onda.

    De momento los resultados en el backtest no son malos del todo, pero me gustaría saber si hay alguna manera de evitar limitarlo a un número específico de barras, sino que la última condición producida sea un mínimo o un máximo para hacer un tipo de entrada u otra…

    En pseudocódigo sería algo así:

    Largos:

    if last lowest <20 and highest not >80 then…

    Cortos

    if last highest >80 and lowest not <20 then…

    No sé si me explico…podéis ayudarme?

    Saludos y gracias!

    #78793 quote
    NicolasNicolas
    Keymaster
    Legend

    Puede “marcar” una nueva variable cuando se produce una de las condiciones, de modo que el valor no cambiará:

    //Long positions:
    c7 = ((lowest[RSINUMBARS](RSI)) < 20) and ((highest[RSINUMBARS](RSI)) < 80)
    //Short positions:
    c17 = ((highest[RSINUMBARS](RSI)) > 80) and ((lowest[RSINUMBARS](RSI)) > 20)
    
    if c7 then 
     last = 1 
    elsif c17 then 
     last = -1
    endif 
    
    if last>0 then 
     //BUY 
    endif
    
    if last<0 then 
     //SELLSHORT 
    endif
    
    #78815 quote
    tradingthelifetradingthelife
    Participant
    Senior

    Muchas gracias Nicolas, aunque desafortunadamente no es lo que buscaba.

    La variable RSINUMBARS en

    c7 = ((lowest[RSINUMBARS](RSI)) < 20) and ((highest[RSINUMBARS](RSI)) < 80)

    debería ser eliminada, no existir. El sistema debe buscar en todas las barras anteriores hasta la primera que cumple esa condición y a partir de ahí empezar a cumplir otras condiciones . Debe ser algo relacionado con WHILE, ONCE, o algo similar, pero no lo consigo resolver. Podrías orientarme?

    Saludos y gracias por su trabajo en PRC.

    #78876 quote
    tradingthelifetradingthelife
    Participant
    Senior

    Alguna pista para saber por dónde debo seguir investigando?

    Gracias de nuevo.

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Condiciones para hacer una entrada


ProOrder: Trading Automático y Backtesting

New Reply
Author
author-avatar
tradingthelife @komiya Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by tradingthelifetradingthelife
8 years, 1 month ago.

Topic Details
Forum: ProOrder: Trading Automático y Backtesting
Language: Spanish
Started: 08/22/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...