Un solo trade al giorno

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #197673 quote
    Gabriele Battista
    Participant
    Senior

    è possibile definire la regola di fare solo il primo trade giornaliero che rispetta le condizioni, o il primo ed il secondo, o il primo e reversare allo stop loss. grazie

    #197684 quote
    MauroPro
    Participant
    Veteran
    Con questo codice di Roberto definisci quante operazioni fare al giorno (basta inserire il numero nella riga 1). Poi nel tuo codice di acquisto/vendita aggiungi: “and tally < maxTrades” –  (lo copio in quanto non funziona insert)  

    once maxTrades = 3           //maxNumberDailyTrades

    once tally = 0

    if intradayBarIndex = 0 then

    tally = 0

    endif

    newTrades = (onMarket and not onMarket[1]) or ((not onMarket and not onMarket[1]) and (strategyProfit <> strategyProfit[1])) or (longOnMarket and ShortOnMarket[1]) or (longOnMarket[1] and shortOnMarket) or ((tradeIndex(1) = tradeIndex(2)) and (barIndex = tradeIndex(1)) and (barIndex > 0) and (strategyProfit = strategyProfit[1]))

    if newTrades then

    tally = tally +1

    endif
    robertogozzi thanked this post
    #203429 quote
    Gabriele Battista
    Participant
    Senior
    Grazie, mancherebbe “primo e reversare allo stop loss”
    #230757 quote
    robertogozzi
    Moderator
    Master
    @Gabriele Battista Non duplicare it tuoi post. Poni la tua domanda solo una volta e solo in un forum. Tutti i doppi post verranno comunque eliminati, quindi pubblicare più volte la stessa domanda ti farà perdere tempo e non ti farà avere una risposta più velocemente. Il doppio post crea solo confusione nei forum. Grazie 🙂 Quindi vuoi fare una sola operazione se è profittevole, mentre sa va in stop vuoi fare il reverse ma sempre solo una volta?
    #230758 quote
    Gabriele Battista
    Participant
    Senior
    Scusa ma l’intenzione non era di duplicare perchè comunque aveva un titolo diverso, in ogni caso si una sola volta se va in SL. in questo caso sarebbe comunque possibile fissare stop e target del reverse?
    #230860 quote
    robertogozzi
    Moderator
    Master
    Eccolo:
    OTD = Barindex - TradeIndex(1) > IntradayBarIndex
    MiaConizioniLong  = close CROSSES OVER  average[20,0](close)
    MiaConizioniShort = close CROSSES UNDER average[20,0](close)
    IF Not OnMarket AND OTD THEN
    IF MiaConizioniLong THEN
    BUY 1 Contract at Market
    ELSIF MiaConizioniShort THEN
    SELLSHORT 1 Contract at Market
    ENDIF
    SET STOP   pLOSS   20
    SET TARGET pPROFIT 20
    Reversed = 0
    ENDIF
    IF (StrategyProfit < StrategyProfit[1]) AND (Reversed = 0) THEN
    Reversed = 1
    IF LongOnMarket[1] THEN
    SELLSHORT 1 Contract at Market
    ELSIF ShortOnMarket[1] THEN
    BUY 1 Contract at Market
    ENDIF
    ENDIF
    //graph Reversed
    //graph OTD coloured("Red")
    Gabriele Battista thanked this post
    #230987 quote
    Gabriele Battista
    Participant
    Senior
    Grazie, così ho stessi SL e TP sia per il trade “diretto” che per il “reverse” dopo lo SL. E’ possibile averli diversi nel reverse? Grazie
    #230995 quote
    robertogozzi
    Moderator
    Master
    Si, basta fare un paio di modifche:
    OTD = Barindex - TradeIndex(1) > IntradayBarIndex
    MiaConizioniLong  = close CROSSES OVER  average[20,0](close)
    MiaConizioniShort = close CROSSES UNDER average[20,0](close)
    IF Not OnMarket AND OTD THEN
    IF MiaConizioniLong THEN
    BUY 1 Contract at Market
    ELSIF MiaConizioniShort THEN
    SELLSHORT 1 Contract at Market
    ENDIF
    SET STOP   pLOSS   20
    SET TARGET pPROFIT 20
    Reversed = 0
    ENDIF
    IF (StrategyProfit < StrategyProfit[1]) AND (Reversed = 0) THEN
    Reversed = 1
    IF LongOnMarket[1] THEN
    SELLSHORT 1 Contract at Market
    ELSIF ShortOnMarket[1] THEN
    BUY 1 Contract at Market
    ENDIF
    SET STOP   pLOSS   30
    SET TARGET pPROFIT 30
    ENDIF
    //graph Reversed
    //graph OTD coloured("Red")
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Un solo trade al giorno


ProOrder: Trading Automatico & Backtesting

New Reply
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by robertogozzi
1 year, 10 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 07/22/2022
Status: Active
Attachments: No files
Logo Logo
Loading...