Chiusura a tempo dopo x giorni

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #232333 quote
    Gabriele BattistaGabriele Battista
    Participant
    Senior

    Vorrei poter uscire dal trade in ogni coso dopo x (es. 3 ) giorni. Grazie

    #232344 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Eccolo:

    DEFPARAM CUMULATEORDERS = False
    ONCE GiorniMax = 3     //Esci dopo 3 giorni
    ONCE Giorni    = 0
    IF (OpenDay <> OpenDay[1]) AND OnMarket THEN
       Giorni = Giorni + 1
    ENDIF
    IF OnMarket AND (Giorni = GiorniMax) THEN
       SELL      AT MARKET
       EXITSHORT AT MARKET
    ENDIF
    MieCondizioniLong  = close CROSSES OVER  Average[20,0](close)
    MieCondizioniShort = close CROSSES UNDER Average[20,0](close)
    IF Not OnMarket THEN
       IF MieCondizioniLong THEN
          BUY 1 Contract AT MARKET
       ELSIF MieCondizioniShort THEN
          SELLSHORT 1 Contract AT MARKET
       ENDIF
       Giorni = 0
    ENDIF
    SET STOP   pLOSS   100
    SET TARGET pPROFIT 200
    //graph Giorni
    #232401 quote
    AragornaAragorna
    Participant
    Average

    Buongiorno roberto, non capisco perchè hai dovuto specificare (OpenDay <> OpenDay[1]).

    inoltre si può scrivere la stessa cosa così?

    If longOnMarket AND (BarIndex – TradeIndex) >= 3 Then
    Sell at Market
    Endif
    If shortOnMarket AND (BarIndex – TradeIndex) >= 3 Then
    Exitshort at Market

     

    nel caso si volesse uscire dopo 3 ore invece che dopo 3 giorni?grazie in anticipo

    Alessio

    #232487 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ho confrontato i due dati di OpenDay, quello corrente con il precedente perché questo indica l’inizio di un nuovo giorno (ho fatto così perché mi hai fatto l’esempio di 3 giorni).

    Per 3 ore sostituisci OpenDay con OpenHour, se vuoi cambia anche i nomi delle variabili per tua maggiore comodità, ma non è necessario ai fini del funzionamento.

    Il tuo esempio è corretto quando desideri uscire dopo 3 barre (non giorni), per cui esci dopo 3 minuti se sei sul grafico a 1 minuto, dopo 3 ore se sei sul grafico orario e dopo 3 giorni se sei sul grafico Giornaliero.

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

Chiusura a tempo dopo x giorni


ProOrder: Trading Automatico & Backtesting

New Reply
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by robertogozzirobertogozzi
2 years, 4 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 05/05/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...