entrata sul minimo/massimo del range

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

    Sto cercando di settare il codice per fare in modo che

    il DAX
    dopo l’apertura delle ore 9.00 ed entro le 9.30
    una volta che il range (differenza minimo massimo in corso) sia di 24 punti
    entri
    in acquisto sul minimo del range
    oppure
    in vendita sul massimo del range

    e che poi non inserisca altri ordini

    il problema è che invece nel backtest
    l’entrata risulta sempre sul minimo o massimo della candela
    e non del range che considero, qualsiasi timeframe

    posto il codice che ho scritto
    come faccio a correggerlo ? finora non mi sono stati di aiuto i post che mi sembravano trattare la stessa impostazione

    grazie

    defparam cumulateorders=false
    
    IF time >= 090000 AND time =< 093000 and HIGH - LOW = 24 * pipsize AND close = low THEN
    BUY 1 CONTRACT LIMIT
    
    
    ELSIF time >= 090000 AND time =< 093000 AND HIGH - LOW = 24 * pipsize AND close = high THEN
    SELLSHORT 1 CONTRACT LIMIT
    
    ENDIF
    
    #233127 quote
    robertogozzi
    Moderator
    Master

    Eccolo:

    defparam cumulateorders=false
    IF IntraDayBarIndex = 0 THEN
       HH = 0
       LL = 0
    ENDIF
    OTD = Barindex - TradeIndex(1) > IntradayBarIndex  //Una sola operazione al giorno (One Trade per Day)
    IF time >= 090000 AND time =< 093000 and OTD THEN
       IF LL = 0 THEN
          LL = low
       ENDIF
       HH = max(HH,high)
       LL = min(LL,low)
       myRange = HH - LL
       IF close > LL and myRange >= 24 THEN
          BUY 1 CONTRACT AT LL LIMIT
       ELSIF close < HH and myRange >= 24 THEN
          SELLSHORT 1 CONTRACT at HH LIMIT
       ENDIF
       SET TARGET PROFIT myRange * 2
       SET STOP   LOSS   myRange
    ENDIF
    //graphonprice HH coloured("Blue")
    //graphonprice LL coloured("Red")
    //graph OTD
    Iván González thanked this post
    #233129 quote
    robertogozzi
    Moderator
    Master

    Questo è più corretto nel piazzare gli ordini:

    defparam cumulateorders=false
    IF IntraDayBarIndex = 0 THEN
       HH = 0
       LL = 0
    ENDIF
    OTD = Barindex - TradeIndex(1) > IntradayBarIndex  //Una sola operazione al giorno (One Trade per Day)
    IF time >= 090000 AND time =< 093000 AND OTD THEN
       IF LL = 0 THEN
          LL = low
       ENDIF
       HH = max(HH,high)
       LL = min(LL,low)
       myRange = HH - LL
       IF close > LL AND myRange >= 24 THEN
          BUY 1 CONTRACT AT LL LIMIT
       ENDIF
       IF close < HH AND myRange >= 24 THEN
          SELLSHORT 1 CONTRACT at HH LIMIT
       ENDIF
       SET TARGET PROFIT myRange * 2
       SET STOP   LOSS   myRange
    ENDIF
    //graphonprice HH coloured("Blue")
    //graphonprice LL coloured("Red")
    //graph OTD
    #233253 quote
    lorenzo33
    Participant
    New

    Grazie mille

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

entrata sul minimo/massimo del range


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
lorenzo33 @lorenzo33 Participant
Summary

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

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 05/27/2024
Status: Active
Attachments: No files
Logo Logo
Loading...