Try an 'if statement', which is how I use these things.

if(lastvalue(longentry))
{StaticVarSet("aaa",lastvalue(Longentry);
}
The StaticVarSet will now only be triggered if longentry is true

Mark

On 13/01/07, Wes Smith <[EMAIL PROTECTED]> wrote:

  Thanks Graham,
But I think StaticVarSet("aaa",lastvalue(Longentry));  will also set the
static var to 'false' when Longentry is false...

I want the staticvar to be set 'true' if longentry is ever true, and then
only reset when there's a longExit signal..)
Wes

----- Original Message ----
From: Graham <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, January 12, 2007 4:05:04 PM
Subject: Re: [amibroker] Help with Static vars

 there are easier ways without the IF's
LongEntry = C > Ref(H,-1) ;
LongExit = C < Ref(L,-1) ;
  StaticVarSet("aaa",lastvalue(Longentr y));

Longlatch = (Longentry OR StaticVarGet("aaa"));


--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriti ng.com <http://www.aflwriting.com>

On 13/01/07, wes_zoltran2 <wes_zoltran@ yahoo.com <[EMAIL PROTECTED]>>
wrote:
>
> I'm trying to learn Static vars
> The example I'm using is to form a 'Latch' type function, similar to
> FLIP, for use in RT trading.   (see dicussion last week in the
> amibroker-at group).
>
>
> The goal is to 'latch' a condition as true, once it has occurred,
> regardless if the condition becomes false later in the curent bar
> For example, if price > prior close.  The normal FLIP doesn't work in
> RT, as the condtion may vary during the bars life, and flip() only
> "latches" at bar close time.
>
> So here's the original code example using flip..
> --
> LongEntry = C > Ref(H,-1) ;
> LongExit = C < Ref(L,-1) ;
>
> /* The following 'Flip' doesn't work in RT.
> It will vary with the condition, until the bar closes */
>
> inlong = Flip(Longentry, longexit) ;
>
> Plot(inlong,"",colorGreen, styleArea, 0,10);
> PlotShapes(IIf( Longentry, shapeUpTriangle, shapeNone) ,colorLime) ;
> PlotShapes(IIf( Longexit, shapeDownTriangl e,shapeNone) ,colorRed) ;
> Title = Name() + " In long entry = " + inlong  ;
> --
>
> And here's my attempt with using static vars to latch 'inlong' = true
> on the 1st occurance of the signal.
> But it doesn't work right .. the static var doesn't seem to getting
> set.. or at least that's the appearance.
>
> --
> _SECTION_BEGIN("RT-FLIP");
> LongEntry = C > Ref(H,-1) ;
> LongExit = C < Ref(L,-1) ;
> if (Longentry[BarCount -1] = True)
>         {
>         StaticVarSet("aaa",True);
>         }
> if (Longexit[BarCount- 1] = True)
>         {
>         StaticVarSet("aaa",False);
>         }
> Longlatch = (Longentry OR StaticVarGet("aaa"));
>
> inlong = Flip(Longlatch ,longexit);
> /* This should be true, until we get a new longexit ) */
>
> Plot(inlong,"",colorGreen, styleArea, 0,10);
> PlotShapes(IIf( Longentry, shapeUpTriangle, shapeNone) ,colorLime) ;
> PlotShapes(IIf( Longexit, shapeDownTriangl e,shapeNone) ,colorRed) ;
>
> SignalText = WriteIf(inlong, EncodeColor( colorLime) + " IN LONG
> TRADE","");
> Title = Name() + " longentry = " + Longentry  + " StVar= " +
> StaticVarGet("aaa")  + signaltext;
> _SECTION_END( );
>
> ---
> I suspect I'm getting hung up in my use of barcount and/or my use of
> the braces in the IF statements.
>
> Any help would be appreciated.
>
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroke r.com/devlog/ <http://www.amibroker.com/devlog/>
>
> For other support material please check also:
> http://www.amibroke r.com/support. html<http://www.amibroker.com/support.html>
>
> Yahoo! Groups Links
>
>
>
>
>



Reply via email to