EXIT STRATEGY CONDIZIONATA

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #225859 quote
    Renzo
    Participant
    New

    Buonasera,

    avrei bisogno di aiuto per quanto segue.

    Vorrei impostare una exit strategy, per esempio da una strategia long, al verificarsi di talune condizioni che devono riguardare separatamente ciascuna candela a partire da quella di ingresso:

    Per esempio:

    • una volta comprato il titolo, vorrei impostare un take profit ed uno stop loss che vale solo per la candela di ingresso;
    • a seguire… vorrei impostare un take profit ed uno stop loss che vale solo per la 1^ candela successiva a quella di ingresso;
    • a seguire … vorrei impostare un take profit ed uno stop loss che vale solo per la 2^ candela successiva a quella di ingresso;
    • ….

    Avevo provato con questo codice, ma credo sia errato:

    IF LONGONMARKET AND (TRADEINDEX + 1) AND CLOSE => CLOSE [1] THEN

    SET TARGET $PROFIT 600

    SET STOP $LOSS 200

    ENDIF

    • Alla 10^ candela, il sistema forzerà la chiusura della strategia (di seguito il codice che credo corretto):

    IF LONGONMARKET AND (BarIndex – TRADEINDEX) = 11 THEN

    SELL 1 share AT MARKET

    ENDIF

    Grazie in anticipo e colgo l’occasione per augurare felice 2024.

    Oronzo

    #225881 quote
    robertogozzi
    Moderator
    Master
    Grazie e auguri ancghe a te. Quanto prima cercherò di codificare quanto hai chiesto.
    #225967 quote
    robertogozzi
    Moderator
    Master
    Prova questo:
    IF BarIndex = 0 THEN
       SL = 200
       FOR i = 1 TO 10
          $sl[i] = SL
          $tp[i] = $sl[i] * 2
          SL     = SL - 10*PipSize
       NEXT
    ENDIF
    Bull3 = summation[3](close > open) = 3
    MieCondizioniLong = close CROSSES OVER average[20,0](close) AND Bull3
    IF MieCondizioniLong AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
       SET TARGET pPROFIT $tp[1]
       SET STOP   pLOSS   $sl[1]
    ENDIF
    IF OnMarket THEN
       SET TARGET pPROFIT $tp[(BarIndex - TradeIndex) + 1]
       SET STOP   pLOSS   $sl[(BarIndex - TradeIndex) + 1]
    ENDIF
    IF Onmarket AND ((BarIndex - TradeIndex) + 1) > 10 THEN
       SELL AT MARKET
    ENDIF
    #225973 quote
    Renzo
    Participant
    New
    Grazie mille Roberto!!!
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

EXIT STRATEGY CONDIZIONATA


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Renzo @oronzo-gonnella Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Renzo
2 years, 1 month ago.

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