[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Static var help



PureBytes Links

Trading Reference Links

i turned of the reverse in backtester but it is to no avail. 
the main reason I want the staticvars is inorder to tell my system not to put a 1 in the buy column while in the middle of a short trade. THis primarily for my chart, all the arrows get messed up. it shows a long enter arrow while in the middle of a short trade.

I am trying to avoid that. 

 i wanted to implement a Shorton and  longon variable after the buy and sell code.that reads longon== 1 if in a buy and shorton==1 in a short. then go back and not allow a buy unless the shorton ==0.  There is a problem. The shorton , longon is used to tell the buy not to put a 1 in the buy array. BUt by definition they get set after after the buy and short array are initiliazed in the code. so the buy code will always look at the initialized value at 0, before it reads the flip. I can't put the flip before the buy code becausec the buy has not been initialized. it is like a catch 22. So i thought to use staticvars instead but am having trouble. 
 
For example:
 
shorton=0;
longon=0;
 
Buy= BarsSince(Signalbar)< waitPeriod AND (H>highsignal)AND Shorton==0 ;
BuyPrice = Max(O,Highsignal+.05);
Short = BarsSince(signalBars) < waitPeriod AND  (Signallow>L) AND Longon==0;
ShortPrice = Min(Open,Signallow-.05);
Shorton = Flip( Short, Cover );



--- 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/