TS Anderson Darling

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #172898 quote
    Wolf Trades
    Participant
    Average

    Buon Pomeriggio a tutti,

    sto scrivendo questo TS multi timeframe molto semplice, ma non riesco a capire cosa sbaglio, vorrei che il TS entrasse long quando la variabile c passa da negativa a positiva e short quando passa da positiva a negativa. Per semplicità ho inserito l’indicatore all’interno del TS:

    Defparam CumulateOrders = False
    Defparam PreLoadBars = 10000
    TimeFrame(Daily)
    // Define variables
    a=LinearRegression[20](close)
    b=Close
    
    // Calculation of difference between the 20 period regression line and the last price expressed as a percentage of the current price
    c=(b-a)/b*100
    if c>0 then
    r=0
    b=255
    else
    r=255
    b=0
    endif
    deviationP=100
    dev=std[deviationP](c)
    
    //candela Verde
    //Verde= Close > Open
    //Candela Rossa
    //Rossa = Close < Open
    
    
    // Condizioni per entrare su posizioni long
    IF NOT LongOnMarket AND c[1]<0 and c>0 THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    // Condizioni per entrare su posizioni short
    IF NOT ShortOnMarket AND c[1]>0 and c<0 THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF
    
    TimeFrame(default)
    Venerdi = OpenDayofWeek=5 and CurrentTime >= 200000
    // Condizioni per uscire da posizioni long
    If LongOnMarket AND Venerdi THEN
    SELL AT MARKET
    ENDIF
    // Condizioni per uscire da posizioni short
    IF ShortOnMarket AND Venerdi THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stop e target: Inserisci qui i tuoi stop di protezione e profit target
    

    Scrivo anche il codice dell’indicatore così da poter verificare sul grafico cosa succede:

    TimeFrame(Daily, updateonclose)
    // Define variables
    a=LinearRegression[20](close)
    b=Close
    
    // Calculation of difference between the 30 period regression line and the last price expressed as a percentage of the current price
    c=(b-a)/b*100
    if c>0 then
    r=0
    b=255
    else
    r=255
    b=0
    endif
    deviationP=100
    dev=std[deviationP](c)
    
    return c coloured(r,0,b) style(histogram) as "ARLS", 0 as "Zero", 0+3*dev style(dottedline,2) as "plus 3 dev", 0+2*dev coloured(255,0,0) style(line,3) as "plus 2 dev", 0-3*dev style(dottedline,2) as "minus 3 dev", 0-2*dev coloured(255,0,0) style(line,3)  as "minus 2 dev"
    
    #172900 quote
    robertogozzi
    Moderator
    Master

    Hai fatto bene ad inserire l’indicatore nel TS, perché gli indicatori MTF (che usano più TF) al momento non sempre funzionano quando sono chiamati con CALL (ci sarà una correzione in futuro).

    A me funziona regolarmente quando C cambia segno.

    #172901 quote
    robertogozzi
    Moderator
    Master

    Alla fine del codice aggiungi queste due righe:

    GRAPH c > 0
    GRAPH c < 0

    vedrai, nel riquadro delle variabili che ProBackTest aprirà (sotto la curva dell’equity), i valori che C ha di volta in volta e ti renderai conto cher quando incrociano c’è stato un cambio ed entra (la freccia la vedrai sulla candela successiva).

    #172904 quote
    Wolf Trades
    Participant
    Average

    Grazie Roberto, ti allego uno screen di un backtest in H4, guardando l’indicatore apre operazioni anche quando non c’è l’incrocio. E’ colpa dell’indicatore che non funziona in multi timeframe?

    H4.jpg H4.jpg
    #172909 quote
    robertogozzi
    Moderator
    Master

    Come ti ho detto, hai fatto bene a mettere l’indicatore all’interno del codice.

    A prima vista mi pare siano tutte corrette, purtroppo non si può vedere bene la posizione dell’entrata rispetto all’incrocio, ma sembrano corrette.

    Dimmi una candela abbastanza recente, data e ora, da potere verificare (diciamo non prima el 2015).

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

TS Anderson Darling


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Wolf Trades @lupo32 Participant
Summary

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

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 07/01/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...