Saving Variables?

4 replies

glennc

Subscriber, bbp_participant, community, 3 replies.

Visit profile

6 years ago #191812

I’m trying to keep a running total of profit/loss over a series of trades, using the ‘assign variable’ function.
So after a trade has closed eg BarsSinceOrderClosed (magicNo.) = 1,
then assign variable ‘RunningTotal’, (RunningTotal+ClosedP/L in money(magicNo./0 trades ago)
In backtesting this works. But live and also emailing this figure there are problems.

How long does the assigned variable last (assuming MT4 terminal is not closed)?
Does it need to be / can it be saved somehow?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

6 years ago #191935

As long as the EA remains actively attached and MT is running steadily it should be kept in memory. What kind of problems do you mean (in live)? Does the variable become 0 while in backtesting it has a correct value?

0

glennc

Subscriber, bbp_participant, community, 3 replies.

Visit profile

6 years ago #191950

Thank you Tomas, I needed to know that piece of information.
Perhaps the problem is the figure in the sent email. Because that returns zero I have assumed the plan is not working, which means I keep re-jigging the EA. I shall let that run over a longer series to confirm that the code itself is working properly.

This begs the next question. Am I to assume that the variable sent via email will not be the actual variable in memory at the time? (I am running mt4 in a VPS with monitors to ensure the platform is operating uninterrupted.)

A related question about the emails – I cannot avoid receiving two of the same email. It is set to send after a trade has closed. So the condition is  BarsSinceOrderClosed (magicNo.) = 1, the ‘calculate on bar open only’ is checked, and I have added IsBarOpen = True. Nevertheless, two emails every time. I could add another variable ’email sent’ to prevent another one, but surely the above conditions should mean it is processed only once?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

6 years ago #192409

Hello,

can you provide the EA so I can check how it is setup? You can also share at [email protected] or using the forum private section

0

glennc

Subscriber, bbp_participant, community, 3 replies.

Visit profile

6 years ago #192423

Hello Tomas. Thanks again for your reply. I should have updated my post – I think the problem (unsurprisingly) is user error. I discovered I was running some of the EA’s on another machine – not live trading there, but I think I it may have been still sending the emails. So I have removed those and will see if the problems are resolved. I will come back to you if the problem continues.
You have already given me the important answer, that the variables should be held in memory with MT4 running steadily.
Thanks for your help.

0

Viewing 4 replies - 1 through 4 (of 4 total)