Code error that buys me every minute

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #205194 quote
    frdriancre
    Participant
    New

    Hi, I already have my code finished the only thing that happens is that what my code does is to buy and the next minute sell and the minute I sell it buys again and so on but what I want is that it buys me every time my open trade goes down 1.5%, thanks

    Sistema.itf
    #205202 quote
    robertogozzi
    Moderator
    Master

    LONGONMARKET no se puede comparar con un precio, ya que es una constante numérica lógica que solo puede tener el valor 0 o 1 (falso o verdadero).
    Si desea consultar el último precio de compra o venta, debe utilizar TradePrice, también escrito TradePrice(1), o CLOSE para el precio actual.

    Estas líneas son inútiles y son lógicamente defectuosas.
    1. no son necesarios porque nunca realiza operaciones CORTAS
    2. son lógicamente incorrectas porque se utiliza IF SHORTONMARKET e inmediatamente después IF LONGONMARKET; uno excluye al otro:

    ELSIF ShortOnMarket THEN
       IF LongOnMarket >= CompraLarga2 * 0.5 THEN       //1.5% drop (100 - 0.015)
          SELLSHORT AT Market
       ENDIF
    ENDIF

    Ahi esta:

    DEFPARAM CumulateOrders = True
    
    //Detectar nuevas entradas
    promediar = (LOngOnMarket AND ShortOnMarket[1]) OR (LOngOnMarket[1] AND ShortOnMarket) OR (OnMarket AND Not OnMarket[1])
    
    //Ver cuantas posiciones hay abiertas
    Posiciones = abs(CountOfPosition)
    
    compra = CompraLarga1 AND CompraLarga2
    
    //Temporalidad de 5min
    TIMEFRAME(5 Minute)
    CompraLarga1 = RSI[14]> 30 and Stochastic[14,3] > 20
    
    //Temporalidad de 1min
    TIMEFRAME(1 Minute )
    ONCE PreciodeReferencia = 0
    
    CompraLarga2 = RSI[14] > 30 and Stochastic[14,3] > 20
    VentaLarga1  = Stochastic[14,3](close) > 40
    
    //Borrar variables
    IF Not OnMarket THEN
    EntryPrice = 1
    PreciodeReferencia = 0
    ENDIF
    
    //Promedia cuando baje un 1,5%
    IF LongOnMarket THEN
    IF close <= (PreciodeReferencia * 0.985) THEN    //1.5% drop (100 - 0.015)
    BUY 2 SHARES AT MARKET
    PreciodeReferencia = close
    ENDIF
    ELSIF ShortOnMarket THEN
    IF LongOnMarket >= CompraLarga2 * 0.5 THEN       //1.5% drop (100 - 0.015)
    SELLSHORT AT Market
    ENDIF
    ENDIF
    
    // Condiciones para entrada de posiciones largas
    IF NOT LongOnMarket AND CompraLarga2 THEN
    BUY 2 SHARES AT MARKET
    PreciodeReferencia = close
    ENDIF
    
    // Condiciones de salida de posiciones largas
    If LongOnMarket AND VentaLarga1 THEN
    SELL AT MARKET
    ENDIF
    
    // Stops y targets: introduzca aquí sus stops de protección y targets de beneficios
    
    GraphOnPrice PreciodeReferencia coloured("Blue")
    SisKike.itf
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Code error that buys me every minute


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
frdriancre @frdriancre Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/02/2022
Status: Active
Attachments: 2 files
Logo Logo
Loading...