IntraBarPersist does not work when using offsets.
IntraBarPersist does not work when using offsets.
The IntraBarPersist Does not really work the way I had hoped. It seems that if you start using offsets such as Date[Offset] in your code it starts to set variables back to zero at the start of the intraday minute bar even when you have put in this IntraBarPersist reserve word. So in the end the only thing one can trust is to get a variable set by a GV, do the update on the variable then immediately send it out to the GV so that the next time you get it you can trust it to have held its value by once again getting it from the GV. For the IntraBarPersist to truly work it needs to be completely removed from the MaxBarsBack table thinking (a true programming variable just like the GV and just like all the other programming languages I have worked with which do not have a problem doing. I think the original EL programmers go a little carried away with the built in table idea. Oh well. A few days lost. At least there is a solution. In effect the GV solution is pretecting the variable from the EL weakness.
Can help.
As I work out the revised code it occured to me that the IntraBarPreserve can be used to reduce the number of GV Get commands to one per minute or maybe less depending on this [offset] problem. The GV ensures that at least if EL decides to reset your variable to zero you can get it back but the if test minimizes the number of GV calls.
As far as solving this problem I think this brand new classic reserve word shoud be used.
Variable MeASimpleVariableSoAllTheTimeLeaveMeTheHellAloneEL MyVariable(0);
However you need to put a smily at the end of that reserve word so EL does not get mad at you and figure out another way to trip you up
Code: Select all
Variable: IntraBarPreserve MyVarGV(0),
If LastBarOnChart then
begin
If MyVarGV = 0 then
MyVarGV = GV_GetNamedInt("GVname",0);
end;
I You want to change MyVarGV then also send out the GV.
Variable MeASimpleVariableSoAllTheTimeLeaveMeTheHellAloneEL MyVariable(0);
However you need to put a smily at the end of that reserve word so EL does not get mad at you and figure out another way to trip you up