So here we have bug #396 and it is again one in the category Major. Took me only 1.5 day to find, after seeing that I am (this time virtually only) losing money. Mind you, there would be no way I had discovered this, if I first hadn’t had a reference of something working correctly. And again, am I the only one running into this ?
This will comprise of (at least) two posts. The first (this one) showing the correct situation. After that the wrong situation will be shown. I hope this works out because if something appears incorrect in an earlier post, I can’t change it.
If Not OnMarket or StrategyProfit <> StrategyProfit[1] then // 31-03-2022,PS, Like this. Watch out : works better but is not waterproof to all resets ! 03-07-2022,PS, Commented out the 2nd part for Test.
// Resets.
Gain = 0
HasBeenGain = 0
[...]
GraphOnPrice Close coloured(255,0,0) as "==General Reset==" // 03-07-2022,PS.
Graph StrategyProfit Coloured (255,255,0) As "==StrategyProfit Current==" // 03-07-2022,PS.
Graph StrategyProfit[1] Coloured (200,200,255) As "**StrategyProfit Previous**" // 03-07-2022,PS.
Endif
The above tries tot show the severity of the impact. In other words, if that If fails, resets take place which shouldn’t (or do not take place when they should, but it is not about that).
1st : Shows the bar preceding the Exit.
2nd : Shows the bar at the Exit detection and it shows how StrategyProfit is not equal to StrategyProfit[1]. Thus reset is triggered.
3rd : Shows the first bar of the Not OnMarket situation.
If you’d follow the red line, you will see that preceding this all it is a straight line. No Resets take place while OnMarket. Beyond it, the red line follows the price, hence resets keep on taking place.
What is crucial to let this work correctly, is the chart at a TimeFrame of 1 minute, together with this line of code; mind that the code snippet above is under the scope of this TF command below :
timeframe(1 minute,UpdateOnClose)
4th : Shows the chart setting.
(yes, I know that these labels and (here not visible) order arrows can be shut off, but these are exactly my references of something which works fine)
On a side note and FYI : That check for the changed StrategyProfit is necessary because the Not OnMarket is ambiguous when working with Limit orders. For people at ProRealTime : You may not know it, but there is no decent (or intuitive ?) way to find out “changed position”.