Login Page - Create Account

Technical Studies Reference


Trading System Based on Alert Condition

Overview

When using this study, you need to run version 2070 or higher for all the latest updates. To update, refer to Fast Update.

The Trading System Based on Alert Condition is an automated trading system study which will submit a Buy or Sell order when the specified Alert Condition formula on the study becomes True.

These orders can be simulated or Live. For more information refer to Send Trade Orders to Trade Service.

This provides a simple method of automated trading. For more advanced methods, it is recommended to use the Spreadsheet System for Trading study or the ACSIL Trading functions.

When an order is generated from this trading system, it will use the settings of the Trade Window. This includes the Quantity and any Attached Orders.

Since this is an automated trading study, for an understanding of the internal logic used aside from the Alert Condition Formula that you define, refer to Automated Trading Management.

The Alert Condition is entered in the Alerts tab for this study. For information on setting alerts, refer to Study/Chart Alerts And Scanning.

This Trading system study can be used in Trade Simulation Mode if you do not want it to submit real orders. For additional information, refer to the Send Trade Orders to Trade Service Input description below.

When using this particular study, you need to be running Sierra Chart version 1700 or higher. To update, refer to Fast Update.

To perform back testing with this study, refer to the Auto Trade System Back Testing page.

For more information on how to use an Automated Trading System refer to Auto Trade Management.

