PureBytes Links
Trading Reference Links
|
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 amibroker@xxxxxxxxxxxxxxx, zeek ing <zeeking57@xxx> 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");
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|