thanks Mike for your reply, a) can you tell me what is wrong with the code, so I don't make the same mistake again in the future. I tried to replicate code I had seen for staticvars.
b) In terms of what I am trying to do. I am trying to write a staticvar that detects when there is a short trade. and then set it in my buy condition not to have a buy if "onshort" == 1. so when staticvar "onshort" equals 1 then no buys will occur. I would use the exrem function but as I understand it, it is not very good in the backtester?? So Marcin suggested I use a staticvar. Can you help please zeek --- In [email protected], zeek ing <zeekin...@...> wrote: > > I think I am having a little problem with my static var code. I expected to > see in an exploration with the variable "onshort" a value of 1 when a short > trade is on. Instead all I see is zeros in the exploration. I am not sure > why. there are two parts to the code. If anyone can tell me what is wrong > with this code it would be appreciated. thanks > > ///part a-- > StaticVarGet("onshort"); > > > > if( IsNull( StaticVarGet("onshort"))) StaticVarSet("onshort",0); > > Onshort= StaticVarGet("onshort"); > > > > //part b--- > > if (LastValue(Short)) > > > > {StaticVarSet("onshort",1);} > > if (LastValue(Cover)) > > > > {StaticVarSet("onshort",0);} > > > > StaticVarGet("onshort"); >