Inputs

  • Enabled: This Input defines whether this trading system is active and will place orders or not. When this is set to Yes an order will be placed when the Alert is True. Otherwise, no orders will be placed.
  • Number of Bars to Calculate: This Input defines how many chart bars for which the Alert Condition will be evaluated. The primary purpose of this Input is to reduce calculation time. It has no other practical purpose.

    If Evaluate On Bar Close Only is set to Yes, the Number of Bars to Calculate must be set to 2 or higher.

    When an Alert Formula is evaluated on a particular bar, and based upon the setting of this Input, it is not evaluated on prior bars, still the Alert Formula can make reference to prior bars in its formula.

    There is the evaluation of the Alert Formula which is always done across the Number of Bars to Calculate and then there is the generation of order signals which is only going to be done on the prior or last chart bar depending upon whether Evaluate On Bar Close Only is set to Yes or No, and will be done on any new bars added to the chart during real-time updating or a replay.
  • Order Action on Alert: This Input defines the action to be taken when the Alert Condition becomes True. It can be one of the following:
    • Buy Entry: A new Buy Market order is placed using the information defined on the Trade Window for this chart which includes the Order Quantity, Time in Force, and Attached Orders settings. For further information, refer to Buy Entry.
    • Buy Exit: A Sell Market order is placed for the open Long Position that exists for the Symbol and Trade Account. The total quantity that will be exited is the lesser of the Order Quantity defined on the Trade Window or the current Position Quantity. For further information, refer to Buy Exit. An exit cannot occur if there is no current Trade Position.

      Effective with version 2067 and higher, when a Buy Exit occurs when there is not an existing position, the prior formula state is cleared so that if the Buy Exit is true when a position is entered through a Buy Entry and there no longer is a state change with the Buy Exit, the Buy Exit will then be able to exit the position after the position is entered. Rather than the Buy Exit state having to go false and then back to true for a Buy Exit to occur.

      So this change makes it easier for a Buy Exit to occur.
    • Sell Entry: A new Sell Market order is placed using the information defined on the Trade Window for this chart which includes the Order Quantity, Time in Force, and Attached Orders settings. For further information, refer to Sell Entry.
    • Sell Exit: A Buy Market order is placed for the open Short Position that exists for the Symbol and Trade Account. The total quantity that will be exited is the lesser of the Order Quantity defined on the Trade Window or the current Position Quantity. For further information, refer to Sell Exit. An exit cannot occur if there is no current Trade Position.

      Effective with version 2067 and higher, when a Sell Exit occurs when there is not an existing position, the prior formula state is cleared so that if the Sell Exit is true when a position is entered through a Sell Entry and there no longer is a state change with the Sell Exit, the Sell Exit will then be able to exit the position after the position is entered. Rather than the Sell Exit state having to go false and then back to true for a Sell Exit to occur.

      So this change makes it easier for a Sell Exit to occur.


    To perform more than one of these Order Actions, for a complete trading system, add a up to four instances of the Trading System Based on Alert Condition study to the chart, with each one set to the particular Order Action that you want to perform.

    The order of execution depends upon the order that the studies are added to the Studies to Graph list in the Chart Studies window. Therefore, you will want the instance of the Trading System Based on Alert Condition study with an Order Action set to Buy Exit listed after the instance of Trading System Based on Alert Condition with an Order Action of Buy Entry.
  • Evaluate On Bar Close Only: When this is set to Yes, then this means that the Alert Condition Formula is not evaluated on the last bar in the chart, only on the prior bars.

    During a full recalculation of the study, or when historical data is being downloaded, orders will not be submitted but the formula is evaluated and the buy and sell indication is still given on the chart.

    When this Input is set to Yes, there would need to be a new bar added to the chart before you would get an order signal after initially adding the study to the chart.
  • Send Trade Orders to Trade Service: This Input controls whether the order submitted by the study is going to be simulated or not. For complete documentation, refer to Send Trade Orders to Trade Service. When using Trade Simulation, this Input needs to be set to No.
  • Maximum Position Allowed: This defines the total quantity of a Position that can be opened by this trading system. This number must be equal to or greater than the Order Quantity on the Trade Window or the trading system will not place the order.
  • Maximum Long Trades Per Day: This defines the total number of Long Trades that can be performed by this Trading System per Day.
  • Maximum Short Trades Per Day: This defines the total number of Short Trades that can be performed by this Trading System per Day.
  • Enable Debugging Output: When this Input is set to Yes a detailed reason is included in the Trade >> Trade Service Log with respect to this study when order signals are not followed for whatever reason.
  • Cancel All Working Orders On Exit: When this Input is set to Yes and the Order Action on Alert is either a Buy Exit or Sell Exit then when the alert becomes True and the Buy Exit or Sell Exit Order is sent, the system will also cancel any Working Orders. For more information refer to Cancel All Working Orders On Exit on the Automated Trading Management page.
  • Allow Trading Only During Time Range: When this Input is set to Yes then trading from this study will only occur between the times specified by the Inputs Start Time for Allowed Time Range and End Time for Allowed Time Range.
  • Start Time for Allowed Time Range: This Input sets the start time for which trading from this study can occur when the Allow Trading Only During Time Range is set to Yes.

    When the Trading System Based on Alert Condition study is evaluating the chart bars for a signal, only the latest time in the last bar in the chart is used for comparison to this Start Time. The bar starting times themselves are not used.

    Effective with version 1949 and higher, it is supported for Start Time for Allowed Time Range to have a time greater than End Time for Allowed Time Range to represent a time range which spans over midnight. This is not supported in earlier versions.
  • End Time for Allowed Time Range: This Input sets the end time for which trading from this study can occur when the Allow Trading Only During Time Range is set to Yes.

    When the Trading System Based on Alert Condition study is evaluating the chart bars for a signal, only the latest time in the last bar in the chart is used for comparison to this Start Time. The bar starting times themselves are not used.

    Effective with version 1949 and higher, it is supported for Start Time for Allowed Time Range to have a time greater than End Time for Allowed Time Range to represent a time range which spans over midnight. This is not supported in earlier versions.
  • Allow Only One Trade per Bar: For documentation, refer to sc.AllowOnlyOneTradePerBar.
  • Support Reversals: For documentation, refer to SupportReversals.
  • Allow Multiple Entries In Same Direction: For documentation, refer to AllowMultipleEntriesInSameDirection.

