uscita a fine giornata con tf 1 giorno

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #201100 quote
    leo di mennoleo di menno
    Participant
    Average

    salve, come posso fare per far uscire la posizione a fine giornata usando il tf giornaliero? ho provato diversi modi ma comunque fa come vuole. grazie

    #201168 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Basta che all’inizio del tuo codice aggiunga:

    IF OnMarket THEN
       SELL      AT MARKET
       EXITSHORT AT MARKET
    ENDIF

    Ovviamente l’uscita verrà eseguita alla chiusura della candela giornaliera.

    #202328 quote
    leo di mennoleo di menno
    Participant
    Average

    sul backtest l’uscita me la da comunque il giorno seguente…… non è possibile uscire a fine giornata?

    #202344 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    L’uscita avviene alla chiusura della candela, ovviamente viene registrata qualche millisecondo dopo e la vedrai sulla nuova candela. In effetti OnMarket ha necessità di un’intera candela per sapere che un’operazione è stata aperta.

    L’unica soluzione è usare il supporto MTF  (Multi, o Multiple, Time Frame) che permette di utilizzare anche un timeframe più piccolo, ad esempio un minuto, in modo da uscire 1 minuto prima della chiusura della candela giornaliera.

    Ecco un esempio (eseguilo da un grafico ad 1 minuto):

    DEFPARAM CumulateOrders = False
    Timeframe(1mn,default)         //timeframe ad 1 minuto
    IF time = 235900 THEN          //uscire sempre alle 23:59  (se esistono posizioni aperte)
       SELL      AT MARKET
       EXITSHORT AT MARKET
    ENDIF
    //
    Timeframe(Daily,UpdateOnClose) //timeframe Giornaliero
    IF close > average[10,0](close) THEN
       BUY AT MARKET
    ENDIF
    IF close < average[10,0](close) THEN
       SELLSHORT AT MARKET
    ENDIF

    Se hai necessità di entrare più nei dettagli basta che cerchi la parola MTF e troverai blog,articoli, post e centinaia di esempim di codice per il multi time frame.

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

uscita a fine giornata con tf 1 giorno


ProOrder: Trading Automatico & Backtesting

New Reply
Author
Summary

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

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