Codice pattern candlestick

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #14584 quote
    Luigi5192Luigi5192
    Participant
    Average

    salve sono nuovo in questo forum, e ho un problema di creazione di una strategia.

    Voglio creare una strategia dove vado a dire che per aprire una posizione long la prima candela deve aprire sotto la banda superiore di bollinger e chiudere sopra, la seconda candela aprire sopra e chiudere sotto, e la terza chiudere sotto il min della prima, viceversa per una posizione short.

    l’entrata viene eseguita a chiusura della 3 candela.

    #14591 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Penso questo possa andare (dovrai aggiustare SL e TP ed eventuali altre condizioni), se ho ben capito il tuo quesito.

    Quella che tu chiami “terza candela” è la candela corrente, la cui chiusura si indica con CLOSE[0] o semplicemente CLOSE (così come low, high, open). La seconda è la candela [1], la prima è la candela [2].

    DEFPARAM CumulateOrders = False                   //No more than 1 trade allowed
    
    BBavg = 20                                        //20-period BB
    BBdev = 2                                         //2-point deviation
    BBVal = average[BBavg](close)                     //BB 20 mean (middle line)
    BollUp = BBval + (std[BBavg](close) * BBdev)      //Bollinger Up   value (20, 2)
    BollDn = BBval - (std[BBavg](close) * BBdev)      //Bollinger Down value (20, 2)
    
    //               Conditions to enter a LONG trade
    c1 = (open[2] < BollUp) AND (close[2] > BollUp) //First  candle opens below and closes above BB up
    c2 = (open[1] > BollUp) AND (close[1] < BollUp) //Second candle opens above and closes below BB up
    c3 = (close < low[2])                           //Third, or current, candle closes below the minimum
                                                    //                   of the first candle
    IF c1 AND c2 AND c3 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    //               Conditions to enter a SHORT trade
    c4 = (open[2] > BollDn) AND (close[2] < BollDn) //First  candle opens above and closes below BB down
    c5 = (open[1] < BollDn) AND (close[1] > BollDn) //Second candle opens below and closes above BB down
    c6 = (close > high[2])                          //Third, or current, candle closes above the maximum
    //                                                                   of the first candle
    IF c4 AND c5 AND c6 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    //     Stop e target
    SET TARGET PPROFIT 10
    SET STOP PLOSS 10
    

    Ho scritto le annotazione in inglese perché sono abutuato a scrivere in inglese ed è facilmente comprensibile anche ad utenti non italiani.

    Ciao.

    Nicolas thanked this post
    #14594 quote
    Luigi5192Luigi5192
    Participant
    Average

    ti ringrazio, saluti.

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

Codice pattern candlestick


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Luigi5192 @luigi5192 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Luigi5192Luigi5192
9 years, 11 months ago.

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