Primo cambio di colore del Supertrend

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26624 quote
    gpecom1gpecom1
    Participant
    New

    Salve a Tutti,

    sono nuovo e sto imparando come programmare con ProRealCode.

    Vorrei creare un TS su timeframe a 5 minuti che si basi sul Supertrend.

    Il sistema dovrebbe fare 1 solo trade al giorno, al primo cambio di colore del supertrend che si verifica dopo le 8:00, e chiudere la posizione entro le 22:30.

    Entry LONG al PRIMO cambio di colore da rosso a verde (dopo le 8:00) OPPURE entry SHORT al PRIMO cambio di colore da verde a rosso (sempre dopo le 8:00).

    Mi sembra che questi potrebbero essere i parametri generali per l’entry:

    DEFPARAM FlatAfter 223000
    st = supertrend[3,10]
    CambioVerde = close[1] < st[1] AND close > st
    CambioRosso = close[1] > st[1] AND close < st
     IF NOT ONMARKET AND TIME > 080000 AND CambioVerde THEN
    BUY 1 contracts AT MARKET
    ENDIF
    IF NOT ONMARKET AND TIME > 080000 AND CambioRosso THEN
    SELLSHORT 1 contracts AT MARKET
    ENDIF
    SET STOP pLOSS.....
    SET TARGET pPROFIT...

    Purtroppo, però, in questo modo il sistema non sembra riconoscere il “PRIMO” CAMBIO DI COLORE dopo le 8:00:
    si attiva dopo quell’orario, ma apre più di una posizione, sia long che short.
    Qualcuno potrebbe aiutarmi a risolvere questo problema? Vorrei che il sistema aprisse una sola posizione, o long o short.
    Molte grazie!

    Gian Paolo

    #26666 quote
    NicolasNicolas
    Keymaster
    Legend

    Al fine di mettere un solo ordine ogni giorno al primo cambiamento di colore supertend, dovrete bandiera una variabile che si è già fatto un mestiere e reimpostare questa variabile ogni nuovo giorno.
    Si può fare come segue:

    DEFPARAM FlatAfter 223000
    
    if intradaybarindex=0 then 
     traded = 0
    endif 
    
    st = supertrend[3,10]
    CambioVerde = close[1] < st[1] AND close > st
    CambioRosso = close[1] > st[1] AND close < st
    
    if traded=0 then 
    IF NOT ONMARKET AND TIME > 080000 AND CambioVerde THEN
     BUY 1 contracts AT MARKET
     traded=1
    ENDIF
     IF NOT ONMARKET AND TIME > 080000 AND CambioRosso THEN
     SELLSHORT 1 contracts AT MARKET
     traded=1
    ENDIF
    endif
    
    SET STOP pLOSS.....
    SET TARGET pPROFIT...

    Non ho prove esso, è la codifica forum.

    #26671 quote
    gpecom1gpecom1
    Participant
    New

    Molte grazie Nicolas, per la tua gentilezza, disponibilità e competenza.

    Mi metto al lavoro e ti tengo informato.

    Gian Paolo

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

Primo cambio di colore del Supertrend


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
gpecom1 @gpecom1 Participant
Summary

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

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 02/28/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...