Skip to main content

How to Handle a Strategy in Error

AlgoTest has a new feature called the Resume Strategy function to help you resume a strategy that has gone into error.

Now you have the capability to handle errors directly on AlgoTest as opposed to managing the positions on the Broker Terminal.

Reasons for Error(s) 

While it is not the most common occurrence, sometimes the strategies you run can go into errors.

There can be many reasons for this error. It can be 

  • Margin Shortfall

  • Illiquid Instrument

  • Some Broker RMS rules, etc. 

In such situations, it is essential to maintain calm and follow the correct steps, to handle the error efficiently.

Handling Errors on AlgoTest during Live Trading

Reasons for Errors on AlgoTest 

A running strategy can go into error for many reasons. Your strategy can be in one of these two modes :

  1. Error Mode - You need to manage your error manually.
  2. View Error to Resume Mode - These erros can be managed from AlgoTest.  

No change : No change here means that errors will be handled as they were before. The trader will have to deal with the said error on the broker terminal by switching strategy to manual.

Strategy Paused : Halt state means that your strategy has been halted and you can rectify the error and resume your strategy.

How to identify an error on AlgoTest

In case your strategy has encountered an error that can be resumed (the strategy has gone into 'Halt State') you need to first identify the error.

For this you need to go to the live trade page and click on the "View Error to Resume" button as shown in the image below.

ATM Percentage

It will show you the reason behind the error. As you can see in the below image the reason is margin error.

ATM Percentage

Similarly, there will be other errors that can be identified by AlgoTest. 

Error Strategy Trade Info

On the Error Page, you will be able to see further information about the strategy.

Running Legs 

Your running positions will be displayed under Running Legs. These are legs on your strategy that are running without error.

Open Orders 

Pending orders can be viewed under "Open Orders".  These are orders open on the broker end for a strategy  in error.

ATM Percentage

Handling "Error to Resume Mode" Strategy

We have all the info about reasons for an error and trade information. 

AlgoTest now offers you three features to handle the error :

  1. Resume feature

  2. Square off feature 

  3. Switch to Manual feature

Resume Feature

This feature enables the user to retry the legs for execution that have not been executed due to error. 

After that, AlgoTest will start monitoring the strategy again as per the conditions defined in the strategy. 

If the Resume button is clicked after strategy exit time, it will work as a square-off button. 

Note : After 03:25 or as per the broker MIS time, the resume button will be disabled.

Time Based Entry/Re ASAP

It will select the strike and try to enter immediately for entry/re entry at the time you click on resume button at whatever price available.

Momentum/Re Cost/Range Breakout

If the current recost/momentum/range breakout price is above your reference price and you click on resume button, it will enter immediately at current price.

If you know the reason behind the error you can try to resolve it and then attempt to resume.  

For instance, In the case of a margin shortfall if you added margin and now want to resume the same strategy, then you can use this feature. 

Squareoff Complete 

  • If any leg exits while 1 or more legs are in error, it will cancel all entry leg orders. No orders will be fired for any of the error legs.

  • If the leg re entry is enabled, then error legs can take entry as per the condition defined for re entry in strategy except for re-cost re-entry. 

  • It will take re-entry cost based on the last price attempted (error leg price).

To resume, click on the resume button as shown in the image below :

ATM Percentage

Square Off Feature

It enables the user to squareoff all error strategy positions and pending orders from AlgoTest. It simply squares all the open positions and cancels pending orders for leg entry in your error strategy. 

After 03:25 or as per your broker MIS time the Square Off button will disabled (only if the execution settings has order type: MIS).

You can squareoff a strategy by clicking on the "Square Off" button and then "Confirm Square Off" button as shown in the image below.

ATM Percentage

ATM Percentage

Switch to Manual Feature

It enables the user to handle the strategy manually on the broker end including all the running positions and pending orders. 

AlgoTest will not fire any further orders after you change the mode of strategy to manual. 

All strategies going into error after 3:25, will automatically turn into "Switch to manual" mode.

Switching to manual doesn't need re-login.

ATM Percentage

warning

In most cases we are able to keep track of the strategy orders that went into error. But in some cases we can't track the orders. 

AlgoTest will show you most error states, but in case it isn't clear we will point you to handle the strategy manually on the broker end. 

Since you can access the info of running positions and pending orders you can easily manage your strategy on the broker terminal.

