Normal
I am the point of setting my trailing stops: 1. Since buy, if index filter continues true, Stop loss at 70% of high, until 2. Index filter has become not true, change stop loss of 90% of high since buy, until 3. Index filter returns true, then 70% of high subject to this stop loss being above stop loss in Condition 2I have created some rudimentary rules, but these I know are way off. I would welcome some guidance on writing the AFL to implement the above trailing stop[CODE]SetForeign( "XAO" ); Filter1 = C> MA( C, 10 ); Filter3 = Ref(MA( C, 10 ),-1)> Filter1; RestorePriceArrays();Filter = Filter1;_SECTION_BEGIN("Buy_sell");Hh = Ref(HHV(H,20),-1);Buy = Iif(Filter,Cross(C,Hh),0);//Trailing Stops:// 1. Since buy, if index filter continues true, Stop loss at 70% of high, until// 2. Index filter has become not true, change stop loss of 90% of high since buy, until// 3. Index filter returns true, then 70% of high subject to this stop loss being above stop loss in Condition 2 Stop1 = IIf(Filter1,C<= Hh*.7,0); //stop condition1Stop2 = IIf(Filter3, C<= Hh*.9,0); //stop condition2Stop3 = IIf(Ref(filter3,-1), C<= Hh*.9,0); //stop condition3Sell = C<Stop1 OR C<Stop2 OR C<Stop3;_SECTION_END();[/CODE]
I am the point of setting my trailing stops:
1. Since buy, if index filter continues true, Stop loss at 70% of high, until
2. Index filter has become not true, change stop loss of 90% of high since buy, until
3. Index filter returns true, then 70% of high subject to this stop loss being above stop loss in Condition 2
I have created some rudimentary rules, but these I know are way off. I would welcome some guidance on writing the AFL to implement the above trailing stop
[CODE]
SetForeign( "XAO" );
Filter1 = C> MA( C, 10 );
Filter3 = Ref(MA( C, 10 ),-1)> Filter1;
RestorePriceArrays();
Filter = Filter1;
_SECTION_BEGIN("Buy_sell");
Hh = Ref(HHV(H,20),-1);
Buy = Iif(Filter,Cross(C,Hh),0);
//Trailing Stops:
// 1. Since buy, if index filter continues true, Stop loss at 70% of high, until
// 2. Index filter has become not true, change stop loss of 90% of high since buy, until
// 3. Index filter returns true, then 70% of high subject to this stop loss being above stop loss in Condition 2
Stop1 = IIf(Filter1,C<= Hh*.7,0); //stop condition1
Stop2 = IIf(Filter3, C<= Hh*.9,0); //stop condition2
Stop3 = IIf(Ref(filter3,-1), C<= Hh*.9,0); //stop condition3
Sell = C<Stop1 OR C<Stop2 OR C<Stop3;
_SECTION_END();
[/CODE]
Hello and welcome to Aussie Stock Forums!
To gain full access you must register. Registration is free and takes only a few seconds to complete.
Already a member? Log in here.