you cannot use applystop like this
try this, it might work

Sell = Cross( Signal( fa, sa, sig ), MACD( fa, sa ) )
 or cross( valuewhen( timecondition2, C-0.1 ), L );

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


On 09/05/07, iliagold1 <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I would like to add a trailing stop after the last order of the day
> of 10 cents, how would I put that in the formula?
>
> I tried something like this but it does not work, please help.
>
> tn2 = TimeNum();
> timecondition2 = tn2 >= 180001;
>
> if( LastValue( Buy AND timecondition2 ) )
>
> {
> ApplyStop( 2, 2, 1, 100, False, 1 );
> }
>
>
> ----------
>
> Bellow is the full formula:
>
> /* variable = optimize( "Description", default, min, max, step ) */
> fa = Optimize( "MACD Fast", 661, 1, 1000, 10 );
> sa = Optimize("MACD Slow", 221, 1, 400, 10 );
> sig = Optimize( "Signal average", 171, 1, 200, 10 );
>
> tn = TimeNum();
> timecondition = tn >= 140000 AND tn < 180000;
>
> tn2 = TimeNum();
> timecondition2 = tn2 >= 180001;
>
> Buy = Cross( MACD( fa, sa ) , Signal( fa, sa, sig ) );
> Sell = Cross( Signal( fa, sa, sig ), MACD( fa, sa ) );
>
> Short = Sell;
> Cover = Buy;
>
> Buy = Buy AND timecondition;
> Short = Short AND timecondition;
> //Sell = Sell OR NOT timecondition;
> //Cover = Cover OR NOT timecondition;
>
> if( LastValue( Buy AND timecondition2 ) )
>
> {
> ApplyStop( 2, 2, 1, 100, False, 1 );
> }
>
> PositionSize = MarginDeposit = 1;

Reply via email to