I found that global variable cant store the value in history but only the current latest value, which make the strategy back testing impossible to finish. For instance,
You insert this indicator in one workspace:
vars:GVset("GVtest"),var1(0);//
GVSetNamedDouble(Gvset,0);
if time=1500 then begin GVSetNamedDouble(Gvset,close);
var1=close;
end;
plot1(var1);
And then insert the below indicator in another workspace:
var:GVget("GVtest"),var0(0);
var0=GVGetNamedDouble("GVtest",-9999);
plot1(var0);
You may get the latest close price on 15:00, but no the days before.
How to trace the history value by GV? thanks!
global variable in MC can be only used in Real time?
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: global variable in MC can be only used in Real time?
What is your chart resolution?I found that global variable cant store the value in history but only the current latest value, which make the strategy back testing impossible to finish. For instance,
You insert this indicator in one workspace:
vars:GVset("GVtest"),var1(0);//
GVSetNamedDouble(Gvset,0);
if time=1500 then begin GVSetNamedDouble(Gvset,close);
var1=close;
end;
plot1(var1);
And then insert the below indicator in another workspace:
var:GVget("GVtest"),var0(0);
var0=GVGetNamedDouble("GVtest",-9999);
plot1(var0);
You may get the latest close price on 15:00, but no the days before.
How to trace the history value by GV? thanks!
Depends on your code, you should be able to check for var0[1].
If not, then you have to save the past data in an array.
ps.
[FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713
Re: global variable in MC can be only used in Real time?
What I mean is the global variable is a constant when you use it, which make the back testing failed. var0[1] can only return the value one bar ago, but the value has not change in the very beginning. Anyone know what I am saying?
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: global variable in MC can be only used in Real time?
Global variables don't work with backtesting, as far as I know. Creating a list with ELCollection does work. You can find the ELCollection and documentation here. There are multiple topics about/that use ELCollection, for example this topic and this topic (do a search for more).I found that global variable cant store the value in history but only the current latest value, which make the strategy back testing impossible to finish.
(...)
How to trace the history value by GV? thanks!
Re: global variable in MC can be only used in Real time?
Thanks, That is what I want. I will spend more time to figure out this.