Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

LIMIT ORDERS for Amibroker (AFL)

Rating:
5 / 5 (Votes 1)
Tags:
trading system, amibroker

If you hope to get a better price on the entry, you might try a limit order. You get complete control over the entry with the following code

Indicator / Formula

Copy & Paste Friendly
//	EnterAtLimit.afl
//
//	Entry using a Limit	Order.
//	Try to get a better	price than the Market Order would give.
//
//	This example uses a	simple	moving average	crossover to
//	illustrate entering	a long	position at the market.
//
// The delay between the signal and the entry is 
// controlled either by the Settings window or the AFL code.
//
// For market orders, enter and exit Market On Close 
//	with	no delay
SetTradeDelays(0,0,0,0);
BuyPrice = C;
SellPrice = C;
// The trading system is a simple moving average crossover 
MA1	= MA(C,5);
MA2	= MA(C,25);
// The signal is generated on the bar when MA1 
//	crosses above MA2
BuySig = Cross(MA1,MA2);
//	If we can get in	at 1%	below the	Close	on	the
//	day the signal was generated,	we	will enter,
// otherwise pass on this signal.
Buy = (Ref (BuySig,-1)==1) AND (L<0.99*Ref(C,-1));
BuyPrice = 0.99*Ref(C,-1);
// When the sell signal comes, use a Market On Close order. Sell = Cross(MA2,MA1);

1 comments

1. riyasnn

can u please post for short side limit order entry afl

Leave Comment

Please login here to leave a comment.

Back