Error(s) that can now be handled on AlgoTest

  1. Margin Error

  2. Session Expired/Invalid Session Error

  3. Illiquidity/Insufficient Volume Error

  4. Convert to Market Order Blocker Error

Margin Error

Margin error comes when your broker rejects your orders due to margin shortfall. In this case as per execution settings the system will try to square-off the strategy. But if the positions are not squared off due to any reason, the system will move the strategy into halt state.

Solution for a Margin Error

You can add the required margin and can use any of the following features.

Resume :- By using this feature, the system will try to execute the legs which are not executed and will monitor the strategy condition as per the defined strategy.

Squareoff :- By using this feature, the system will try to squareoff the leg(s) which are running and cancel the pending order(s) if any is placed.

Switch to Manual :- By using this feature, the system will put the strategy into manual mode and no further orders will be fired by the system. After that you need to manage the pending orders and execute positions manually on the broker end.

info

Switching to manual doesn't need re-login.

Session Expired/Invalid Session Error

A Session Expire/Invalid Session error comes when your broker expires your session. 

One of the reasons for this error could be that your broker doesn't allow you to use the API simultaneously on more than one platform and you might be logged into multiple platforms simultaneously.

Solution for Session Expire/Invalid Session Error

You need to re-login to your broker on the broker setup page on AlgoTest

Visit the broker setup page on AlgoTest and click on the re-login button. Re-login and use any of the following features:

Resume :- By using this feature, the system will try to execute the legs which are not executed and will monitor the strategy condition as per the defined strategy.

Squareoff :- By using this feature, the system will try to squareoff the leg(s) which are running and cancel the pending order(s) if any is placed.

Switch to Manual :- By using this feature, the system will put the strategy into manual mode and no further orders will be fired by system. Now you need to manage the pending orders and execute positions manually on the broker end.

info

Switching to manual doesn't need re-login.

Illiquidity/Insufficient Volume error

Illiquidity/Insufficient Volume error comes when the given strike doesn't have enough liquidity or volume and so it cannot be traded.

Solution for Illiquidity/Insufficient Volume Error

It is possible that at the time you decide to take a trade (or your strategy attempts to take a trade based on predefined conditions) a specific strike doesn't have enough liquidity. 

But maybe after a certain amount of time it has enough volume to get traded. You can try any of the following features :

Resume :- By using this feature, the system will try to execute the legs which are not executed and will monitor the strategy condition as per the defined strategy.

Squareoff :- By using this feature, the system will try to squareoff the leg(s) which are running and cancel the pending order(s) if any is placed.

Switch to Manual :- By using this feature, the system will put the strategy into manual mode and no further orders will be fired by system. Now you need to manage the pending orders and execute positions manually on the broker end.

Convert to Market Order Blocked Error

Some brokers don't allow market orders for BSE segments. So in case your limit order is rejected and we try to execute via market order, your broker can reject the order saying market orders are blocked for BSE. 

Solution for Market Order Blocked Error

You can try any of the following features to remove your strategy from error

Resume :- By using this feature, the system will try to execute the legs which are not executed and will monitor the strategy condition as per the defined strategy.

Squareoff :- By using this feature, the system will try to squareoff the leg(s) which are running and cancel the pending order(s) if any is placed.

Switch to Manual :- By using this feature, the system will put the strategy into manual mode and no further orders will be fired by system. Now you need to manage the pending orders and execute positions manually on the broker end.

Error(s) that Can't be Handled on AlgoTest

If your strategy shows any other error except Margin/Session Expire/Illiquidity or Insufficient Volume/Market Order Blocked error, it will not show you features like Resume/Squareoff/Switch to Manual. No orders will be fired from AlgoTest. This strategy has to be managed manually on the broker end.

How AlgoTest Works in Case your Strategy goes into "View Error to Resume" Mode

  • No Legs will be fired by the system if strategy is in error mode.

  • If you are using limit orders and a ORB/Momentum/re entry limit order triggers and entry happens when strategy was in error mode, a SL limit order will be placed by system on your broker end. Further no monitoring will be done unless you click on resume button.

  • If you click on the resume button after exit time then error legs will not enter and will be squared off immediately.

  • Signal strategy in error will get squaredoff if signal comes from tradingview/chartink.

  • For Broker Level Settings, it will only consider closed legs MTM. It will not consider MTM of running legs until you resume the strategy.

  • "Strategies deployed" count will remain blocked, till you click the "Square-off" or "Switch to manual" button.