The CreateEntryOrder() Function allows you to place an entry order. It has 9 parameters:


1.Instrument: TInstrument – the instrument.
2.Account: TAccount – the account.
3.Amount: Double — the number of lots.
4.BuySell: TBuySell — buy or sell.
5.Rate: Double — the entry rate.
6.StopRate: Double – the predefined stop order rate (enter 'NullRate' if you do not want to place a stop order).
7.LimitRate: Double – the predefined limit order rate (enter 'NullRate' if you do not want to place a limit order).
8.OrderType: TOrderType — the order type. Values: otEStop, otELimit.
9.OperationTag: String — the custom order tag.

Custom order tags are used to make it easier to identify and access the individual orders and consequent positions. Note that tags should have unique names.

You may want to use a counter for tagging the orders and positions.

Example: Let us create a strategy that will place 2 entry orders: one to buy at the rate 30 points higher than the current rate, and

the other one to sell at the rate 50 points higher than the current rate.

The strategy should place orders when the Close rate of the last (current) candle is higher than the Close rate of the previous candle.


We will use the procedure OnNewCandle as it runs every time a new candle appears in the chart. Remember, that you must set this function in the procedure OnCreate().


The script will be as follows:



 StrategyName='My Strategy';

 StrategyVersion = '1.0';



 History: TCandleHistory;

 Account: TAccount;

 Amount, Point: Double;

 ESrate, ELrate, Stop, Limit: Integer;


procedure OnCreate;


 Settings.AddCandleHistory(@History, 'Candle History', '', CI_5_Minutes, 100);

 History.OnNewCandleEvent := @OnNewCandle;

 Settings.AddAccount(@Account, 'Account', '');

 Settings.AddFloat(@Amount, 'Amount(:Lots)', 5);

 Settings.AddInteger(@ESRate, 'ES in pips', 30);

 Settings.AddInteger(@ELRate, 'EL in pips', 50);

 Settings.AddInteger(@Stop, 'Stop', 15);

 Settings.AddInteger(@Limit, 'Limit', 20);



procedure OnNewCandle;


 Point := History.Instrument.PointSize;

 if History.Last.Close>History.Last(1).Close then


    CreateEntryOrder(History.Instrument, Account, Amount, bsSell,




                     otELimit, 'EntryLimitSell');

    CreateEntryOrder(History.Instrument, Account, Amount, bsBuy,




                     otEStop, 'EntryStopBuy');