Click or drag to resize

Order Handling Methods

Understanding Historical Orders and Live Orders

ArthaChitra submits 2 (two) types of orders, namely, historical orders and live orders.

Historical orders are submitted while processing the historical bars and are essentially dummy or synthetic orders and no actual orders are submitted (to the associated account). Live orders on the other hand are actual orders (except for simulated account) and are reflected in the account associated with it.

Any position opened in the historical bars must be closed before a live order can be submitted. The strategies (as listed in Strategies tab in Main View) highlighted in pink reflects that a position has been opened in historical bars and is waiting to be closed. Once the position turns flat, live orders will be submitted on the next trigger. The below screenshot further demonstrates it.

Strategy Tab
Order Handling Rules

In order to ensure no redundant orders are submitted by a strategy, ArthaChitra lays down order handling rules which guides how an order will be processed. The order handling rules may ignore an order if it deems fit. Below are some of the scenarios which discusses the order handling rules.

Enter methods (e.g. EnterLong) will be ignored when:

  • Entries taken exceeds the EntriesPerDirection.
  • Entry Limit orders in the opposite direction is working. e.g. if a Sell limit order, as submitted via EnterShortLimit, is working then orders submitted by, say EnterLong/EnterLongLimit method, will be ignored.
  • An existing entry entry order is still in PendingSubmit state.
  • Exit orders, as submitted by Set method or Exit methods in opposite direction are pending. e.g. if a Sell order submitted via SetTarget method is working, then orders submitted by EnterLong etc will be ignored.

Exit methods (e.g. ExitPosition) will be ignored when:

  • A stop or target order with the same entry order name is pending.

Set methods will be ignored when:

  • An order submitted via the Exit method is working

Note: Orders ignored by the Order Handling Rules are displayed in the Output View. Please make sure you have set TraceOrders to "true".

Understanding EntriesPerDirection

The EntriesPerDirection property determines how many entries in the same direction will the strategy allows. For example if the EntriesPerDirection is set to 1 (one) then only 1 (one) entry will be allowed. If the strategy triggers a 2nd entry in the same direction then the order handling rules will ignore the call. A 2nd entry in the same direction can only take place once we exit the first trade.

The EntriesPerDirection is calculated based on how the user has configured the EntryHandling settings. If EntryHandling is set to AllEntries then all current trades are taken into consideration while calculating the EntriesPerDirection. However if the EntryHandling is set to UniqueEntries, then orders with the same unique name will be taken into consideration to calculate the EntriesPerDirection value.

Let's exemplify the scenario. Say the strategy generates 3 (three) long entries.

  • EnterLong("buy1");
  • EnterLong("buy2");
  • EnterLong("buy1");

Scenario 1 : If Entries per direction is set at 1 (one)

AllEntriesOnly the first entry will be taken. the 2nd and 3rd entries will be ignored.
UniqueEntriesThe 1st and the 2nd entries will be taken. the 3rd entry will be ignored.

Scenario 2 : If entries per direction is set to 2 (two)

AllEntriesThe 1st and the 2nd entry will be taken. the 3rd entry will be ignored.
UniqueEntriesAll the orders will be taken.

Multi-series consideration

The EntriesPerDirection in a multi-series envirionment is independent of each other, i.e. BarsArray[0] will calculate its own EntriesPerDirection and BarsArray[1] will have its own EntriesPerDirection and both are independent of each other. For example if you set the EntriesPerDirection to 1 (one) and the EntryHandling is set to AllEntries, and you submit a long order in the primary bars (BarsArray[0]) then all subsequest long orders in that bars series will be ignored. However you can submit a long order in the secondary bars series (BarsArray[1]). Since they are independent of each other the long order in the secondary series will be NOT ignored. Subsequest long orders in the secondary series will however will be ignored (as per the EntriesPerDirection rule)

Action

Result

Long order in primary bars (BarsArray[0])Order will be submitted
Long order in primary bars (BarsArray[0])Order will be ignored
Long order in secondary bars (BarsArray[1])Order will be submitted
Long order in secondary bars (BarsArray[1])Order will be ignored
Close/Reverse button

Clicking on Close or Reverse button from any of the views, will close the global position for that instrument (global position includes positions created manually and by strategies) and will disable all the strategies pertaining to the said instrument.

Strategy Options

ArthaChira lets you configure (from Settings > Options > Strategy tab in Main View) on how the strategy will deal with connection loss or order rejection etc. Please refer here for more details.

If the account suppots margin order then user have the choise set the 'Is Margin' property from the Strategy Selector View. The 'Is Margin' property can be set when the Strategy State is in Initialize mode only.

See Also