ORDINI SERALI CON CHIUSURA GIORNO DOPO

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #218970 quote
    MaoRai54
    Participant
    Master

    Buon pomeriggio a tutti,

    sto scrivendo un codice con TF 1M che compra alle 21.59 a certe condizioni e deve vendere il giorno seguente alle ore 9.00 se c’è una condizione, altrimenti non vende a quell’ora ed allora imposto TP e SL.

    non riesco a fargli capire che deve aspettare il giorno dopo, almeno alle ore 9.00, per chiudere la posizione. quindi me la chiude anche di notte quando prende SL o TP

    che comandi devo dare?

    grazie per l’aiuto

    #218974 quote
    MauroPro
    Participant
    Veteran

    Prova una cosa così (è un esempio):

    defParam cumulateOrders = false
    positionSize = 1

    condizioneEntrata = close > average[20]
    condizioneUscita = close < average[50]

    if time = 215900 and condizioneEntrata then
    buy positionSize contracts at market
    endif

    if longOnMarket and time = 090000 and condizioneUscita then
    sell positionSize contracts at market
    elsIf longOnMarket and time > 090000 then
    set stop pLoss 100
    set target pProfit 100
    endif

    #218975 quote
    MaoRai54
    Participant
    Master

    GRAZIE, MA UNA COSA COSI’ L’HO PROVTA IN VARI MODI E IL SITEMA NON ASPETTA LE 9.00 DEL GIORNO DOPO CON GLI SL E TP

    #218976 quote
    MauroPro
    Participant
    Veteran

    Se provi ad azzerare SL e Tp prima delle 9?

     

    defParam cumulateOrders = false
    positionSize = 1

    condizioneEntrata = close > average[20]
    condizioneUscita = close < average[50]

    if time <= 090000 then
    set stop pLoss 0
    set target pProfit 0
    endif
    if time > 090000 then
    set stop pLoss 100
    set target pProfit 100
    endif

    if time = 215900 and condizioneEntrata then
    buy positionSize contracts at market
    endif

    if longOnMarket and time = 090000 and condizioneUscita then
    sell positionSize contracts at market
    endif

    #218982 quote
    robertogozzi
    Moderator
    Master

    Non credo funzioni, perché una volta messo TP e SL dovrebbe proseguire e non toglierlo tra le 0 e le 9 (se l’operazione dura più giorni).

    Meglio toglierli quando NON siamo a mercato (altrimenti restano in memoria):

    if Not OnMarket then
       set stop pLoss 0
       set target pProfit 0
    endif
    #218983 quote
    MauroPro
    Participant
    Veteran

    Ciao Roberto, ho provato il mio codice sul Dax ad 1 minuto e mi sembra ( ho controlato qualche op.) che funzioni, ossia che la strtaegia non esca mai prima delle 9 anche se il TP o SL vengono colpiti nella notte.

    #218984 quote
    MauroPro
    Participant
    Veteran

    Ho controllato meglio. Nel caso di un op che duri più giorni (sono molto rare) il mio codice non fa comunque  mai uscire prima delle 9, rischiando di avere uno stop maggiore di 100.

    E’ anche vero che anche nel caso dell’uscita standard alle 9, lo stop può essere superiore a 100, occorre quindi capire se, passato un giorno, si vogliono mantenere le condizini inziali dell’uscita alle 9, oppure se attivare, dopo un giorno,  il TP – SL nella notte.

    #218986 quote
    robertogozzi
    Moderator
    Master

    Sceglierà MaoRai54 cosa fare, se usare il tuo codice che dalle 000000 toglie nuovamente SL e TP tornando alle condizioni iniziali, oppure usare la mia variazione per lasciare SL e TP una volta messi (riportandoli a zero dopo l’uscita).

    #218991 quote
    MaoRai54
    Participant
    Master

    @Roberto     @MauroPro

    intanto grazie ad entrambi.

    La versione di Roberto non mi funzionerebbe perché alle 21.59 sarei a mercato comunque.

    Quella di MauroPro l’ho leggermente adattata (vedi qui sotto) ed è perfettamente funzionante!!

    if (time=>220000 or time<100000) then
    set stop pLoss 0
    set target pProfit 0
    endif
    if hour=9 and close>CC0 then
    sell at market
    else
    if (hour=>HH and time<215900) then
    set stop pLoss SL
    set target pProfit TP
    endif
    endif

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

ORDINI SERALI CON CHIUSURA GIORNO DOPO


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
MaoRai54 @maorai Participant
Summary

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

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 08/12/2023
Status: Active
Attachments: No files
Logo Logo
Loading...