The next day trade if it gets 3 stoplosses in a row

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

    Hello. is there a code that makes it not place any more orders if it makes 3 losing trades in a row through stop loss on the same day. I want it to start again after the next day.

    #226905 quote
    robertogozzi
    Moderator
    Master

    There you go:

    ONCE TradeON = 1
    ONCE SLtally = 0
    ONCE SLhit   = 0
    IF IntraDayBarIndex = 0 THEN
       TradeON = 1
       SLtally = 0
       SLhit   = 0
    ENDIF
    // check if a trade was profitable or not, then stop trading after 3 consecutive losses
    IF StrategyProfit > StrategyProfit[1] THEN
       SLhit   = 0
       SLtally = 0
       TradeON = 1
    ELSIF StrategyProfit < StrategyProfit[1] THEN
       SLhit = SLhit + 1
       IF SLhit = 3 THEN
          TradeON = 0
       ENDIF
    ENDIF
    Sma               = average[20,0](close)
    MyLongConditions  = Not OnMarket AND close CROSSES OVER  Sma AND TradeON
    MyShortConditions = Not OnMarket AND close CROSSES UNDER Sma AND TradeON
    IF MyLongConditions THEN
    BUY 1 CONTRACT AT MARKET
    ELSIF MyShortConditions THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    SET STOP   pLOSS   10
    SET TARGET pPROFIT 20
    //graph SLhit
    //graph TradeON coloured("Red")
    #226916 quote
    kvacksa87
    Participant
    Junior

    Thanks for the quick response as usual

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

The next day trade if it gets 3 stoplosses in a row


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
kvacksa87 @kvacksa87 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by kvacksa87
2 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/24/2024
Status: Active
Attachments: No files
Logo Logo
Loading...