Heikin ashi smoothed

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #139401 quote
    R05
    Participant
    Veteran

    Gent.mi buongiorno,

    ho messo su il seguente trading system che si basa sulle hiekin ashi smoothed molto semplice: quando è blu compra, quando diventa rossa vende con stop and reverse ma le entrate le fa ritardate. Vi allego il file.

    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
    
    defparam flatbefore = 153000
    defparam flatafter = 183000
    
    // Condizioni per entrare su posizioni long
    indicator1, ignored = CALL "PRC_HPT Heikin Ashi Smoothed"[10, 10]
    
    
    IF indicator1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Condizioni per entrare su posizioni short
    ignored, indicator2 = CALL "PRC_HPT Heikin Ashi Smoothed"[10, 10]
    
    
    IF indicator2 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Stop e target
    SET STOP pLOSS 20
    SET TARGET pPROFIT 20

    La pagina dell’indicatore è la seguente: https://www.prorealcode.com/prorealtime-indicators/hpt-heikin-ashi-smoothed/.

    Nel file esempio le due operazioni cerchiate sono state aperte dopo il cambio colore alla quarta candela, e poi prima altre operazioni non sono state fatte.

    esempio.jpg esempio.jpg
    #139405 quote
    robertogozzi
    Moderator
    Master

    Nel secondo caso perché era già a mercato.

    Nel primo caso probabilmente per l’orario, hai postato una foto in cui non si vede nient’altro che le candele.

    È meglio postare sempre foto da cui si possa vedere tutto il grafico (non lo schermo), in modo da vedere date, orari, unità, TF, prezzo e strumento.

    #139406 quote
    R05
    Participant
    Veteran

    Si scusa Roberto hai ragione. Ho rifatto lo screen shot. Nasdaq time frame 1 minuto.

    esempio-1.jpg esempio-1.jpg
    #139435 quote
    robertogozzi
    Moderator
    Master

    Dimmi per favore il giorno e l’ora esatta delle candele da controllare.

    #139447 quote
    R05
    Participant
    Veteran

    Ciao Roberto nell’esempio è la giornata di ieri alle ore 17:29 e 17:39. Ma in tutte le operazioni tarda sempre almeno di una candela: cioè appare rossa la heikin ashi smoothed e alla candela successiva dovrebbe aprire la posizione ma non lo fa: lo fa dalla terza in poi.

    #139456 quote
    robertogozzi
    Moderator
    Master

    Come si vede dalla foto il segnale viene generato alle 17:28 ed entra LONG (segnato con la freccia alle 17:29). Lo stesso fa alle 17:38 (freccia sulle 17:39) ma stavolta SHORT.

    L’entrate sono corrette in base al segnale ricevuto.

    Perché secondo te è tardi, quando dovrebbe arrivare il segnale?

    x-5.jpg x-5.jpg
    #139476 quote
    R05
    Participant
    Veteran

    Ciao Roberto io manualmente entro alla seconda candela blu o rossa: cioè dopo un trend a ribasso abbiamo la prima candela blu, una volta avuta questa ho la conferma che inizia il trend long quindi alla candela successiva cioè alla seconda blu entro long. Ti allego l’immagine sempre per l’esempio di mercoledì, il primo esempio perchè per me il segnale è generato alle 17:27 non alle 17:28 (o per lo meno io in manuale alle 17:28 già entro avendo già la candela precedente quella delle 17:27 cambiato colore).

    Cattura.jpg Cattura.jpg
    #139478 quote
    robertogozzi
    Moderator
    Master

    Si, ma manualmente vedi un grafico e decidi.

    Una strategia non vede i grafici, si basa solo sui segnali che riceve dall’indicatore.

    Quando il segnale è Long va Long, quando è Short va Short. Se non c’è segnale non entra.

    #139482 quote
    R05
    Participant
    Veteran

    Ok perfetto Roberto, grazie. Quindi il problema dovrebbe essere l’indicatore che è ritardato, in effetti nel tuo grafico di prima l’indicatore messo in fondo al grafico mostra la candela verde o rossa sempre a partire dalla seconda candela e quindi il sistema avendo il segnale alla seconda candela apre la posizione alla candela successiva. Chissà perchè l’indicatore non mostra il segnale già alla prima. Potrebbe essere un problema di settaggio dell’ indicatore ? (perchè per fare un esempio è come se quando il supertrend diventa verde il sistema non entra subito ma aspetta un’altra candela)

    #139488 quote
    robertogozzi
    Moderator
    Master

    Perché l’autore ha stabilito le condizioni che riteneva corrette (per lui o per chi ha avuto l’idea).

    Ovviamente l’idea può essere cambiata, per questo ti chiedevo quando vorresti, per il tuo trading, che il segnale Long o Short apparisse?

    #139490 quote
    R05
    Participant
    Veteran

    Alla prima candela blu o rossa che appare. Abbiamo trend a rialzo: blu blu blu blu blu blu rossa (qui subito deve apparire il segnale perchè ho già la candela di colore opposto)

    Cattura2.jpg Cattura2.jpg
    #139503 quote
    robertogozzi
    Moderator
    Master

    Ti ho modificato il codice solo per il segnale, quindi crea un duplicato dell’indicatore, con un nome diverso, mettere sotto il grafico (o anche da richiamare solamente senza metterlo sotto grafico). L’indicatore originale lascialo pure sul grafico così puoi vedere le candele, mentre questo restituisce solo segnali (impostalo come istogramma se vuoi, magari con colori diversi per Long e Short):

    //PRC_HPT Heikin Ashi Smoothed | indicator
    //25.04.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //translated from MT4 indicator code
    
    //---settings
    //MaPeriod=6
    //MaPeriod2=2
    //---end of settings
    
    once maOpen=Open
    once maClose=Close
    //once maLow=Low
    //once maHigh=High
    
    if barindex>0 then
    maOpen=(maOpen[1]*(MAperiod-1)+Open)/MAPeriod
    maClose=(maClose[1]*(MAperiod-1)+Close)/MAPeriod
    maLow=(maLow[1]*(MAperiod-1)+Low)/MAPeriod
    maHigh=(maHigh[1]*(MAperiod-1)+High)/MAPeriod
    
    haOpen=(ExtMapBuffer5[1]+ExtMapBuffer6[1])/2
    haClose=(maOpen+maHigh+maLow+maClose)/4
    //haHigh=Max(maHigh, Max(haOpen, haClose))
    //haLow=Min(maLow, Min(haOpen, haClose))
    if (haOpen<haClose) then
    //r=0
    //g=191
    //b=255
    //ExtMapBuffer7=haLow
    //ExtMapBuffer8=haHigh
    else
    //r=255
    //g=10
    //b=0
    //ExtMapBuffer7=haHigh
    //ExtMapBuffer8=haLow
    endif
    ExtMapBuffer5=haOpen
    ExtMapBuffer6=haClose
    
    //ExtMapBuffer1=weightedaverage[MAperiod2](ExtMapBuffer7)
    //ExtMapBuffer2=weightedaverage[MAperiod2](ExtMapBuffer8)
    //ExtMapBuffer3=weightedaverage[MAperiod2](ExtMapBuffer5)
    //ExtMapBuffer4=weightedaverage[MAperiod2](ExtMapBuffer6)
    endif
    Bullish = haClose > haOpen
    Bearish = haClose < haOpen
    //DRAWCANDLE(ExtMapBuffer3,ExtMapBuffer2,ExtMapBuffer1,ExtMapBuffer4) coloured(r,g,b)
    
    //short = ExtMapBuffer7[1]>ExtMapBuffer8[1] and ExtMapBuffer7[2]<ExtMapBuffer8[2] and ExtMapBuffer7[0]>ExtMapBuffer8[0]
    //long = ExtMapBuffer7[1]<ExtMapBuffer8[1] and ExtMapBuffer7[2]>ExtMapBuffer8[2] and ExtMapBuffer7[0]<ExtMapBuffer8[0]
    Long  = Bullish AND Bearish[1]
    Short = Bearish AND Bullish[1]
    RETURN long as "long signal", -short as "short signal"
    #139505 quote
    R05
    Participant
    Veteran

    Ok grande grazie Roberto, gentilissimo. Ho fatto come hai detto, funziona perfettamente. Ho messo giù il trading system seguente e apre le posizioni dove vorrei io.

    defparam flatbefore = 090000
    defparam flatafter = 183000
    
    //PRC_HPT Heikin Ashi Smoothed | indicator
    //25.04.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //translated from MT4 indicator code
     
    //---settings
    MaPeriod=10
    //MaPeriod2=10
    //---end of settings
     
    once maOpen=Open
    once maClose=Close
    //once maLow=Low
    //once maHigh=High
     
    if barindex>0 then
    maOpen=(maOpen[1]*(MAperiod-1)+Open)/MAPeriod
    maClose=(maClose[1]*(MAperiod-1)+Close)/MAPeriod
    maLow=(maLow[1]*(MAperiod-1)+Low)/MAPeriod
    maHigh=(maHigh[1]*(MAperiod-1)+High)/MAPeriod
     
    haOpen=(ExtMapBuffer5[1]+ExtMapBuffer6[1])/2
    haClose=(maOpen+maHigh+maLow+maClose)/4
    //haHigh=Max(maHigh, Max(haOpen, haClose))
    //haLow=Min(maLow, Min(haOpen, haClose))
    if (haOpen<haClose) then
    //r=0
    //g=191
    //b=255
    //ExtMapBuffer7=haLow
    //ExtMapBuffer8=haHigh
    else
    //r=255
    //g=10
    //b=0
    //ExtMapBuffer7=haHigh
    //ExtMapBuffer8=haLow
    endif
    ExtMapBuffer5=haOpen
    ExtMapBuffer6=haClose
     
    //ExtMapBuffer1=weightedaverage[MAperiod2](ExtMapBuffer7)
    //ExtMapBuffer2=weightedaverage[MAperiod2](ExtMapBuffer8)
    //ExtMapBuffer3=weightedaverage[MAperiod2](ExtMapBuffer5)
    //ExtMapBuffer4=weightedaverage[MAperiod2](ExtMapBuffer6)
    endif
    Bullish = haClose > haOpen
    Bearish = haClose < haOpen
    //DRAWCANDLE(ExtMapBuffer3,ExtMapBuffer2,ExtMapBuffer1,ExtMapBuffer4) coloured(r,g,b)
     
    //short = ExtMapBuffer7[1]>ExtMapBuffer8[1] and ExtMapBuffer7[2]<ExtMapBuffer8[2] and ExtMapBuffer7[0]>ExtMapBuffer8[0]
    //long = ExtMapBuffer7[1]<ExtMapBuffer8[1] and ExtMapBuffer7[2]>ExtMapBuffer8[2] and ExtMapBuffer7[0]<ExtMapBuffer8[0]
    Long  = Bullish AND Bearish[1]
    Short = Bearish AND Bullish[1]
    
    // Condizioni per entrare su posizioni long
    IF long THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    // Condizioni per entrare su posizioni short
    IF short THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF
    
    // Stop e target: Inserisci qui i tuoi stop di protezione e profit target
    set target pprofit 20
    set stop ploss 20
    
    esempio-2.jpg esempio-2.jpg
    #139608 quote
    R05
    Participant
    Veteran

    Ciao Roberto, se volessi che il sistema aprisse la posizione long solo dopo che abbiamo avuto almeno ad esempio 10 candele rosse, come dovrei fare?

    Ho provato ad aggiungere il seguente codice

    ONCE CandleNum = 10
    Bullish        = summation[CandleNum](close > open) = CandleNum
    Bearish        = summation[CandleNum](close < open) = CandleNum
    

    ed ho ottenuto questo, ma non fa quello che voglio

    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
    
    defparam flatbefore = 090000
    defparam flatafter = 183000
     
    //PRC_HPT Heikin Ashi Smoothed | indicator
    //25.04.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //translated from MT4 indicator code
     
    //---settings
    MaPeriod=10
    //MaPeriod2=10
    //---end of settings
     
    once maOpen=Open
    once maClose=Close
    //once maLow=Low
    //once maHigh=High
     
    if barindex>0 then
    maOpen=(maOpen[1]*(MAperiod-1)+Open)/MAPeriod
    maClose=(maClose[1]*(MAperiod-1)+Close)/MAPeriod
    maLow=(maLow[1]*(MAperiod-1)+Low)/MAPeriod
    maHigh=(maHigh[1]*(MAperiod-1)+High)/MAPeriod
     
    haOpen=(ExtMapBuffer5[1]+ExtMapBuffer6[1])/2
    haClose=(maOpen+maHigh+maLow+maClose)/4
    //haHigh=Max(maHigh, Max(haOpen, haClose))
    //haLow=Min(maLow, Min(haOpen, haClose))
    if (haOpen<haClose) then
    //r=0
    //g=191
    //b=255
    //ExtMapBuffer7=haLow
    //ExtMapBuffer8=haHigh
    else
    //r=255
    //g=10
    //b=0
    //ExtMapBuffer7=haHigh
    //ExtMapBuffer8=haLow
    endif
    ExtMapBuffer5=haOpen
    ExtMapBuffer6=haClose
     
    //ExtMapBuffer1=weightedaverage[MAperiod2](ExtMapBuffer7)
    //ExtMapBuffer2=weightedaverage[MAperiod2](ExtMapBuffer8)
    //ExtMapBuffer3=weightedaverage[MAperiod2](ExtMapBuffer5)
    //ExtMapBuffer4=weightedaverage[MAperiod2](ExtMapBuffer6)
    endif
    Bullish = haClose > haOpen
    Bearish = haClose < haOpen
    //DRAWCANDLE(ExtMapBuffer3,ExtMapBuffer2,ExtMapBuffer1,ExtMapBuffer4) coloured(r,g,b)
     
    //short = ExtMapBuffer7[1]>ExtMapBuffer8[1] and ExtMapBuffer7[2]<ExtMapBuffer8[2] and ExtMapBuffer7[0]>ExtMapBuffer8[0]
    //long = ExtMapBuffer7[1]<ExtMapBuffer8[1] and ExtMapBuffer7[2]>ExtMapBuffer8[2] and ExtMapBuffer7[0]<ExtMapBuffer8[0]
    Long  = Bullish AND Bearish[1]
    Short = Bearish AND Bullish[1]
     
    
    ONCE CandleNum = 10
    Bullish        = summation[CandleNum](close > open) = CandleNum
    Bearish        = summation[CandleNum](close < open) = CandleNum
    
    
    // Condizioni per entrare su posizioni long
    IF long and bearish THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
     
    // Condizioni per entrare su posizioni short
    IF short and bullish THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF
     
    // Stop e target: Inserisci qui i tuoi stop di protezione e profit target
    set target pprofit 20
    set stop ploss 20
    

    esempio allegato è di venerdì sul nasdaq time frame 1 minuto

    Cattura-1.jpg Cattura-1.jpg
    #139610 quote
    robertogozzi
    Moderator
    Master

    Alle righe 65 e 66 devi usare HACLOSE e HAOPEN, non open e close, altrimenti fa la verifica sulle candele giapponesi normali.

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

Heikin ashi smoothed


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
R05 @r05 Participant
Summary

This topic contains 23 replies,
has 3 voices, and was last updated by R05
5 years, 6 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 07/16/2020
Status: Active
Attachments: 9 files
Logo Logo
Loading...