non mi entra correttamente…

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #202346 quote
    Mauro M
    Participant
    New

    vorrei che entrasse long al minimo della candela precedente meno 30 punti e viceversa. sul daily. Grazie

    DEFPARAM CumulateOrders=false
    NTICK = 30
    
    c4=barindex-tradeindex=1
    //Long entry
    if Close < Open   then
       buy 1 shares at low - Ntick stop
    endif
    
    //stop loss massimo in punti dal prezzo ingresso
    if LongOnMarket and c4 then
       SELL AT MARKET
    endif
    
    //Short entry
    if Close > Open  then
       sellshort 1 shares at high - Ntick stop
    endif
    
    //stop loss massimo in punti dal prezzo ingresso
    If ShortOnMarket AND c4 THEN
       EXITSHORT AT MARKET
    endif
    set stop ploss 70
    set target pprofit 140
    #202384 quote
    robertogozzi
    Moderator
    Master

    Se vuoi allegare un file del codice fallo pure, ma, salvo che il codice ecceda 200-300 linee, è bene postarlo. Grazie 🙂

    Per fare riferimento alla candela precedente  devi usare [1] accanto a low e high, altrimenti viene presa in considerazione la barra corrente.

    Inoltre è meglio convertire i punti con PipSize, per essere certi che non vengano interpretati come prezzo. Sugli indici può funzionare ugualmente, ma su EurUsd, ad esempio, sommare 30 significa passare da 0,9600 a 30,9600 o a -29,0400.

    Gli ordini pendenti devono essere LIMIT, non stop, in quanto entri ad un prezzo migliore, non peggiore, rieptto a quello corrente. Però, nel caso tu voglia utilizzare [1] per riferirti alla barra precedente, devi usare un IF per mettere l’ordine LIMIT se il prezzo d’entrata è migliore, oppure STOP se è peggiore (se non usi [1] è inutile, in quanto HIGH è sicuramente più alto e LOW più basso di CLOSE):

    DEFPARAM CumulateOrders=false
    NTICK = 30*pipsize
    
    c4=barindex-tradeindex=1
    //Long entry
    if Close < Open   then
       Entrata = low[1] - Ntick
       if close > Entrata then
          buy 1 shares at Entrata limit
       elsif close < Entrata then
          buy 1 shares at Entrata stop
       endif
       //graphonprice Entrata coloured(0,0,255,255)
    endif
    
    //stop loss massimo in punti dal prezzo ingresso
    if LongOnMarket and c4 then
       SELL AT MARKET
    endif
    
    //Short entry
    if Close > Open  then
       Entrata = high[1] + Ntick
       if close > Entrata then
          sellshort 1 shares at Entrata stop
       elsif close < Entrata then
          sellshort 1 shares at Entrata limit
       endif
       //graphonprice Entrata coloured(255,0,0,255)
    endif
    
    //stop loss massimo in punti dal prezzo ingresso
    If ShortOnMarket AND c4 THEN
       EXITSHORT AT MARKET
    endif
    set stop ploss 70
    set target pprofit 140

    se vuoi vedere la linea dove sono i prezzi di entrata, rimuovi le doppie barre dei commenti dove c’è graphonprice.

    #202399 quote
    Mauro M
    Participant
    New

    Roberto non va ad esempio 7 ottobre (con IG) entra  long a 12425.1. il minimo del 6 ottobre è 12397.0…. 12397.0 – 30 =12367 qui sarebbe stato l’ingresso long.  Non capisco dove possa stare l’errore

    #202402 quote
    robertogozzi
    Moderator
    Master

    Su cosa l’hai provato?

    #202406 quote
    Mauro M
    Participant
    New

    Sul dax.

    #202417 quote
    robertogozzi
    Moderator
    Master

    Timeframe?

    #202421 quote
    Mauro M
    Participant
    New

    Daily

    #202431 quote
    robertogozzi
    Moderator
    Master

    Il 6 ci sono le condizioni e piazza l’ordine d’ingresso LONG sul minimo precedente, che è quello del giorno 5. Se il prezzo d’entrata viene raggiunto il giorno successivo entra (e sarà il 7).

    Se vuoi cambiare il giorno precedente con il giorno corrente sostituisci [1] con [0] nelle due righe:

    Entrata = low[1]  - Ntick
    Entrata = high[1] + Ntick
    #202441 quote
    Mauro M
    Participant
    New

    Funziona tutto. Grazie perfetto.

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

non mi entra correttamente…


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Mauro M @mauro-m Participant
Summary

This topic contains 8 replies,
has 2 voices, and was last updated by Mauro M
3 years, 4 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 10/12/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...