Dernier trade cloturé par 1 STOP

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #242217 quote
    4801
    Participant
    Junior

    Bonjour à tous et bonne année 2025.

    J’ utilise en fin de code : SET STOP PLOSS 100 , afin de limiter mes pertes à 100. Si mon trade est ainsi clôturé par 1 ordre STOP, je souhaite ouvrir une nouvelle position

    seulement en sens contraire du trade précédent clôturé par 1 STOP. Quel code doit-on écrire pour :  ” le dernier trade a été cloturé par 1 ordre STOP “

    J’ ai cherché un peu partout sans succès et vous remercie pour votre aide .

    #242225 quote
    robertogozzi
    Moderator
    Master

    Voici le code :

    ONCE TradeLong   = 1
    ONCE TradeShort  = 1
    ONCE LongFlag    = 0
    ONCE ShortFlag   = 0
    Sma20            = average[20,0](close)
    // check whether the closed trade was a Loss or a Win
    IF StrategyProfit < StrategyProfit[1] THEN
       // If it's a loss, then only trade the opposite direction next time
       IF LongFlag  THEN
          TradeLong  = 0
          TradeShort = 1
       ELSIF ShortFlag THEN
          TradeLong  = 1
          TradeShort = 0
       ENDIF
    ELSIF StrategyProfit > StrategyProfit[1] THEN
       // If it's a win, then trade any direction
       TradeLong     = 1
       TradeShort    = 1
    ENDIF
    // Entry
    IF Not OnMarket THEN
       LongFlag      = 0
       ShortFlag     = 0
       IF close CROSSES OVER  Sma20 AND TradeLong THEN
          BUY 1 Contract at Market
          LongFlag   = 1
       ELSIF close CROSSES UNDER Sma20 AND TradeShort THEN
          SELLSHORT 1 Contract at Market
          ShortFlag  = 1
       ENDIF
    ENDIF
    SET STOP   pLOSS   100
    SET TARGET pPROFIT 200
    Iván González thanked this post
    #242331 quote
    4801
    Participant
    Junior

    Bonjour Roberto,

    Un grand merci pour votre aide . Le code que vous avez écrit est Top, cela fonctionne très bien. J’ ai mis un peu de temps à vous répondre suite une  grippe.

    Bonne journée.

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

Dernier trade cloturé par 1 STOP


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
4801 @4801 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by 4801
1 year, 1 month ago.

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