info Backtest Supertrend

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #202617 quote
    xcirolix85
    Participant
    New

    Ciao ragazzi, premetto che non sono molto pratico con le programmazioni perchè il mio stile è discrezionale.

    Detto ciò vorrei chiedere se qualche buon anima mi può dare una mano a modificare la scrittura della strategia supertrend di default per fare dei backtest

    Quello che vorrei è:

    • Sul settimanale se il Supertrend è verde cerca solo posizioni LONG
    • Sul settimanale se il Supertrend è rosso cerca solo posizioni SHORT

    TF OPERATIVO

    • Giornaliero: Entra long quando c’è il cambio da rosso a verde / esci quando diventa rosso
    • Giornaliero: Entra short quando c’è il cambio da verde a rosso / esci quando diventa verde
    #202661 quote
    Nicolas
    Keymaster
    Master

    Ecco il codice che stai cercando. Prendiamo ordini su intervalli di tempo giornalieri Supertend che cambiano colore e con un filtro Supertrend dello stesso colore su base settimanale.

    timeframe(weekly, updateonclose)
    wst = Supertrend[3,10]
    wlong = close>wst
    wshort = close<wst
    
    timeframe(daily,updateonclose)
    dst = Supertrend[3,10]
    if not longonmarket and close crosses over dst and wlong then 
    buy 1 contract at market 
    endif 
    
    if not shortonmarket and close crosses under dst and wshort then 
    sellshort 1 contract at market 
    endif 
    
    
    #202676 quote
    xcirolix85
    Participant
    New

    Grazie della risposta intanto..

    L’ho appena provato ma noto che nel tf operativo, cioè il giornaliero, non chiude le operazioni quando c’è il cambio colore..

    #202681 quote
    Nicolas
    Keymaster
    Master

    Sì, penso che sia correlato al modo in cui apro l'ordine solo in base al filtro settimanale. Nella versione modificata di seguito, gli ordini vengono chiusi solo in base al cambio colore giornaliero Supertrend, anche se una nuova condizione di ordine contrarian non è ancora soddisfatta:

    timeframe(weekly, updateonclose)
    wst = Supertrend[3,10]
    wlong = close>wst
    wshort = close<wst
    
    timeframe(daily,updateonclose)
    dst = Supertrend[3,10]
    
    if longonmarket and close crosses under dst then 
     sell at market 
    endif 
    if shortonmarket and close crosses over dst then 
     exitshort at market 
    endif 
    
    if not longonmarket and close crosses over dst and wlong then 
    buy 1 contract at market 
    endif 
    
    if not shortonmarket and close crosses under dst and wshort then 
    sellshort 1 contract at market 
    endif
    #202699 quote
    xcirolix85
    Participant
    New

    Ottimo così va benissimo.. grazie mille

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

info Backtest Supertrend


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
xcirolix85 @xcirolix85 Participant
Summary

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

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 10/16/2022
Status: Active
Attachments: No files
Logo Logo
Loading...