Box time e target

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #231341 quote
    Edisone
    Participant
    Average

    Salve chiedo aiuto per completare il codice.

    TF basso es. 3 minuti, future es. NQ

    Considero il massimo e il minimo di un box che va dalle 14.30 alle 15.30 (es. max=2000, min=1000).

    1 condizione:  il prezzo dopo le 15.30 deve andare oltre il massimo del box (> 2000)

    2 condizione: il prezzo successivamente (ma entro le 1600) devi scendere (< 2000)

    L’ingresso short (con 2 contratti) è all’incrocio del massimo del box cioè al tocco del valore 2000 quando lo ritesterà.

    1 exit: 1 contratto alla remunerazione del rischio

    2 exit: ultimo contratto al tocco del minimo del box (1000)

    Allego immagine.

    Grazie mille.

     

     

    //TF 3 minuti  - Future es. NQ
    
    DEFPARAM CumulateOrders = False 
    
    Time1 = 143001 // BOX open time
    Time2 = 153000 // BOX close time
    
    // Disegna Box
    TIMEFRAME(default)
    IF (Time = Time1) OR ((Time > Time1) AND (Time[1] < Time1)) THEN
    Bar1 = barindex
    hh   = high
    ll   = low
    ENDIF
    hh = max(hh,high)
    ll = min(ll,low)
    IF (Time = Time2) OR ((Time > Time2) AND (Time[1] < Time2)) THEN
    Bar2 = BarIndex
    ENDIF
    IF Bar2 > Bar1 THEN
    upper= hh
    lower =ll
    Bar2 = 0
    ENDIF
    
    // SHORT
    //Entrata
    IF (time >= time2 and time <= 160000) AND (Not LongOnMarket) AND (close[1] > upper) AND (close  CROSSES UNDER upper)  THEN
    SELLSHORT AT MARKET 
    ENDIF
    
    IF (low crosses under lower) AND LongOnMarket THEN
    BUY  AT MARKET
    ENDIF
    #231454 quote
    Iván González
    Moderator
    Master

    Salve Ecco una prima approssimazione. Non c’è limite al numero di volte in cui si entra ogni giorno, né al numero di barre del mercato. Il resto lo lascio a voi 🙂

    defparam cumulateorders=false
    //TF 3 minuti  - Future es. NQ
    Time1 = 143001 // BOX open time
    Time2 = 153000 // BOX close time
    // Disegna Box
    once bar1=0
    once bar2=0
    IF (Time = Time1) OR ((Time > Time1) AND (Time[1] < Time1)) THEN
    Bar1 = barindex
    hh   = high
    ll   = low
    ENDIF
    hh = max(hh,high)
    ll = min(ll,low)
    IF (Time = Time2) OR ((Time > Time2) AND (Time[1] < Time2)) THEN
    Bar2 = BarIndex
    ENDIF
    IF Bar2 > Bar1 THEN
    upper= hh
    lower =ll
    Bar2 = 0
    ENDIF
    
    if (time >= time2 and time <= 160000) then
    n=n+1
    else
    n=0
    endif
    
    IF (time >= time2 and time <= 160000) AND not onmarket AND (close > upper)   THEN
    stoplevel=highest[n](high)
    sellshort 2 contract at upper stop
    set stop price stoplevel
    set target price lower
    endif
    
    if shortonmarket and COUNTOFPOSITION=-2 then
    x=stoplevel-tradeprice
    firstexit = tradeprice-x
    exitshort 1 contract at firstexit limit
    set target price lower
    endif
    
    graphonprice upper as "Upper Level"
    graphonprice lower as "Lower Level"coloured("Green")
    graphonprice firstexit as "FirstExit"coloured("blue")
    graphonprice stoplevel as "StopLoss" coloured ("red")
    Edisone thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Box time e target


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Edisone @edisone Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván González
1 year, 10 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 04/10/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...