I've performed some basic tests and discovered the issue arises only for signals not indicators. Here's my code to demonstrate the issue. The output for a signal study is as follows:
Normal variable set to 1
Intrabarpersist variable set to 1
Normal variable set to 1
Normal variable set to 1
Normal variable set to 1
As you can see the intrabarpersist variable retains it's value across re-runs but the normal one doesn't. The other interesting point to note is the
once keyword works across the re-runs. In other words, it is only ever executed once regardless of how many times the study is re-run. This is good or bad depending on the intent by the programmer. I don't mind its current behaviour as it is very handy most of the time. I already use another method to execute code each and every time a study is re-run. The simplest way is to use a normal variable as shown in my test code to check whether a study is re-run.
Code:
[IntrabarOrderGeneration = True]
variables:
normal.var(0), intrabarpersist intrab.var(0);
once cleardebug;
if normal.var = 0 then begin
normal.var = 1;
print ("Normal variable set to 1");
end;
if intrab.var = 0 then begin
intrab.var = 1;
print ("Intrabarpersist variable set to 1");
end;
iF LastBarOnChart_s then value1 = close[30];