Step-by-Step Instructions

  1. When using this particular study, you need to be running Sierra Chart version 1700 or higher. To update, refer to Fast Update.
  2. Add the Trading System Based on Alert Condition study to the chart. Refer to Adding/Modifying Studies.
  3. Add the Moving Average - Simple study to the chart as well. This study is used in this particular example. You can work with whatever studies you require or none if you do not need them.
  4. Open the Study Settings window for the Trading System Based on Alert Condition study.
  5. Go to the Settings and Inputs tab of the Study Settings window.
  6. Set the Enabled Input to Yes.
  7. Set the Order Action on Alert Input to the particular action you want to take when the Alert Condition Formula becomes True.
  8. For simulated trading set Send Trade Orders to Trade Service to No. Always set this to No until you are confident in the trading system or if you just want the trading system simulated always. Trade >> Trade Simulation Mode On also needs to be enabled.
  9. The Alert Condition is entered in the Alerts tab for this study. For an example, enter the formula =CROSSFROMBELOW(C, ID2.SG1). This will make reference to the moving average study added above assuming its identifier ID2. For complete documentation for Alert Condition Formulas, refer to Study/Chart Alerts And Scanning.
  10. Press OK.
  11. Press OK.
  12. Open the Trade Window for the chart. Set the Order Quantity to the quantity you want for the orders.
  13. If you want to use Attached Orders with the order submitted by the Entry order from this trading system, then follow the Attached Order Instructions.
  14. A Buy is denoted on the chart as a point on high. A Sell is denoted as a point on low. The colors and width of these can be set through the Subgraphs tab.
  15. If there is no order signal when you expect, then set the Trading System Based on Alert Condition Input Enable Debugging Output to Yes. The reason for ignored signals will be listed in the Trade >> Trade Service Log.
  16. There are no order signals, for when the system is evaluated on the historical data in the chart. It is necessary to perform back testing to accomplish this. To perform back testing with this study, refer to the Auto Trade System Back Testing page.
  17. If you need help with your formula or debugging automated trading systems, then in general Sierra Chart does not provide support for this. For more, information, refer to Troubleshooting Automated Trading Systems.

Trade Service Log Error Message Descriptions

"Trading is not allowed. Reason: Formula state has not changed" means that the state of the Alert Condition formula was previously true and remains true and that is why the order signal is ignored. If trading was not allowed for other reasons and the state was true and then trading is allowed, that true signal will then be evaluated and trigger an order.

Time in Force

The Time in Force which is used for the parent order and any Attached Orders, if enabled through the Use Attached Orders setting on the Main tab of the Trade Window for the chart, is the Time in Force setting on the Main tab of the Trade Window.

The Time in Force setting on the Targets tab does not apply since it does not apply for ACSIL based trading systems. It will be ignored. The Time in Force for both the parent order and Attached Orders if enabled, will be the same as the parent order.

Order Signals and Disappearing Alert Condition Markers

By default, the Trading System Based on Alert Condition study uses the Point on High marker on a chart bar where there is a Buy signal and the Point on Low marker on a chart bar where there is a Sell signal.

These markers indicate the current state of the Alert Condition Formula and do not indicate whether or not an order was actually submitted and filled. A formula could have momentarily gone true and then back to false and the marker is no longer present but an order was submitted.

You need to display order fills on the chart to actually see where there have been orders submitted and filled. For complete documentation, refer to Disappearing Orders Or Signals.

To help with debugging order signals, including not receiving order signals from the Trading System Based on Alert Condition study, set the Enable Debugging Output Input to Yes. When this Input is set to Yes a detailed reason is included in the Trade >> Trade Service Log with respect to this study when order signals are not followed for whatever reason.

Additionally, refer to the Troubleshooting Automated Trading System Behavior section.

Notes

  1. When the following message is displayed in the Trade >> Trade Service Log: Formula state has not changed, then the message indicates that from one chart update to the next or from one chart bar to the next, the true/false state of the formula has not changed and therefore an order entry signal will not be given.

*Last modified Friday, 29th May, 2020.