limitare il numero di operazioni giornaliere

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #61145 quote
    gothicdream
    Participant
    Junior

    salve, vorrei sapere come fare per dire al ts di fare al massimo 2 operazioni al giorno, ignorando i segnali successivi.

    qualcuno può aiutarmi?

    grazie

    #61147 quote
    maximus78
    Participant
    Senior

    Ciao, ti faccio un esempio su trades long,

    poi lo aggiusti tu con le tue condizioni e se vuoi aggiungi anche la versione per lo short.

    Max

    defparam cumulateorders=false
    Entrata=mie condizioni
    Uscita=mie condizioni
    
    if intradaybarindex = 0 then
    countposition=0
    endif
    
    condperday=countposition < 3
    
    if not longonmarket and Entrata and condperday then
    buy 1 shares at market
    countposition=countposition+1
    endif
    
    if longonmarket and Uscita then
    sell at market
    endif
    robertogozzi, Juan Salas and gothicdream thanked this post
    #61149 quote
    gothicdream
    Participant
    Junior

    grazie 1000!!

    #61502 quote
    gothicdream
    Participant
    Junior

    maximus78 approfitto ancora di te se posso…

    vorrei inserire in un sistema un’operazione aggiuntiva nel caso la posizione aperta sia in perdita ad esempio di 20 pips, ma non riesco..

    ho scritto:

    IF condizione1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF

    e fino a qua funziona tutto. poi:

    if longonmarket and close<(tradeprice-pointsize*20) then
    BUY 1 CONTRACT at market
    endif

    ma qua non funziona… ho provato anche a mettere DEFPARAM CumulateOrders = true, ma così non va bene perché apre più posizioni in base alla condizione1.

    e poi dovrei scrivere la condizione di chiusura in modo che chiuda entrambe le posizioni long aperte.

    avresti un suggerimento?

    grazie!

    #61524 quote
    Nicolas
    Keymaster
    Master

    Per evitare di aggiungere più posizioni in base alla condizione1, prova solo se sei già sul mercato o no:

    IF condizione1 and NOT ONMARKET THEN
     BUY 1 CONTRACT AT MARKET
    ENDIF

    A proposito di aggiungere più posizioni se il prezzo diminuisce, il codice dovrebbe funzionare se si consente di accumulare ordini.
    Quando stai chiudendo le posizioni, sono tutte chiuse, quindi non preoccuparti di sapere come chiuderle tutte in una volta. Solo “SELL AT MARKET”

    gothicdream thanked this post
    #61567 quote
    gothicdream
    Participant
    Junior

    grazie, non ci avevo pensato… sto imparando!!

    #61571 quote
    gothicdream
    Participant
    Junior

    un’altra domanda.. c’è un modo per fermare il backtest per alcuni giorni e poi riprenderlo?

    ad esempio: chiudi tutte le posizioni il 22 giugno 2016 e riparti il 4 luglio 2016, oppure chiudi tutte le posizioni il 23 dicembre 2016 e riparti il 7 gennaio 2017.

    se uso la funzione “quit” il sistema si ferma e poi non riparte più.

    #61629 quote
    maximus78
    Participant
    Senior

    Ciao Gothic, ti ho fatto un esempio con entrambe le situazioni:

    Compra con un buy limit quando la posizione è sotto di 10 pips da tradeprice e sei già a mercato, ho messo anche uno stop loss fisso di 20 pips ed un take profit di 50 pips.

    Per sospendere il sistema dal 1° luglio fino al 30 novembre per esempio puoi impostare una variabile  trading=0, (cioè falso) in questo modo non effettua trades in quel lasso di tempo.

    Per impostare una variabile falsa, devi impostare una variabile vera, cioè trading=1 che si riferisce alle condizioni di entrata, in questo caso la nostra c1.

    C2 agisce come ordine limite di acquisto solo sei già a mercato con C1 (if onmarket).

     

    defparam cumulateorders = true
    c1=close>highest[10](high)[1]
    c2=tradeprice-(pointsize*10)
    
    if c1 then
    trading=1
    endif
    if date >=20170701 and date<=20171130 then
    trading=0
    endif
    
    if not onmarket and trading=1 then
    buy 1 contracts at market
    set stop ploss 20
    set target pprofit 50
    endif
    
    if onmarket then
    buy 1 contracts at c2 limit
    set stop ploss 20
    set target pprofit 50
    endif
    
    graph (tradeprice-(pointsize*10)) as "buylimit"
    gothicdream thanked this post
    #61674 quote
    gothicdream
    Participant
    Junior

    ciao! avevo già costruito un indicatore che evitasse l’operatività in certe date, e infatti mi dà lo stesso risultato di quello che hai scritto tu (e per i backtest di sistemi intraday è sufficiente), ma io cercavo qualcosa che in più chiudesse tutte le operazioni aperte appena prima dell’attivazione del periodo flat. Mi serve per il multiday. Che tu sappia è possibile?

    #61676 quote
    robertogozzi
    Moderator
    Master

    Ho spostato il topic da ProBuilder a ProOrder, trattandosi di una strategia.

    Basta che tra la riga 8 e la 9 aggiungi queste, che ti chiudono tutte le operazioni eventualemte in corso, Long o Short, in profitto o in perdita che siano:

    IF OnMarket THEN
       SELL AT MARKET
       EXITSHORT AT MARKET
    ENDIF
    maximus78 and gothicdream thanked this post
    #61708 quote
    gothicdream
    Participant
    Junior

    perfetto, grazie!!

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

limitare il numero di operazioni giornaliere


ProOrder: Trading Automatico & Backtesting

New Reply
Author
Summary

This topic contains 10 replies,
has 4 voices, and was last updated by gothicdream
8 years ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 01/31/2018
Status: Active
Attachments: No files
Logo Logo
Loading...