Pause system after 2 losses
Forums › ProRealTime English forum › ProOrder support › Pause system after 2 losses
- This topic has 10 replies, 3 voices, and was last updated 2 years ago by ProRealP.
-
-
07/12/2021 at 12:07 PM #173502
Hello!
I’m trying to add a parameter that won’t allow my system to continue trading after 2 consecutive losses in the same day, but without quitting the system. I’ve copy pasted from a couple of old threads here, but can’t quite get it to work. This is what I’ve “come up with”12345678910111213141516Once TradeON = 1If IntraDayBarIndex = 0 thenTradeON = 1Endifif strategyprofit <> strategyprofit[1] thenif positionperf(1)<0 thenperte=perte+1elseperte=0endifendifif perte >=2 thenTradeON = 0endifDoes anyone know what I’m doing wrong or have any ideas about how to code this?
07/12/2021 at 12:35 PM #17350407/12/2021 at 12:55 PM #173506I’ve added TRADEON to the buy conditions like you show, but it still seems to take more positions then “allowed”. Here is an example, though i reckon it’s not enough to go on. It shouldn’t have taken the position on the 6th at 19.18 with this code, am I right?
07/12/2021 at 2:11 PM #173509You should add this line just after line 3 (before ENDIF):
1perte=0but this has nothing to do with your issue.
It’s a nother issue, since you never reset PERTE at the beginning of a new day, it may happen that you never enter at market again after 2 losses as STERATEGYPROFIT will never change again!
The question you asked is to stop after 2 LOSSES, not after 2 trades.
07/12/2021 at 2:15 PM #173510Your issue is due to using POSITIONPERF instead of STRATEGYPROFIT.
Try this code:
123456789101112131415Once TradeON = 1If IntraDayBarIndex = 0 thenTradeON = 1perte = 0Endifif strategyprofit < strategyprofit[1] thenperte=perte+1elsif strategyprofit > strategyprofit[1] thenperte=0endifif perte =2 thenTradeON = 0endif07/12/2021 at 2:42 PM #173513I believe I understand the logic of your code. Perte is set to 0 at new day and if two losses are recorded then tradeon=0. Makes sense.
But it still takes positions after 2 losses. The positions are exactly the same as with the code I first used.
It’s quite odd because if I change “if perte =2″ then to “if perte =1” it seems to work flawlessly, but then closes after 1 loss..
07/12/2021 at 2:49 PM #17351507/12/2021 at 3:15 PM #173516I think yoy haven’t added TradeON to your conditions to enter a position.
My code works like a charm:12345678910111213141516171819202122232425Once TradeON = 1If IntraDayBarIndex = 0 thenTradeON = 1perte = 0Endifif strategyprofit < strategyprofit[1] thenperte = perte + 1elsif strategyprofit > strategyprofit[1] thenperte=0endifif perte = 2 thenTradeON = 0endifIF close CROSSES OVER average[20] and not onmarket and TradeON THENBUY AT MarketENDIFIF close CROSSES UNDER average[20] and not onmarket and TradeON THENSELLSHORT AT MarketENDIFSET TARGET pPROFIT 100SET STOP pLOSS 50graph perte coloured(255,0,0,255)graph TradeON coloured(0,0,255,255)07/12/2021 at 3:57 PM #17352307/12/2021 at 4:13 PM #17352707/12/2021 at 4:29 PM #173531I was not aware of that. It’s working perfectly now.
Thanks!
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on