PureBytes Links
Trading Reference Links
|
there are easier ways without the IF's
LongEntry = C > Ref(H,-1) ;
LongExit = C < Ref(L,-1) ;
StaticVarSet("aaa",lastvalue(Longentry));
Longlatch = (Longentry OR StaticVarGet("aaa"));
--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriting.com
On 13/01/07, wes_zoltran2 <wes_zoltran@xxxxxxxxx> 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,shapeDownTriangle,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,shapeDownTriangle,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.amibroker.com/devlog/
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
> Yahoo! Groups Links
>
>
>
>
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.10/624 - Release Date: 1/12/2007 2:04 PM
|