STOP TRADE EN COURS SI

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

    Bonjour, j’aimerai cloturer ma journée si mes gains ont atteint X€, avez vous une idée de code.

    Par avance merci,

    #249248 quote
    RICOU
    Participant
    New

    Et dans le même ordre d’idée, cloturer ma journée à partir de 2 trades négatifs.

    Merci

    #249249 quote
    robertogozzi
    Moderator
    Master

    Voilà:

    DEFPARAM CumulateOrders = False
    ONCE TradeON    = 1
    ONCE myProfit   = 0
    ONCE MaxProfits = 200
    IF IntradayBarIndex = 0 THEN
       // Définissez à nouveau la variable TradeON pour redémarrer le trading chaque nouveau jour.
       TradeON  = 1
       myProfit = 0
    ELSE
       // Mettre à jour le bénéfice (ou la perte) temporaire
       myprofit = myProfit + (StrategyProfit - StrategyProfit[1])
    ENDIF
    // Si le profit est >= N, arrêtez le trading jusqu'au lendemain
    IF myProfit >= MaxProfits THEN
       TradeON = 0
    ENDIF
    // Indicateurs et conditions d'entrée en Long ou en Short
    Sma          = average[20,0](close)
    BullishCross = close CROSSES OVER  Sma
    BearishCross = close CROSSES UNDER Sma
    IF Not OnMarket AND TradeON THEN
       IF BullishCross THEN
          BUY 1 Contract at Market
       ELSIF BearishCross THEN
          SELLSHORT 1 Contract at Market
       ENDIF
       SET STOP   %LOSS   0.5
       SET TARGET %PROFIT 0.5
    ENDIF
    // Debugging data
    graph TradeON                coloured("Green")
    graph myProfit >= MaxProfits coloured("Red")
    Iván González thanked this post
    #249251 quote
    robertogozzi
    Moderator
    Master

    J’ai vu votre deuxième message tard, voici le code modifié :

    DEFPARAM CumulateOrders = False
    ONCE TradeON     = 1
    ONCE myProfit    = 0
    ONCE MaxProfits  = 200
    ONCE Negative    = 0
    ONCE MaxNegative = 2
    ONCE TradeON = 0 = 2
    IF IntradayBarIndex = 0 THEN
       // Définissez à nouveau la variable TradeON pour redémarrer le trading chaque nouveau jour.
       TradeON  = 1
       myProfit = 0
       Negative = 0
    ELSE
       // Mettre à jour le bénéfice (ou la perte) temporaire
       myprofit = myProfit + (StrategyProfit - StrategyProfit[1])
    ENDIF
    // Si le profit est >= N, arrêtez le trading jusqu'au lendemain
    IF myProfit >= MaxProfits THEN
       TradeON = 0
    ELSIF (StrategyProfit - StrategyProfit[1]) < 0 THEN
       // Si les pertes sont >= MaxNegative, arrêtez de trader jusqu'au lendemain
       Negative = Negative + 1
       IF Negative >= MaxNegative THEN
          TradeON = 0
       ENDIF
    ENDIF
    // Indicateurs et conditions d'entrée en Long ou en Short
    Sma          = average[20,0](close)
    BullishCross = close CROSSES OVER  Sma
    BearishCross = close CROSSES UNDER Sma
    IF Not OnMarket AND TradeON THEN
       IF BullishCross THEN
          BUY 1 Contract at Market
       ELSIF BearishCross THEN
          SELLSHORT 1 Contract at Market
       ENDIF
       SET STOP   %LOSS   0.5
       SET TARGET %PROFIT 0.5
    ENDIF
    // Debugging data
    graph TradeON                coloured("Green")
    graph myProfit >= MaxProfits coloured("Red")
    Iván González thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

STOP TRADE EN COURS SI


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
RICOU @ricou Participant
Summary

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

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 08/01/2025
Status: Active
Attachments: No files
Logo Logo
Loading...