chiude le posizioni alle 00:00

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #165438 quote
    domenicoprorealcode
    Participant
    Junior

    Buona sera,  sto sbagliando qualcosa al codice, grazie infinite a chi mi vorrà aiutare.

    il sistema mi chiude la posizione alle 00:00 del giorno in cui e stata aperta,

    invece io vorrei che il sistema si attiva  dalle 07:00, al momento che la condizione viene eseguita vorrei che la rimane aperta nei giorni seguenti fino al rangiungimento del trailing stop.

    //-------------------------------------------------------------------------
    // Codice principale : LUNEDI
    //-------------------------------------------------------------------------
    // Definizione dei parametri del codice
    DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
    // Il sistema cancellerà tutti gli ordini in attesa e chiuderà tutte le posizioni a 0:00. Dopo l'orario "Flat Before" non saranno piazzati nuovi ordini o posizioni.
    DEFPARAM FLATBEFORE = 070000
    // Cancellare tutti gli ordini in attesa e chiudere tutte le posizioni all'orario "Flat After"
    Otd = (Barindex - TradeIndex(1) > IntradayBarIndex)
    // giorni tradabili specifici della settimana LUNEDI
    daysForbiddenEntry = OpenDayOfWeek = 2 OR OpenDayOfWeek = 3 OR OpenDayOfWeek = 4 OR OpenDayOfWeek = 5 OR OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    indicator1 = SuperTrend[3,10]
    c1 = (close[1] CROSSES OVER indicator1)
    
    
    
    IF c1 AND not daysForbiddenEntry AND Otd AND trailingstart AND trailingstep AND Time < 200000 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    SET STOP PLOSS 680
    //************************************************************************
    //trailing stop function
    trailingstart =250//trailing will start @trailinstart points profit
    trailingstep = 100//trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //************************************************************************
    #165441 quote
    robertogozzi
    Moderator
    Master

    La chiude perché hai scritto

    DEFPARAM FLATBEFORE = 070000

    Quindi puoi aprire un’operazione tra le 07:00 e le 23:59.

    Alle 00:00, essendo un’ora precedente alle 07:00 chiude tutto.

    Basta togliere quella riga.

    Se vuoi iniziare alle 7, scrivi questa riga alla 12:

    cTime = Time >= 070000 snd Time < 200000

    poi sostituisci la riga 18 con

    IF c1 AND not daysForbiddenEntry AND Otd AND cTime AND Not OnMarket THEN

    ho tolto i riferimenti al trailing stop perché non servono a niente, sono sempre condizioni vere.

    #165451 quote
    domenicoprorealcode
    Participant
    Junior

    gentilissimo come sempre Roberto,

    mi da errore allego file

    Desktop-Screenshot-2021.03.26-19.51.57.44.png Desktop-Screenshot-2021.03.26-19.51.57.44.png
    #165453 quote
    robertogozzi
    Moderator
    Master

    l’operatore corretto è AND.

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

chiude le posizioni alle 00:00


ProOrder: Trading Automatico & Backtesting

New Reply
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by robertogozzi
5 years ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 03/26/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...