Trading Range Iniziale

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #243591 quote
    ReneroRenero
    Participant
    New

    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 quote
    robertogozzirobertogozzi
    Moderator
    Legend

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

    Iván González thanked this post
    #243602 quote
    robertogozzirobertogozzi
    Moderator
    Legend

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

    Iván González thanked this post
    #243609 quote
    ReneroRenero
    Participant
    New

    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)
  • 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

Trading Range Iniziale


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Renero @renero Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by ReneroRenero
1 year, 7 months ago.

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