[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] TrailStop: ApplyStop opens positions for me?



PureBytes Links

Trading Reference Links

Hello,

I am learnig the AmiBroker Folmula Language. For the test puroses I 
wrote a simple backtester system. I want it to open one long 
position at bar 1 and apply a trailing stop to it. That's it: I 
don't want any more positions open. I just want to test what will be 
the behaviour of the trailing stop applied to this single position. 
However, the code that I came up with seems to open new long 
positions everytime the stoploss order has been executed on the 
previously opened position.

Can anyone advise as to what is wrong with my code? I past my code 
below

Thanks,
WB

-  -  -  -  code  start  -  -  -  -  -

PositionSize = 100000;	// The size of 1 lot
TickSize = 0.0001;

for( i = 1; i < BarCount; i++ )
{
	if (i == 1)
	{
	Buy = 1;
	ApplyStop(2, 2, 0.0050, 1, False, 0);
	}
	else
	{
	Sell = 0;
	Short = 0;
	Cover = 0;
	}
}

-  -  -  -  code  end  -  -  -  -  -








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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 other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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