Strategyprofit Bug (doesnt work when in negative)
Forums › ProRealTime English forum › ProOrder support › Strategyprofit Bug (doesnt work when in negative)
- This topic has 11 replies, 4 voices, and was last updated 1 year ago by Amin1233.
-
-
06/27/2022 at 1:35 PM #196211TadeOK conditions123456789ONCE TradeOK = 1ONCE MyLimit = 300IF time = 100000 THENTradeOK = 1Myprofit=strategyprofitENDIFIF (Myprofit- strategyprofit) >= MyLimit THENTradeOK = 0ENDIF
Hi I have been having this issue for a longtime. The result from backtest does not match the actual performance.
I have the below code where if the Strategy profit from 10:00 am fall below 300 I would like to stop orders for the rest of the day.
It works perfectly in the probacktest but as you can see in the below pictures: the backtest does not place order however in the reality it has placed an order.
In the picture with the extra order (that happened in the real market) Ihave just initiated the strategy so the “myprofit” from yesterday was “0” and when the first order is closed in loss the strategyprofit become negative and the formula will be “0- (-400) = 400 which is bigger than 300 and the system should stop for the day. My theory is that there is a bug in the Prorealtime that where the startegy profit turns negative the formula doesnot work.
06/27/2022 at 2:22 PM #196215123456789101112131415ONCE TradeOK = 1ONCE MyLimit = 300IF time = 100000 THENTradeOK = 1Myprofit=strategyprofit // E.g. -500.ENDIF// Now x bars later you lost two trades and StrategyProfit = -700.IF (Myprofit- strategyprofit) >= MyLimit THEN// IF -700 >= -500 then // This returns False.TradeOK = 0 // So TradeOK remains 1.ENDIF// And this is what you would be having for a long time. :-)Amin, If you try to read my comments say 5 times, you are sure I am right but that something must be wrong with my thinking. Still I am right so your code is wrong. 🙂
Next you might be set on the wrong foot because the backtest shows that it works. But this does not tell much without the proof that the backtest did not perform other trades in advance of what you showed.At the bottom of your code add this line :
1Graph StrategyProfitAnd you will see where it goes off, if so. Thus, I was not saying that your statement is wrong. Only that your code is (unless I just see it wrongly).
Additionally, it looks like you add position underway. That is a good recipe to not understand what’s happening. *And* mind you please, backtest report data deals differently with that than Live (or Demo-Live). So this confuses (just look at the number of bars of the 2nd trade and how that reports).
06/27/2022 at 3:14 PM #196221Hi Peter
Thanks for your reply , This is what happened today:
ONCE TradeOK = 1
ONCE MyLimit = 300
IF time = 100000 THEN
TradeOK = 1
Myprofit=strategyprofit // Today = 0
ENDIF// Now x bars later you lost one trade and StrategyProfit = -400.
IF (Myprofit- strategyprofit) >= MyLimit THEN
// IF 0 -(-400) >300 then // This should return true. TradeOK = 0 // So TradeOK should be 0 and stop trading.
ENDIFNot sure what you mean in your example.But it returns False in reality . However in the backtest because the strategyprofit was in positive it work correctly.
06/27/2022 at 4:27 PM #196226// IF 0 -(-400) >300 then // This should return true.
I am really sorry, but it doesn’t. -400 is smaller than +300. Not larger (>).
🙂06/27/2022 at 4:33 PM #19622706/27/2022 at 5:22 PM #196229Haha, no … you changed the code (but your last post would be correct).
Even if I could wonder what the PRT language would do with –400 (I have not the best hopes for that turning out to be +400, you are telling the system something quite else :
Suppose we change this
If 0 -(-400) >300
into this
If 0 -(-400-200) > … then this will work out to
If 0- (-600) > …
So all (ad all programming languages) anticipate that. Anticipate because it is done all over the place.
According to you it would work out to something likeIf 0-(+400-200) =
only because you see
0-(-
If I made mistakes or typos somewhere, I blame you. 🙂
I just can’t think in explaining the obvious.06/27/2022 at 5:25 PM #196230Your code seems to work perfectly (tested on DAX, 30-minute TF):
123456789101112131415161718ONCE TradeOK = 1ONCE MyLimit = 300IF time = 100000 THENTradeOK = 1Myprofit=strategyprofitENDIFIF (Myprofit- strategyprofit) >= MyLimit THENTradeOK = 0ENDIFif TradeOK AND close crosses over average[100] and Not OnMarket thenbuy at marketset target pprofit 400set stop ploss 100endifgraph StrategyProfitgraph MyProfitgraph (Myprofit - strategyprofit)graph TradeOK06/27/2022 at 5:34 PM #19623206/27/2022 at 7:44 PM #196234TradeOK12345678910ONCE TradeOK = 1ONCE MyLimit = 300IF time = 100000 THENTradeOK = 1Myprofit=strategyprofitENDIFIF (StrategyProfit - MyProfit) < -MyLimit THENTradeOK = 0ENDIFHi @Amin1233
You can try this:
1 user thanked author for this post.
06/27/2022 at 8:58 PM #19624406/28/2022 at 3:32 AM #19624807/11/2022 at 7:37 AM #197103Hi Peter, I changed it to your code and it didn’t work. Last night it happened again and after loss still opened new position. I also tried simply if strategyprofit<my profit. This one añdo didn’t work. So there is absolutely a bug here .
-
AuthorPosts
Find exclusive trading pro-tools on