Aiuto per creazione TS con Donchian Channel

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #71121 quote
    bloodflowerbloodflower
    Participant
    New

    Ciao a tutti,

    vorrei realizzare un TS che sfrutti il Donchian Channel per generare delle entrate a mercato.

     

    L’idea è: guarda le ultime 10 barre (time frame: 4h oppure daily), se la barra attuale supera il canale superiore (inferiore) del Donchian Channel entra nella successiva Long (Short).

    Stop loss a 1 ATR e profit target a 5 ATR (ATR a 10 giorni).

    Qualcuno mi può aiutare?

    Grazie mille!

    #71147 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ho scritto questo codice, provalo:

    DEFPARAM CumulateOrders = false
    
    ONCE Periodi = 10
    
    DonchianSUP  = highest[Periodi](high[1])
    DonchianINF  = lowest[Periodi](low[1])
    
    StopLoss     = AverageTrueRange[Periodi](close)
    TargetProfit = StopLoss * 5
    
    //          LONG
    IF high > DonchianSUP THEN
       BUY 1 CONTRACT AT MARKET
       SET TARGET PROFIT TargetProfit
       SET STOP   LOSS   StopLoss
    ENDIF
    
    //          SHORT
    IF low < DonchianINF THEN
       SELLSHORT 1 CONTRACT AT MARKET
       SET TARGET PROFIT TargetProfit
       SET STOP   LOSS   StopLoss
    ENDIF
    #71162 quote
    bloodflowerbloodflower
    Participant
    New

    iodi](high[1]) DonchianINF  = lowest[Periodi](low[1])

    Grazie mille, lo provo e ti dico! 🙂

    #71569 quote
    bloodflowerbloodflower
    Participant
    New

    Ciao,

    invece di entrare “AT MARKET” alla barra successiva vorrei inserire un ordine di acquisto “STOP” sulla barra in corso, come posso fare?

    Grazie mille

    #71571 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Prova questa versione

    DEFPARAM CumulateOrders = true
     
    ONCE Periodi            = 10                                //10  periodi per il calcolo del canale
    
    // Gli ordini pendenti durano solo UNA barra, per cui vanno reimmessi ogni volta, se siamo a mercato
    IF LongOnMarket THEN
       SELL      AT DonchianSUP + TargetProfit LIMIT            //Target Profit
       SELL      AT DonchianSUP - StopLoss     STOP             //Stop Loss
    ELSIF ShortOnMarket THEN
       EXITSHORT AT DonchianINF - TargetProfit LIMIT            //Target Profit
       EXITSHORT AT DonchianINF + StopLoss     STOP             //Stop Loss
    ELSE
       // Determinare i  bordi del canale DONCHIAN (quando non siamo a mercato)
       DonchianSUP  = highest[Periodi](high[1])
       DonchianINF  = lowest[Periodi](low[1])
       // Definire Stop Loss & Target Profit
       StopLoss     = AverageTrueRange[Periodi](close)
       TargetProfit = StopLoss * 5
    ENDIF
    
    // Entrare a mercato, se non lo siamo già, con ordini pendenti
    IF Not OnMarket THEN
       //          LONG
       BUY 1 CONTRACT       AT DonchianSUP STOP                 //Entrata
       SELL                 AT DonchianSUP + TargetProfit LIMIT //Target Profit
       SELL                 AT DonchianSUP - StopLoss     STOP  //Stop Loss
       //          SHORT
       SELLSHORT 1 CONTRACT AT DonchianINF STOP                 //Entrata
       EXITSHORT            AT DonchianINF - TargetProfit LIMIT //Target Profit
       EXITSHORT            AT DonchianINF + StopLoss     STOP  //Stop Loss
    ENDIF

     

    (io non l’ho testata)

Viewing 5 posts - 1 through 5 (of 5 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

Aiuto per creazione TS con Donchian Channel


ProOrder: Trading Automatico & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 05/22/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...