chiude le posizioni alle 00:00

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #165438 quote
    domenicoprorealcodedomenicoprorealcode
    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
    robertogozzirobertogozzi
    Moderator
    Legend

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

    l’operatore corretto è AND.

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

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 robertogozzirobertogozzi
5 years, 6 months ago.

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