Indicatore non funziona in “CALL”

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #249154 quote
    occhiostanco
    Participant
    New

    Buongiorno,

    il mi primo indicatore, che calcola l’ATR daily quando ci si trova in un TF intraday, funziona quando è applicato

    a un grafico, ma non se è chiamato da un altri indicatore (ritorna e stampa N/D), anche la semplice chiamata;

    MyATR= CALL RdAATRDInIntraday [5]
    return

     

    Di seguito il codice dell’indicatore. In allegato il grafico dove si vede il valore calcolato.

    Se un altro indicatore lo chiama, al posto del valore corretto restiuisce e stampa N/D

    Grazie

     

    // R. da Argile
    //
    // Compute TR daily in TF intraday
    // A MINIMUM NUMBER OF BARS MAY BE REQUIRED TO BE ACCURATE
    //
    // DEFPARAM DRAWONLASTBARONLY = true      // for debug purpose
    
    TFDailyInSeconds  = 3600 * 24          // various intraday time frames in seconds
    TFMinInSeconds    = 60                 // ...
    TF30MinInSeconds  = 60 * 30            // ...
    TFWeeklyInSeconds = 3600 * 24 * 7      // ...
    TFMaxIntradayInSeconds  = 3600 * 4     // max intraday considered is 4H
    
    ONCE AlreadyDrawnInfo                     = 0
    ONCE AlreadyComputedTodayNumOfMBbars      = 0
    
    // get and shows current TF
    IF AlreadyDrawnInfo = 0 THEN           // Stuff to be done only ONCE
    TF = GetTimeFrame     // timeframe in seconds
    TFinMin = TF / 60
    //DRAWTEXT ("timeframe in seconds #TF# ", -100, -50) ANCHOR (TOPRIGHT, XSHIFT, YSHIFT)
    TFintraday = 1
    TFNumBarsInDay = 3600 / TF
    IF TF >  TFMaxIntradayInSeconds THEN  // Computatin only TF intraday up to 4H
    TFintraday = 0
    TFNumBarsInDay = 1
    ENDIF
    //
    AlreadyDrawnInfo = 1
    ENDIF
    
    //
    // compute running ATR daiy
    //
    CurrentTRDaily    = max(DHIGH(0) - DLOW(0), MAX(abs(DHIGH(0) - DCLOSE(1)), abs(DLOW(0) - DCLOSE(1))))
    // Get last day before yesterday bar
    IF BarIndex < (ATRdailyPeriod * TFNumBarsInDay) THEN
    PreviousDayClose = DCLOSE(2)       // previous day close
    PreviousDayLow   = DLOW(2)         // previous day low
    CurrentTRDaily   = MAX(DHIGH(1)-DLOW(1), MAX(abs(DHIGH(1) - PreviousDayClose), ABS(DLOW(1) - PreviousDayClose))) // current True Range Daily
    MyATRDaily = CurrentTRDaily
    ELSE
    IF INTRADAYBARINDEX = 0 THEN // compute new atr daily only on first intraday bar
    BarFDound = 0
    iBar = 0
    WHILE (BarFDound < 2) AND (iBar < (2 * TFNumBarsInDay))    // secon check is to avoid infiniteloop
    IF OPENDAYOFWEEK[iBar] <> OPENDAYOFWEEK[iBar + 1] THEN
    iLastYesterdayBar = iBar + 1
    BarFound = BarFound + 1
    ENDIF
    iBar = iBar + 1
    WEND
    
    PreviousDayClose = DCLOSE(iLastYesterdayBar+1)       // previous day close
    PreviousDayLow   = DLOW(iLastYesterdayBar+1)         // previous day low
    CurrentTRDaily   = MAX(DHIGH(iLastYesterdayBar)-DLOW(iLastYesterdayBar), MAX(abs(DHIGH(iLastYesterdayBar) - PreviousDayClose), ABS(DLOW(iLastYesterdayBar) - PreviousDayClose))) // current True Range Daily
    MyATRDaily = ((MyATRDaily[1] * (ATRdailyPeriod - 1)) + CurrentTRDaily) / ATRdailyPeriod
    ELSE
    MyATRDaily = MyATRDaily[1]
    ENDIF
    ENDIF
    
    
    IF DATE = TODAY THEN
    DRAWTEXT ("ATRD computed in TF <#TFinMin#Min>: #MyATRDaily# ", -100, -35) ANCHOR (TOPRIGHT, XSHIFT, YSHIFT)
    ENDIF
    
    // return al least 2 values otherwise indicator takes the name of the UNIQUE return value (sic!)
    RETURN myATRdaily AS "ARdaily" COLOURED (0,0,0,0)
    
    #249160 quote
    occhiostanco
    Participant
    New

    Comunque ho inserito il codice con il pulsante ma vedo che non lo ha indentato ….

    #249164 quote
    robertogozzi
    Moderator
    Master

    Non lo indenta.

    Posta il file ITF, oppure indica qual’è il dato che gli viene passato con la CALL.

    #249167 quote
    Wim
    Participant
    Junior

    PRT non consente la CALL di un indicatore contenente codice MultiTimeFrame (MTF). Sfortunatamente PRT non ti dà un messaggio di errore decente se provi questo. La mia ipotesi è che il colpevole sia il tuo gettimeframe nella riga 19.  (autotranslate par DEEPL)

    #249170 quote
    Iván González
    Moderator
    Master

    Forse si tratta di qualcosa nel tuo codice…
    nel grafico seguente puoi vedere l’ATR calcolato direttamente nell’indicatore e richiamato con l’istruzione CALL.

    timeframe(daily)
    myATRdaily=averagetruerange[5](close)
    RETURN myATRdaily
    myatr=call "MyIndicator(5)"
    return myatr
    
    occhiostanco thanked this post
    #249174 quote
    occhiostanco
    Participant
    New

    Grazie Wim,

    non uso la funzione TIMEFRAME proprio per evitare guai di quel genere, credo il problema sia un altro, comunque molto frustrante

    perdere tempo così….

    #249175 quote
    occhiostanco
    Participant
    New

    Scusa roberto cosa è il file itf?

    #249177 quote
    Wim
    Participant
    Junior
    //MyATR= CALL RdAATRDInIntraday [5]
    //return
    
    MyATR= CALL "RdAATRDInIntraday"[60]
    return MyATR as "MyATR"
    #249190 quote
    robertogozzi
    Moderator
    Master

    Scusa roberto cosa è il file itf?

    E’ il file creato dall’editor di ProRealTime. Quando vuoi salvare in locale sul tuo PC il codice, devi esportarlo mediante l’apposito pulsante (vedi foto, pressoché identica per indicatori, strategie e screener) e ti creerà il file crittografato ITF.

    Il pulsante da usare è quello evidenziato in CELESTE, mentre il file è quello evidenziato in ARANCIO (ovviamente tu sceglierai uno dei tuoi codici), segui le indicazioni per dirgli dove andare a salvare il file con estenzione ITF (non è un testo visibile).

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

Indicatore non funziona in “CALL”


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
Summary

This topic contains 8 replies,
has 4 voices, and was last updated by robertogozzi
6 months, 1 week ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 07/28/2025
Status: Active
Attachments: 3 files
Logo Logo
Loading...