TS Mean Reverse con richiamo indicatore

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #172741 quote
    Wolf TradesWolf Trades
    Participant
    Average

    Salve a tutti, ho trovato questo indicatore all’interno della library, il link è il seguente:

    https://www.prorealcode.com/prorealtime-indicators/normalized-bars/

    Il codice l’ho leggermente modificato come segue:

    TimeFrame(Daily)
    // --- settings
    p = 100
    s = 2
    // --- end of settings
     
    myRange = close - open
    myStd = std[p](myRange)*s
     
    dynO = 0
    dynH = high - open
    dynL = low - open
    dynC = close - open
     
    if dync > 0 then
    R = 0
    G = 125
    B = 255
    else
    R = 255
    G = 125
    B = 0
    endif
     
    DRAWBARCHART(dynO,dynH,dynL,dynC) coloured(r,g,b)
     
    return myStd as "+std", -myStd as "-std", 0 as "0"

    In sostanza vorrei codificare un trading system mean reverse che, per esempio:

    -apra trade short se il prezzo è salito oltre 2 volte la deviazione standard calcolata sugli ultimi 100 giorni

    -apra trade long se il prezzo è sceso oltre 2 volte la deviazione standard calcolata sugli ultimi 100 giorni

    Ho provato a fare un backtest ma credo di aver sbagliato qualcosa, ho inserito l’indicatore direttamente nel TS senza usare la funzione CALL:

    Defparam CumulateOrders = FALSE
    DefParam PreLoadBars = 10000000
    
    TimeFRame(Daily)
    // --- settings
    p = 100
    s = 2
    // --- end of settings
     
    myRange = close - open
    myStdPositiva = std[p](myRange)*s
    myStdNegativa = (std[p](myRange)*s)*(-1)
     
    dynO = 0
    dynH = high - open
    dynL = low - open
    dynC = close - open
     
    
    CondBuy = Close > myStdPositiva
    CondSell = Close < myStdNegativa
    
    Venerdi = OpendayofWeek=5 and CurrentTime >=200000
    
    TimeFrame(Default)
    // Condizioni per entrare su posizioni long
    IF NOT LongOnMarket AND CondBuy THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    // Condizioni per uscire da posizioni long
    If LongOnMarket AND Venerdi THEN
    SELL AT MARKET
    ENDIF
    
    // Condizioni per entrare su posizioni short
    IF NOT ShortOnMarket AND CondSell THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF
    
    // Condizioni per uscire da posizioni short
    IF ShortOnMarket AND Venerdi THEN
    EXITSHORT AT MARKET
    ENDIF
    

    Grazie a chi potrà aiutarmi

    #172742 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Alle righe 20 e 21 confronti il prezzo con l’indicatore, ma credo non vada bene, mi pare non restituisca un prezzo.

    #172746 quote
    Wolf TradesWolf Trades
    Participant
    Average

    Ciao Roberto, non riesco a capire l’errore, quando hai tempo puoi aiutarmi?

    #172749 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ti posso aiutare se mo spieghi cosa vuoi fare.

    L’indicatore può valere 1.0345 oppure -0.3457, come puoi confrontarlo con un prezzo (close)?

    Devi spiegarmi cosa vuoi fare con l’indicatore.

    #172750 quote
    Wolf TradesWolf Trades
    Participant
    Average

    Vorrei un buy o un sell se il prezzo dell’asset supera 2 volte la deviazione standard di un determinato periodo.

    buy: prezzo che supera di 2 volte la deviazione standard negativa

    sell: il contrario

    #172753 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Prova a cambiare la riga 10 con questa:

    myRange = close

    In modo che la deviazione sia calcolata sul prezzo e non sul range.

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

TS Mean Reverse con richiamo indicatore


ProOrder: Trading Automatico & Backtesting

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

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

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