Inserimento chiusura venerdì e chiusura tot barre

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #194429 quote
    Mauro M
    Participant
    New

    salve sono nuovissimo sia della programmazione che de forum.

    Ho bisogno di un aiuto…

    vorrei inserire nel code che (inserirò qua sotto )queste peculiarità.

    vorrei che il sistema  mi chiudesse le operazioni dopo un tot di barre ad esempio 2  con chiusura alle ore 19 . inoltre cosa fondamentale se il sistema avesse operazioni attive anche se non sono passate le 2 barre chiude tutto venerdi alle ore 19.

    Grazie a chi mi vorrà aiutare.

    DEFPARAM CumulateOrders=True
    NTICK = 0
    N2TICK = 0

    Xpuntistop = 20

    //Long entry
    if Close < Open then
    buy 1 shares at High + Ntick stop
    endif
    //Stop dinamico sul minimo meno n tick
    If LongOnMarket then
    sell 1 share at Low – N2tick stop
    Endif
    //stop loss massimo in punti dal prezzo ingresso
    if LongOnMarket then
    sell 1 share at PositionPrice -xpuntistop stop
    endif

    //Short entry
    if Close > Open then
    sellshort 1 shares at Low – N2tick stop
    endif
    //Stop dinamico sul minimo meno n tick
    If ShortOnMarket then
    exitshort 1 share at Low – N2tick stop
    endif
    //stop loss massimo in punti dal prezzo ingresso
    if ShortOnMarket then
    exitshort 1 share at PositionPrice +xpuntistop stop
    endif

    Set Stop %Loss 10 //as insurance
    Set Target %profit 2.75 //target

    #194442 quote
    robertogozzi
    Moderator
    Master

    Scusami cosa intendi con “chiudesse le operazioni dopo un tot di barre ad esempio 2 con chiusura alle ore 19” ? Vuoi dire che se passano più di 2 barre deve chiudere, ma solo alle ore 19? (quindi se alle 16 sono già passate 2 barre deve attendere le 19?

    Per la chiusura del Venerdì, questo è chiaro.

    #194452 quote
    Mauro M
    Participant
    New

    Per prima cosa la ringrazio del suo interessamento .

    Se oggi entro facciamo finta che il sistema sia giornaliero. Questa entrata se non vengo stoppato e se non raggiungo il mio target la consideriamo barra nr 1. Domani il mio sistema é ancora dentro consideriamo barra 2 e anche qui non raggiunge stop e profit. Alle 19 di questo giorno barra 2 il sistema chiude l’operazione .

    Se fosse possibile il nr di barre vorrei se fosse una variabile. Mi scuso fin d’ora se non mi esprimo in termini a voi comprensibile. Ma sono realmente alle prime armi nella programmazione .

    #194460 quote
    robertogozzi
    Moderator
    Master

    Ho capito, Venerdì lo farò.

    #194571 quote
    Mauro M
    Participant
    New

    Ok la ringrazio

    #194582 quote
    robertogozzi
    Moderator
    Master

    Eccolo (all’inizio ci sono le due variabili, una per il numero di barre e l’altra per l’orario di chiusura):

    DEFPARAM CumulateOrders=false//True
    Timeframe(Daily,UpdateOnClose)
    ONCE NumeroBarre = 2
    ONCE Chiusura    = 190000
    NTICK = 0
    N2TICK = 0
    
    Xpuntistop = 20
    
    //Long entry
    if Close < Open then
    buy 1 shares at High + Ntick stop
    endif
    //Stop dinamico sul minimo meno n tick
    If LongOnMarket then
    sell 1 share at Low - N2tick stop
    Endif
    //stop loss massimo in punti dal prezzo ingresso
    if LongOnMarket then
    sell 1 share at PositionPrice -xpuntistop stop
    endif
    
    //Short entry
    if Close > Open then
    sellshort 1 shares at Low - N2tick stop
    endif
    //Stop dinamico sul minimo meno n tick
    If ShortOnMarket then
    exitshort 1 share at Low - N2tick stop
    endif
    //stop loss massimo in punti dal prezzo ingresso
    if ShortOnMarket then
    exitshort 1 share at PositionPrice +xpuntistop stop
    endif
    
    Set Stop   %Loss   10   //as insurance
    Set Target %profit 2.75 //target
    //
    TimeFrame(default)
    ONCE Barra = 0
    IF Not OnMarket THEN
    Barra = 0
    ELSIF (OnMarket AND Not OnMarket[1]) OR (ShortOnMarket AND LongOnMarket[1]) OR (ShortOnMarket[1] AND LongOnMarket) THEN
    Barra = 1
    ELSE
    IF InTradayBarIndex = 0 THEN
    Barra = Barra + 1
    ENDIF
    ENDIF
    IF (Barra >= NumeroBarre) AND (Time >= Chiusura) THEN
    SELL      at Market
    EXITSHORT at Market
    ENDIF
    //
    //graph Barra

    Deve essere usato su un time frame intraday, meglio se con la candela che chiude alle 190000 (se è un 4 ore, la chiusura non potrà avvenire alle 190000, ma alle 210000).

    #194590 quote
    Mauro M
    Participant
    New

     

    La ringrazio…ma se invece volessi fare lanciare il sistema su un daily. E volessi che questose  non raggiungie il target chiudi le operazioni dopo il giorno successivo all’entrata e comunque chiude tutte le operazioni venerdi a chiusura. Come sarebbe il codice? Mi chiedo solo una cosa, non centra con la programmazione, ma chiudendo a fine giornata si incappa su spread più  larghi . Inoltre quando chiude negli ultimi secondi?

    #194591 quote
    robertogozzi
    Moderator
    Master

    Quando viene dato l’ordine di chiusura il Venerdì sera il mercato è chiuso, quindi l’ordine verrà eseguito alla riapertura ed al prezzo di apertura, qualunque sia,

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

Inserimento chiusura venerdì e chiusura tot barre


Supporto ProBuilder

New Reply
Author
author-avatar
Mauro M @mauro-m Participant
Summary

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

Topic Details
Forum: Supporto ProBuilder
Language: Italian
Started: 06/01/2022
Status: Active
Attachments: No files
Logo Logo
Loading...