It is very simple.

/////////////////////////////////////////
F1=ValueWhen(H<Ref(H,-2) AND Ref(H,-1)<Ref(H,-2) AND Ref(H,-3)<Ref(H,-2) 
AND Ref(H,-4)<Ref(H,-2),Ref(H,-2),1);
F2=ValueWhen(L>Ref(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) 
AND Ref(L,-4)>Ref(L,-2),Ref(L,-2),1);
a=Cross(H,F1);
b=Cross(F2,L);
state=IIf(BarsSince(a)<BarsSince(b),1,0);
Buy = state>Ref(state,-1);
Sell = state<Ref(state,-1);
PlotShapes( IIf(Buy, shapeSmallCircle,0) , colorGreen,0,L,-10);
PlotShapes( IIf(Sell, shapeSmallCircle,0) , colorOrange,0,H,10);

SetChartOptions( 0, chartShowDates | chartShowArrows | chartWrapTitle );
_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}} 
{{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 
1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", colorWhite, styleBar | styleNoTitle | ParamStyle( 
"Style" ) | GetPriceStyle() );

if ( ParamToggle( "Tooltip shows", "All Values|Only Prices" ) )
{
     ToolTip = StrFormat( "Open: %g\nHigh:  %g\nLow:   %g\nClose:  %g 
(%.1f%%)\nVolume: " + NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( 
C, 1 ) ) );
}
/////////////////////////////////////////


On 5/6/2010 8:31 AM, Vinay Gakkhar. wrote:
> Can senior members please translate for me the following from 
> MetaStock language to the AFL ?
>
> I want to have the enter & exit arrows also.
>
> Thank you.
>
> vgakkhar
>
> WriteIf(F1:=ValueWhen(1,H<Ref(H,-2) AND Ref(H,-1)<Ref(H,-2) AND 
> Ref(H,-3)<Ref(H,-2) AND 
> Ref(H,-4)<Ref(H,-2),Ref(H,-2));F2:=ValueWhen(1,L>Ref(L,-2) AND 
> Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND 
> Ref(L,-4)>Ref(L,-2),Ref(L,-2));a:=Cross(H,F1);b:=Cross(F2,L);
> state:=If(BarsSince(a)<BarsSince(b),1,0);
> state>Ref(state,-1),"If trading short positions, exit all short 
> positions today with a Market On Close (MOC) order or at the market 
> price on tomorrow's open.
>
> If trading long positions, enter long today with a Market On Close 
> (MOC) order or at the market price on tomorrow's open. ")\
> \
> WriteIf(F1:=ValueWhen(1,H<Ref(H,-2) AND Ref(H,-1)<Ref(H,-2) AND 
> Ref(H,-3)<Ref(H,-2) AND 
> Ref(H,-4)<Ref(H,-2),Ref(H,-2));F2:=ValueWhen(1,L>Ref(L,-2) AND 
> Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND 
> Ref(L,-4)>Ref(L,-2),Ref(L,-2));a:=Cross(H,F1);b:=Cross(F2,L);
> state:=If(BarsSince(a)<BarsSince(b),1,0);
> state<Ref(state,-1),"If trading long positions, exit all long 
> positions today with a Market On Close (MOC) order or at the market 
> price on tomorrow's open.
>
> If trading short positions, enter short today with a Market On Close 
> (MOC) order or at the market price on tomorrow's open. ")\
> \
> WriteIf(F1:=ValueWhen(1,H<Ref(H,-2) AND Ref(H,-1)<Ref(H,-2) AND 
> Ref(H,-3)<Ref(H,-2) AND 
> Ref(H,-4)<Ref(H,-2),Ref(H,-2));F2:=ValueWhen(1,L>Ref(L,-2) AND 
> Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND 
> Ref(L,-4)>Ref(L,-2),Ref(L,-2));a:=Cross(H,F1);b:=Cross(F2,L);
> state:=If(BarsSince(a)<BarsSince(b),1,0);
> state=Ref(state,-1),"No trading signals today.")
>
>
>



------------------------------------

**** 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:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to