Trading Range Iniziale

Forums ProRealTime forum Italiano Supporto ProOrder Trading Range Iniziale

Viewing 4 posts - 1 through 4 (of 4 total)
  • #243591

    Salve, sotto ho postato un programma semplice basato sulla rottura di un tradig range nelle prime 2 ore di negizziazione. Quando faccio andare il backtest mi dice di definire la variabile “EntryPririce”.  Sicuramente sono io che sbaglio qualcosa ma da quanto ho capito non è da definire. Cosa posso fare per favore sono bloccato.

    // Strategia Breakout Range Intraday (Esempio Base) – CODICE CORRETTO
    // Timeframe: 30 minuti o 1 ora

    DEFPARAM CumulateOrders = False // Non cumulare ordini

    // **1. Definisci il Range Iniziale (Prime 2 Ore della Sessione)**
    StartTimeRange = 090000 // 9:00 ora del mercato
    EndTimeRange = 110000 // 11:00 ora del mercato

    ONCE RangeHigh = 0
    ONCE RangeLow = 0
    ONCE RangeDefined = 0 // 0 = non definito, 1 = definito

    IF Time >= StartTimeRange AND Time <= EndTimeRange AND RangeDefined = 0 THEN
    RangeHigh = Highest[3](High) // Massimo delle ultime 3 barre (circa 1.5 ore a 30 min TF)
    RangeLow = Lowest[3](Low) // Minimo delle ultime 3 barre
    RangeDefined = 1
    ENDIF

    // **2. Condizioni di Ingresso (Breakout)**
    BuyLevel = RangeHigh + (PipValue * 5) // Buy Stop leggermente sopra il massimo (5 pips, ad esempio)
    SellLevel = RangeLow – (PipValue * 5) // Sell Stop leggermente sotto il minimo

    // **3. Ordini di Ingresso (Buy Stop e Sell Stop)**
    IF Time > EndTimeRange AND RangeDefined = 1 THEN // Entra dopo la definizione del range
    IF NOT LongOnMarket THEN
    BUY 1 CONTRACT AT BuyLevel STOP
    ENDIF
    IF NOT ShortOnMarket THEN
    SELLSHORT 1 CONTRACT AT SellLevel STOP
    ENDIF
    ENDIF

    // **4. Stop Loss e Take Profit (Percentuali del Range – Da Ottimizzare)**
    RangeAmplitude = RangeHigh – RangeLow
    StopLossPercent = 1 // 1% del range come Stop Loss (da ottimizzare)
    TakeProfitPercent = 2 // 2% del range come Take Profit (da ottimizzare)

    StopLossLongLevel = EntryPrice – (RangeAmplitude * StopLossPercent / 100)
    StopLossShortLevel = EntryPrice + (RangeAmplitude * StopLossPercent / 100)
    TakeProfitLongLevel = EntryPrice + (RangeAmplitude * TakeProfitPercent / 100)
    TakeProfitShortLevel = EntryPrice – (RangeAmplitude * TakeProfitPercent / 100)

    SET STOP LOSS StopLossLongLevel
    SET TARGET PROFIT TakeProfitLongLevel
    SET STOP LOSS StopLossShortLevel
    SET TARGET PROFIT TakeProfitShortLevel

    // **5. Time Exit (Chiusura a Fine Giornata)**
    TimeExit = 170000 // 17:00 ora del mercato

    IF Time >= TimeExit THEN
    IF LongOnMarket THEN
    SELL AT MARKET
    ENDIF
    IF ShortOnMarket THEN
    EXITSHORT AT MARKET
    ENDIF
    QUIT // Arresta il sistema a fine giornata
    ENDIF

    // **Reset Range per il giorno successivo**
    IF DayOfWeek <> DayOfWeek[1] THEN // Se cambia il giorno
    RangeDefined = 0 // Resetta per il nuovo giorno
    ENDIF

    #243601

    Si, devi definire quella variabile, visto che viene usata 4 volte, per  determinare i livelli di SL e TP.

     

    1 user thanked author for this post.
    #243602

    Dove hai scritto “PipValue * 5”, probabilmente volevi scrivere “PipSize * 5”.

     

    1 user thanked author for this post.
    #243609

    Non credevo che fosse da definire; si esatto ho fatto un altro errore invece di scrivere PipSize ho scritto PipValue.

    Grazie e buon weekend

Viewing 4 posts - 1 through 4 (of 4 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login