Is the admin modifying the code on variables?
-
This max daily win/loss counter is working for years in my projects and today suddenly stopped working!

https://fxdreema.com/shared/vgE9nAc8
Variables storing the profit/loss values are not functional. Is the admin touching the code? I need it to work again.
-
For some weird reason the maximum profit/loss value is not reinitialized correctly as per block 15. I tried this on different moments of the day and the value of the last time it was used is 'recovered' from some kind of invisible cache and is added the the current value for open trades. At the same time the maximum loss is never activated! This is very weird...:o
-
@l-andorrà can you isolate the problem into 2-3 blocks without any unnecessary parts in the example? Its difficult to follow the Spanish variables
-
@roar Nice to see someone else asking for isolated examples

@l-andorrà Yesterday I was touching a little bit on the Trade events. Now minutes ago I touched that again. But I don't see how this is related to the variables.
I would also like some isolated project. -
Sure. I'll provide one soon.
-
@fxDreema This is the simplest version I can create for you to understand (I hope) where the issue is.
https://fxdreema.com/shared/F53XQ0Ilb
This is what the structure is doing:
-
Showing on the chart the combined profit/loss of all open trades at the moment. Block 2 and below are doing that and that works fine. No problem there.
-
Showing on the chart the combined profit/loss of all closed trades today. Block 3 and below are doing that and that works fine. No problem there.
-
Showing on the chart the combined profit/loss of all open right now + closed trades today. Block 4 and 13 are doing that and that works fine. No problem there.
-
Showing on the chart the highest profit and today. Blocks 6, 7 and below are doing that that works fine. No problem there.
The problem raises when a new day is reinitiating all those variables to 0. That is what blocks 1 and 15 are for. Some months ago I used a 'once a day' block instead of a 'time filter' and all worked fine. All variables were reinitiated normally until suddenly they didn't. Some days yesterday's highest loss was still visible at the beginning of the trading session. Occasionally it was the highest profit. It was a random result because it didn't happen everyday, but it was a common issue.
I 'fixed' that by using the current time filter version and selecting the first minutes (1 or 2 were enough) of the new trading session you be sure that more than one tick would definitely reinitiate all variables. That worked for some time until I found that the problem still persisted unless I selected at least 10 minutes of the new trading session. Now it simply doesn't work at all.
If you test the structure on backtest it will work for sure every single day. The problem is doing it on demo/real. For some reason variables on block 15 are not correctly reinitiated and today's information simply is not updated.
These are my hypothesis:
-
The info for variables in block 15 are stored somewhere within the fxDreema code and it is not properly deleted.
-
The calculations on blocks 6,7 and below are still executed in the first ticks of the new trading session and yesterday's values are obtained again and not those for today's.
I hope this can be more helpful.
-
-
@l-andorrà in your example there is no time window for resetting those variables. Even if you specify 10 minutes time window, it is not guaranteed that the EA receives a tick and the blocks are updated.
I would make a structure that makes sure the variables are actually reset every day, with 100% certainty.

-
I forgot to add those values when I created the example.
Please imagine I select the period 00:00 to 00:05. The chart the EA is working on is receiving ticks since minute one for the last 15 years (I checked it). -
Try putting a comment block (or Log message) right after the reset block, and comment out all variables. This way you see their values, and also see when the reset happens.
-
Ahem...Didn't you see block number 13 in the link?

-
@l-andorrà block 13 is not directly after the reset, anything can happen between those 2 events.
Its better to use Print() (the "log message" block) because it gives the timestamps so you can be sure the values are updated ones
-
Interesting. But how can I see the values of the variables? They cannot be selected with the 'log message' block'?
-
I think you can right-click and insert the variable, but at this point its probably easier to make a custom string and print it:
string cmt = "";
cmt += " " + "highest_loss: " + highest_loss;
cmt += ", " + "highest_profit: " + highest_profit;
cmt += ", " + "max_profit_was_at: " + max_profit_was_at;
cmt += ", " + "max_loss_was_at: " + max_loss_wat_at;
cmt += ", " + "total_profit: " + total_profit;Print(cmt);


-
I confirm the text is visible as per your example. That means the variables are modified after that. For some reason yesterday's information is stored somewhere and 'recovered' the following day as if it was calculated today. Is there any hidden 'buffer/cache' within any of those blocks, maybe?
-
What do you see in the log? Are the variables 0 or something else?
-
Yes, all of them are 0.
-
I found the proof that there is some kind of 'hidden memory' storing the value beyond the time limit. I tested the structure for 24 hours and I looked at what happened at the day change in front of the chart. I selected a period of two minutes for block 1 to work so I was sure more than one tick was executing that block. Because it was a new day, there were no open trades nor any closed trade. All variables should be 0. Well, the value for the max profit was correctly reinitiated but values for max loss and the hour when that happened were persistent. Those values couldn't be obtained by the calculation structure of block 3 and below because, as I said, there were not any closed trade the new day.
When I tried roar's suggestion I used a 'once a day' block and the log info was correct. However, when I changed it to a 'time filter' as it is now, the problem persists. This means the block is reinitializing the variables correctly but the 'hidden memory' is immediately retaken the stored value.
-
@l-andorrà next step of troubleshooting would be more log blocks - as you have multiple groups of blocks, each group should start with a log message that tells the timestamp and variable values.
-
I will try, but This is becoming more and more weird. Now I see the wrong results are stored 24 hours beyond its max time limit. I left the EA working 'normally' and the second day the wrong results was hold. However, the third day, (ie 48 after the wrong result) variables were correctly reinitiated. The hidden memory is not everlasting so far.
-
@l-andorrà it could be just some weird mechanism with time zones and block execution order. I'm not sure whats the full picture though