Hi, There are many flaws in your code. It might be more productive to describe in words *exactly* what you are trying to accomplish.
If you just want to produce an exploration showing when you have an open short position (subject to veto by portfolio management) then the following code is an example of how to do this: // Sample crossover strategy. Replace with your own. Fast = MA(Close, 5); Slow = MA(Close, 25); Short = Cross(Slow, Fast); Cover = Cross(Fast, Slow); // This tells you when you're short! AmShort = Flip(Short, Cover); // Add the exploration results. Filter = 1; AddColumn(AmShort, "Short On"); // Plot the strategy signals on a chart. Plot(Fast, "Fast", colorOrange); Plot(Slow, "Slow", colorBlue); PlotShapes(Short * shapeHollowDownArrow, colorRed); PlotShapes(Cover * shapeHollowUpArrow, colorGreen); Mike --- 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"); >
