# Alerts ## Backtester Alerts | Buy Alerts | Sell Alerts | | :------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------: | | ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/alerts/long.png) | ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/alerts/short.png) | Users can get alerted for any action executed by a strategy, from opening positions to closing them. The way alerts work is the same across all the Backtester scripts. The message field in the **Alert Messages** setting section of each Backtester allows for the strategy to send a custom alert message depending on the action taken by the strategy, if no messages are set the strategy will send default messages. In order for alerts to return custom user set messages the `{{strategy.order.alert_message}}` should be set on the message field of the Tradingview alert menu. ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/alerts/alert.png) Backtester (PAC) does not have Exit Long/Short TP/SL alerts, instead only having Exit Long/Short ## Alerts Placeholders Users can use placeholders in the messages set from the **Alert Messages** setting section to return market data, take profit/stop losses values, chart ticker and timeframe...etc. | Placeholder | Description | | :----------------------------------------------------: | :------------------------------------------------------------------------------------------------------------: | |
`{open}`
|
Current opening price
| |
`{high}`
|
Current high price
| |
`{low}`
|
Current low price
| |
`{close}`
|
Current closing price
| |
`{volume}`
|
Current volume
| |
`{time}`
|
Current unix time (in milliseconds)
| |
`{ticker}`
|
Chart ticker (e.g: for BINANCE:BTCUSDT the ticker name is BTCUSDT)
| |
`{prefix}`
|
Ticker prefix (e.g: for BINANCE:BTCUSDT the ticker prefix is BINANCE)
| |
`{timeframe}`
|
Chart timeframe
| |
`{tp}`
|
Take profit value
| |
`{sl}`
|
Stop loss value
| New long entry generated at `{time}` and price `{close}` on `{ticker}{timeframe}` with take profit `{tp}` and stop loss `{sl}` # Forecasting ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/forecasting/settings.png) Being able to anticipate where price might evolve after a trade can be useful to plan potential exit points, set take profits/stop loss as well as knowing when user set ones might get hit...etc. All backtesting toolkits include a forecasting tool able to provide forecasts from the most recent trade executed by the backtester. ## Using Forecasts ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/forecasting/forecasting.png) Forecasts can be enabled from the "FORECAST" settings group by enabling the "Show Forecast" toggle. Each forecast is influenced by the price evolution made during previous respective long and short trades, as such forecasts for long positions are different from the ones of short positions. Users can select the maximum length of forecast using the "Forecasting Length" setting. Because of the forecasting algorithm used, forecasts can have a lower length than the one selected by the user depending on the average bars in trade. Very frequent trades will generally return short price forecasts due to the lack of available data. ### Forecasting Area ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/forecasting/area.png) By default, forecasts are displayed alongside an area, indicating where future prices might evolve. The area extremities can help users potentially determines exit points with there interaction with the price, but can also help reference the performance of a current trade relative to past trades. Areas extremities are representative of past trades performances. For example: * For long positions: A lower extremity not significantly going below the entry price can indicate good past performance for long positions. * For short positions: An upper extremity not significantly going above the entry price can indicate good past performance for short positions. If an area is no longer visible in a point in time of the forecast it means that there is not enough data for that point in time. ### Forecasting Memory Users can control the influence older trades have on the forecast using the "Maximum Forecast Memory" setting, with lower values using a shorter term memory, discarding older information more quickly. Low values of this setting allow obtaining more diverse forecasts for new trades, while higher values will return forecasts less subject to change over time. ### Take Profits Levels From Forecast When forecasts are displayed, users can set take profits using the **nth** percentile of a returned forecast. This can be done from the "TPS & SLS" settings, by selecting "Forecast" in the "Long TP" and/or "Short TP". The numerical setting selected at the right of the drop-down menus determines the percentile used, and should be set within the range \[0, 100] in order to work. Percentiles values can affect the returned levels as follows: * In case of a long trade, a lower set percentile will return take profits closer to the entry price, potentially triggering sooner. * In case of a short trade, a lower set percentile will return take profits further away from the entry price, potentially triggering later. Do note that because forecasts are based on the strategy entries, take profits levels based on it can be subject to repainting, except when using a backtesting window based on a date. # Entry Rules ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/osc/entry/settings.png) Backtester (OSC) allows user to set their own long/short entry rules from features of the Oscillator Matrix® as well as external indicators. Entry rules can be created separately for both long and short entries, and can be set using up to 8 different user set conditions. Each can enabled by toggling them on using the toggle input on the left of each condition, if the enabled conditions are valid, the strategy will open a corresponding market order. ## Oscillator Matrix® Conditions Conditions for 6 features of the Oscillator Matrix® are included. These include: * Money Flow conditions * OverFlow conditions * HyperWave conditions * Reversals conditions * Divergences conditions * Confluence conditions The first dropdown determines the specific condition used for that feature, these can include generic conditional operators such as `Greater Than` or `Crossing`, or conditions proper to certain features such as `Any Bullish` in the Hyperwave conditions. The second input setting allows the user to enter a numerical values, which is used when `Greater Than`, `Lower Than`, `Equal`, `Crossing Over`, `Crossing Under`, or `Crossing` are used. For example if the user wants to go **Long** when the HyperWave oscillator cross over 80 the following settings would be used: ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/osc/entry/example-osc.png) ## External Conditions ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/osc/entry/externals.png) Users can use the output of external indicators on the chart as input to set entry conditions. The second dropdown of external condition settings determines which conditional operator to use on both external outputs. These include: * Greater Than * Lower Than * Equal * Crossing Over * Crossing Under * Crossing The third external condition works similarly but instead of comparing two external outputs the condition will compare an external output specified in the condition first dropdown with a user set value in the third dropdown using a conditional operator set on the second dropdown. This last condition is particularly useful for oscillators. Here is an example of the third external condition being set for an RSI crossing over 50. ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/osc/entry/example-external.png) ## Using Conditions Together More complex entry rules can be created by using multiple conditions together, this is done thanks to the **Step** dropdown setting on the right of each condition (below each condition for conditions 4 and 5). The *Step* setting is directly related to the Step & Match algorithm and work in two ways: * When two or more conditions have the same step number, both conditions are evaluated. Used to test matching conditions. * When two or more conditions have different step numbers, each conditions will be evaluated in order, testing for the first step and switching to the next step once the previous one is true. When the final step is true the strategy will open a market order. Used to create sequence of conditions. This operation is complementary, as you can create a sequence of conditions with one step consisting of two or more matching conditions as long as they have the same step number. A user wanting to go long when a bullish divergence occurs after any bullish reversal while money flow was bullish (over 50) could do it as follows: ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/pac/entry/example-stepmatch.png) ### Invalidate Step The "Invalidate" step allows to set a condition as an "invalidation condition". When this condition is triggered while a sequence of conditions is incomplete, the sequence will restart at step 1. If multiple steps are set as "Invalidate" any of the conditions being true will reset the sequence of conditions, as such not all of them are required to be true for the sequence of conditions to reset. Let's take an example where we use 2 regular steps and one "Invalidate" step. The position will be opened when step 2 trigger after step 1 has been triggered. Step 1 condition trigger, we will now evaluate step 2 from now on. Invalidation step condition trigger, we reset the sequence and evaluate step 1 just after. ### Invalidation Behaviors Invalidation behaviors allows adding more restrictions to a sequence of conditions, users can use two different invalidation behaviors described below: #### Invalidate On Step 1 The "Invalidate On Step 1" behavior allows to reset an incomplete sequence of conditions when the condition on step 1 trigger. This prevents the first step condition from happening in between other steps of the condition sequence. This behavior is useful when the first step of our sequence of conditions needs to never be repeated during the sequence. Let's take an example where we use 3 regular steps. Step 1 condition trigger, we will now evaluate step 2 from now on. Step 2 condition trigger, we will now evaluate step 3 from now on. Step 1 condition trigger, we start evaluating step 2 from now. #### Invalidate On Any Repeated Step The "Invalidate On Any Repeated Step" behavior allows to reset an incomplete sequence of conditions when a step is triggered such that it does not respect the set order of conditions. This behavior is useful when we want a perfectly ordered sequence of conditions to complete, without any step repeating itself. Let's take an example where we use 3 regular steps. Step 1 condition trigger, we will now evaluate step 2 from now on. Step 2 condition trigger, we will now evaluate step 3 from now on. Step 1 or 2 conditions trigger, we start evaluating step 1 from now. ## No Existing Positions Requirement Users can enable the **Don't Allow Trades Until Closed** setting in order to only open trade when no existing positions are open. This setting allows waiting for a position to be closed before one can be opened. Enabling **Don't Allow Trades Until Closed** for long positions will prevent opening shorts as long as a long position is opened. If this same setting is not enabled for short conditions then shorts can effectively be closed by new long positions. # Exit Conditions ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/osc/exits/settings.png) Users can close any position on a profit or loss using specific crossing conditions obtained from external sources. Exits conditions can be enabled in the **EXIT CONDITIONS** settings section. Oscillators are intended to be used as external source when it comes to TP/SL conditions, but users can directly create scripts returning scaled outputs from overlay indicators. ### Exit Take Profit Long/Short take profits exits conditions will exit a long or short position when a set condition is met such that the position exit on a profit. Take profits conditions are triggered if they are toggled on for a specific order (Long/Short) and if the selected external source is either **Crossing**, **Crossing Up**, or **Crossing Down**, **Greater Than**, **Lower Than**, or **Equal** to the numerical value specified by the user. ### Exit Stop Losses Long/Short stop losses exits conditions will exit a long or short order when a set condition is met such that the position exit on a loss. Stop losses conditions are triggered if they are toggled on for a specific order (Long/Short) and if the selected external source is either **Crossing**, **Crossing Up**, or **Crossing Down**, **Greater Than**, **Lower Than**, or **Equal** to the numerical value specified by the user. ### Time Exits Time exits allow users to exit trade from a specific time of the day. Note that trades are still exited at the opening of the next bar. The timezone is the same as the one of the chart symbol. ### Placeholders ![Exit Long Take Profit when closing price cross the upper Bollinger band extremity](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/osc/exits/placeholder.png) Users who do not wish to use a numerical value to evaluate a condition with an external source may use a placeholder instead, which allows using prices. The following placeholders are supported: * `open` : Opening price * `high` : High price * `low` : Low price * `close` : Closing price * `hl2` : Median price * `ohlc4` : Average price * `hlc3` : Typical price * `hlcc4` : Weighted price ## Partial Exits ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/partial.png) Users can exit a percentage of an existing position by specifying a percentage lower than 100%. This can lead to sequential exit, with reduced exposure each time an exit is triggered. # Introduction Backtester (OSC) is a script that allows users to perform backtests using features from our [Oscillator Matrix®](/docs/toolkits/oscillator-matrix/introduction) toolkit. Users can create their own entry & exit conditions as well as control take-profit and stop-loss placement. Each core component of the backtester are described in the following pages: # Backtest Parameters The Backtester (OSC) use the following default properties: | Property | Default | Description | | ------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Backtesting Window | Bars | Determines how the backtesting interval is set. If `Bars` is selected the most recent specified amount (in `Window (Bars)`) will be used to backtest the strategy. If `Date` is selected the interval will be set using the specified starting and ending dates, while using "Entire History" will use all the available historical data | | Window (Bars) | 2000 | Amount of the most recent bars used to backtest the strategy if `Bars` is selected in `Backtesting Window` | | Window Start | 2024-01-01 00:00 | Starting date of the backtesting strategy if `Date` is selected in `Backtesting Window` | | Window End | 2024-01-01 00:00 | Ending date of the backtesting strategy if `Date` is selected in `Backtesting Window` and if the `Window End` toggle is enabled | | Initial Capital | 10 000 | Initital amount of funds available at the start of the backtest | | Base Currency | Default | Currency used for performing the backtest, backtest statistics will be expressed using this curreny. If `Default` is selected the symbol currency is used | | Order Size | 1 Contract | Determines the amount of contracts/currency to buy or sell, can be expressed in contracts, currency, or percent of equity | | Commission | 0% | Fees paid per clotured trades, can be expressed as currency per contracts, currency per order, or % of the total transation value | | Margin for long position | 0% | Equity percentage required to fund a position | | Margin for short position | 0% | Equity percentage required to fund a position | These should be adjusted to return more precise and accurate results of the real performance of a trading strategy. # Disclaimer Backtests are not indicative of future results. Backtesting strategies on synthetic data does not return representative results of a strategy. Backtests should be performed on charts returning real closing prices. See [here](https://www.tradingview.com/script/q9laJNG9-Backtesting-on-Non-Standard-Charts-Caution-PineCoders-FAQ/) for more information. *CFTC Rule 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.* # Take Profit & Stop Loss ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/tpsl.png) Users can set take profits and stop losses orders allowing a certain degree of money management in the backtest. Take profits and stop loss orders can be enabled and adjusted from the **FIXED TPS & SLS** settings section. Take profits and stop losses orders are placed relative to the price preceding a trade, and might not be filled at the exact price set by the user. ## TP/SL Options Take profits and stop losses for specific orders can be enabled from the toggles present in their settings section. Take profits and stop losses can be set using various methods described below: | Option | Description | | :-----------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | Price |
Set the take profit/stop loss orders at the specified price.
| | Currency |
Set the take profit/stop loss orders a specified amount of currency away from the closing price preceding the entry of a long/short order.
| | Ticks |
Set the take profit/stop loss orders a specified amount of ticks away from the closing price preceding the entry of a long/short order.
| | % |
Set the take profit/stop loss orders a specified percentage away from the closing price preceding the entry of a long/short order.
| | ATR |
Set the take profit/stop loss orders *N* average true ranges away from the closing price preceding the entry of a long/short order, where *N* is a specified multiplier.
| | Forecast |
(Only available for take profits orders) Use a percentile of a returned forecast to set take profits. Forecasts must be enabled in order for this to work.
| | Trailing Stop |
(Only available for stop loss orders) Enable a percentage based trailing stop. A position will be exited if price reach the trailing stop.
| The average true range used to set take profits/stop losses orders make use of a period of 200 bars. ### Trailing Stop ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/trailing.png) Users can use a percentage based trailing stop to exit positions. The trailing stop will move in the direction of interest if its distance with the low price(in case of long positions) or high price (in case of short positions) is greater than the specified percentage. ### Take Profits Levels From Forecast When forecasts are displayed, users can set take profits using the **nth** percentile of a returned forecast. This can be done from the "TPS & SLS" settings, by selecting "Forecast" in the "Long TP" and/or "Short TP". The numerical setting selected at the right of the drop-down menus determines the percentile used, and should be set within the range \[0, 100] in order to work. Percentiles values can affect the returned levels as follows: * In case of a long trade, a lower set percentile will return take profits closer to the entry price, potentially triggering sooner. * In case of a short trade, a lower set percentile will return take profits further away from the entry price, potentially triggering later. Do note that because forecasts are based on the strategy entries, take profits levels based on it can be subject to repainting, except when using a backtesting window based on a date. # Entry Rules Backtester (PAC) allows users to set their own long/short entry rules from price action related concepts as well as external indicators. Entry rules can be built as sequences of conditions, matching conditions, or a mix of both. More details are provided in the section below. Entry rules can be created separately for both long and short entries, and can be set using up to 6 different user set conditions. Each can enabled by toggling them on using the toggle input on the left of each condition, if the enabled conditions are valid, the strategy will open a corresponding market order. Three types of distinct conditions are available, each described in the sections below. ## Price Action Conditions ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/pac/entry/pac-settings.png) Conditions 1, 2, and 3 work the same way, and allow using conditions from market structures, volumetric order blocks, imbalances, and liquidity grabs. The first dropdown includes options: *Bullish* and *Bearish*, and determines the origin of the selected condition in the second dropdown. The second dropdown includes the list of price action related conditions, these include: | Condition | Description | | :-----------------: | :------------------------------------------------------: | | CHoCH or BOS | Triggered on a change of character or break of structure | | CHoCH | Triggered on a change of character | | BOS | Triggered on a break of structure | | Mitigated OB | Triggered once price mitigates an order block | | Within OB | Triggered if price is within the area of an order block | | Entered OB | Triggered once price enters the area of an order block | | Exit OB | Triggered once price exits the area of an order block | | Entered Imbalance | Triggered once price enters the area of an imbalance | | Within Imbalance | Triggered if price is within the area of an imbalance | | Mitigated Imbalance | Triggered once price mitigates an imbalance | | Exit Imbalance | Triggered once price exits an imbalance | | Liquidity Grab | Triggered once a liquidity grab is detected | For example if the user wants to go **Long** when a new **Bullish** **CHoCH** the following settings would be used: ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/pac/entry/example-pac.png) User can change the settings of each price action concept by scrolling down the settings, each concept has its own setting group. To learn more about each concept see: [Market Structures](/docs/toolkits/price-action-concepts/market-structures) [Order Blocks](/docs/toolkits/price-action-concepts/order-blocks) [Imbalances](/docs/toolkits/price-action-concepts/imbalances) [Liquidity Grabs](/docs/toolkits/price-action-concepts/liquidity) ## External Conditions ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/pac/entry/external-settings.png) Users can use the output of external indicators on the chart as input to set entry conditions. The second dropdown of external condition settings determines which conditional operator to use on both external outputs. These include: * Greater Than * Lower Than * Equal * Crossing Over * Crossing Under * Crossing The third external condition works similarly but instead of comparing two external outputs the condition will compare an external output specified in the condition first dropdown with a user set value in the third dropdown using a conditional operator set on the second dropdown. This last condition is particularly useful for oscillators. Here is an example of the third external condition being set for price crossing over a simple moving average. ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/pac/entry/example-external.png) ## Session Condition ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/pac/entry/session.png) Condition 6 is a session condition, with an active status if current time is within the specified session interval. Session timezone is the same as the one of the chart symbol exchange (UTC for cryptocurrencies) ## Using Conditions Together More complex entry rules can be created by using multiple conditions together, this is done thanks to the **Step** dropdown setting on the right of each condition (below each condition for conditions 4 and 5). The *Step* setting is directly related to the Step & Match algorithm and work in two ways: * When two or more conditions have the same step number, both conditions are evaluated. Used to test matching conditions. * When two or more conditions have different step numbers, each conditions will be evaluated in order, testing for the first step and switching to the next step once the previous one is true. When the final step is true the strategy will open a market order. Used to create sequence of conditions. This operation is complementary, as you can create a sequence of conditions with one step consisting of two or more matching conditions as long as they have the same step number. A user wanting to go long when a bullish break of structure occurs after price mitigated a bearish order block while price was above its 20 period moving average could do it as follows: ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/pac/entry/example-stepmatch.png) ### Invalidate Step The "Invalidate" step allows to set a condition as an "invalidation condition". When this condition is triggered while a sequence of conditions is incomplete, the sequence will restart at step 1. If multiple steps are set as "Invalidate" any of the conditions being true will reset the sequence of conditions, as such not all of them are required to be true for the sequence of conditions to reset. Let's take an example where we use 2 regular steps and one "Invalidate" step. The position will be opened when step 2 trigger after step 1 has been triggered. Step 1 condition trigger, we will now evaluate step 2 from now on. Invalidation step condition trigger, we reset the sequence and evaluate step 1 just after. ### Invalidation Behaviors Invalidation behaviors allows adding more restrictions to a sequence of conditions, users can use two different invalidation behaviors described below: #### Invalidate On Step 1 The "Invalidate On Step 1" behavior allows to reset an incomplete sequence of conditions when the condition on step 1 trigger. This prevents the first step condition from happening in between other steps of the condition sequence. This behavior is useful when the first step of our sequence of conditions needs to never be repeated during the sequence. Let's take an example where we use 3 regular steps. Step 1 condition trigger, we will now evaluate step 2 from now on. Step 2 condition trigger, we will now evaluate step 3 from now on. Step 1 condition trigger, we start evaluating step 2 from now. #### Invalidate On Any Repeated Step The "Invalidate On Any Repeated Step" behavior allows to reset an incomplete sequence of conditions when a step is triggered such that it does not respect the set order of conditions. This behavior is useful when we want a perfectly ordered sequence of conditions to complete, without any step repeating itself. Let's take an example where we use 3 regular steps. Step 1 condition trigger, we will now evaluate step 2 from now on. Step 2 condition trigger, we will now evaluate step 3 from now on. Step 1 or 2 conditions trigger, we start evaluating step 1 from now. ## No Existing Positions Requirement Users can enable the **Don't Allow Trades Until Closed** setting in order to only open trade when no existing positions are open. This setting allows waiting for a position to be closed before one can be opened. Enabling **Don't Allow Trades Until Closed** for long positions will prevent opening shorts as long as a long position is opened. If this same setting is not enabled for short conditions then shorts can effectively be closed by new long positions. # Exit Rules The strategy can include custom long/short orders exits rules. These can be created in a similar way than entry rules by using two available conditions, and can evaluate price action features as well as the output of external indicators on your chart. ## Price Action Conditions ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/pac/exits/settings.png) Conditions *Exit Long 1* and *Exit Short 1* allow using conditions from market structures, volumetric order blocks, and imbalances. The first dropdown includes options: *Bullish* and *Bearish* and determines the origin of the selected condition in the second dropdown. The second dropdown includes the list of price action related conditions, these include: | Condition | Description | | :-----------------: | :------------------------------------------------------: | | CHoCH or BOS | Triggered on a change of character or break of structure | | CHoCH | Triggered on a change of character | | BOS | Triggered on a break of structure | | Mitigated OB | Triggered once price mitigates an order block | | Within OB | Triggered if price is within the area of an order block | | Entered OB | Triggered once price enters the area of an order block | | Entered Imbalance | Triggered once price enters the area of an imbalance | | Within Imbalance | Triggered if price is within the area of an imbalance | | Mitigated Imbalance | Triggered once price mitigates an imbalance | ## External Conditions Conditions *Exit Long 2* and *Exit Short 2* allow the user to use the output of external indicators on the chart as input for setting exit conditions. These allow setting a condition based on two different external indicators output, with The first and third dropdowns determining which external output to use. The second dropdown determines which conditional operator to use on both external outputs. These include: * Greater Than * Lower Than * Equal * Crossing Over * Crossing Under * Crossing ## Using Conditions Together More complex exit rules can be created by using multiple conditions together, this is done thanks to the **Step** dropdown setting on the right of each condition (below each condition for *Exit Long 2* and *Exit Short 2*). The *Step* setting is directly related to the Step & Match algorithm and works in two ways: * When two or more conditions have the same step number, both conditions are evaluated. Used to test matching conditions. * When two or more conditions have different step numbers, each condition will be evaluated in order, testing for the first step and switching to the next step once the previous one is true. When the final step is true the strategy will open a market order. Used to create sequence of conditions. This operation is complementary, as you can create a sequence of conditions with one step consisting of two or more matching conditions as long as they have the same step number. ## Time Exits Time exits allow users to exit trade from a specific time of the day. Note that trades are still exited at the opening of the next bar. The timezone is the same as the one of the chart symbol. ## Partial Exits ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/partial.png) Users can exit a percentage of an existing position by specifying a percentage lower than 100%. This can lead to sequential exit, with reduced exposure each time an exit is triggered. ## Only Exit On A Profit Enabling "Only Exit On A Profit" allows only triggering an exit if this exit leads to a profit, effectively preventing any exit that would lead to a loss. This can be useful to increase winrates of strategies. Enabling this setting alongside "Dont allow trades until closed" can prevent any losing trade from being exited, leading to a theoretical 100% winrate without a stop-loss. Do note however that a unprofitable trade can be held for an unlimited amount of time, leading to unrealistic scenarios. # Introduction Backtester (PAC) is a script that allows users to perform advanced backtests on all features from our [Price Action Concepts®](../../docs/toolkits/price-action-concepts/introduction) toolkit. Users can create their own entry & exit conditions as well as control take-profit & stop-loss placement. Each core components of the system is described on the following pages: # Backtest Parameters The Backtester (PAC) uses the following default properties: | Property | Default | Description | | ------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Backtesting Window | Bars | Determines how the backtesting interval is set. If `Bars` is selected the most recent specified amount (in `Window (Bars)`) will be used to backtest the strategy. If `Date` is selected the interval will be set using the specified starting and ending dates, while using "Entire History" will use all the available historical data | | Window (Bars) | 2000 | Amount of the most recent bars used to backtest the strategy if `Bars` is selected in `Backtesting Window` | | Window Start | 2024-01-01 00:00 | Starting date of the backtesting strategy if `Date` is selected in `Backtesting Window` | | Window End | 2024-01-01 00:00 | Ending date of the backtesting strategy if `Date` is selected in `Backtesting Window` and if the `Window End` toggle is enabled | | Initial Capital | 10 000 | Initital amount of funds available at the start of the backtest | | Base Currency | Default | Currency used for performing the backtest, backtest statistics will be expressed using this curreny. If `Default` is selected the symbol currency is used | | Order Size | 1 Contract | Determines the amount of contracts/currency to buy or sell, can be expressed in contracts, currency, or percent of equity | | Commission | 0% | Fees paid per clotured trades, can be expressed as currency per contracts, currency per order, or % of the total transaction value | | Margin for long position | 0% | Equity percentage required to fund a position | | Margin for short position | 0% | Equity percentage required to fund a position | These should be adjusted to return more precise and accurate results of the real performance of a trading strategy. # Disclaimer Backtests are not indicative of future results. Backtesting strategies on synthetic data does not return representative results of a strategy. Backtests should be performed on charts returning real closing prices. See [here](https://www.tradingview.com/script/q9laJNG9-Backtesting-on-Non-Standard-Charts-Caution-PineCoders-FAQ/) for more information. *CFTC Rule 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.* # Take Profit & Stop Loss ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/tpsl.png) Users can set take profits and stop losses orders allowing a certain degree of money management in the backtest. Take profits and stop loss orders can be enabled and adjusted from the **FIXED TPS & SLS** settings section. Take profits and stop losses orders are placed relative to the price preceding a trade, and might not be filled at the exact price set by the user. ## TP/SL Options Take profits and stop losses for specific orders can be enabled from the toggles present in their settings section. Take profits and stop losses can be set using various methods described below: | Option | Description | | :-----------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | Price |
Set the take profit/stop loss orders at the specified price.
| | Currency |
Set the take profit/stop loss orders a specified amount of currency away from the closing price preceding the entry of a long/short order.
| | Ticks |
Set the take profit/stop loss orders a specified amount of ticks away from the closing price preceding the entry of a long/short order.
| | % |
Set the take profit/stop loss orders a specified percentage away from the closing price preceding the entry of a long/short order.
| | ATR |
Set the take profit/stop loss orders *N* average true ranges away from the closing price preceding the entry of a long/short order, where *N* is a specified multiplier.
| | Forecast |
(Only available for take profits orders) Use a percentile of a returned forecast to set take profits. Forecasts must be enabled in order for this to work.
| | Trailing Stop |
(Only available for stop loss orders) Enable a percentage based trailing stop. A position will be exited if price reach the trailing stop.
| The average true range used to set take profits/stop losses orders make use of a period of 200 bars. ### Trailing Stop ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/trailing.png) Users can use a percentage based trailing stop to exit positions. The trailing stop will move in the direction of interest if its distance with the low price(in case of long positions) or high price (in case of short positions) is greater than the specified percentage. ### Take Profits Levels From Forecast When forecasts are displayed, users can set take profits using the **nth** percentile of a returned forecast. This can be done from the "TPS & SLS" settings, by selecting "Forecast" in the "Long TP" and/or "Short TP". The numerical setting selected at the right of the drop-down menus determines the percentile used, and should be set within the range \[0, 100] in order to work. Percentiles values can affect the returned levels as follows: * In case of a long trade, a lower set percentile will return take profits closer to the entry price, potentially triggering sooner. * In case of a short trade, a lower set percentile will return take profits further away from the entry price, potentially triggering later. Do note that because forecasts are based on the strategy entries, take profits levels based on it can be subject to repainting, except when using a backtesting window based on a date. # Entry Rules ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/s-o/entry/settings.png) Backtester (S\&O) makes use of various features within the Signals & Overlays® toolkit such as [Confirmation and Contrarian Signals](/docs/toolkits/signals-overlays/signals) or [Overlays indicators](/docs/toolkits/signals-overlays/indicator-overlay) to specify entry rules for the strategy. More information regarding signal settings can be found [here](/docs/toolkits/signals-overlays/signal-settings) By default, backtesting is performed using the most recent 2000 bars, this value can be changed from the **Backtest Window (Bars)** setting, the user can also perform a backtest between two specified dates using the "Date" options in "Backtesting Window", or using all the available chart history by using "Entire History" (note that this will not allow the optimizer to run). ## Long/Short Entry Conditions Users can specify their strategy respective long/short entry rules from the **LONG CONDITIONS** and **SHORT CONDITIONS** settings sections, using the following available options: | Condition | Options | Options (2) | Description | | :------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | Signal Type | | |
Enter a position on the occurrence of the user specified signal. Users can select between the Confirmation and Contrarian signals algorithm (Long/Short conditions can use different algorithms), these are affected by the selected Sensitivity and Autopilot frequency settings.

Selecting "Bullish Classifier" or "Bearish Classifier" will open positions on the occurence of a signal with the same classification as the one specified by the user on the rightmost input.
| | Reversal Zones | | |
Enter a position if price is above/under or within the specified extremities.
| | Smart Trail | | |
Enter a position if the Smart Trail switch bullish/bearish or if it is currently bullish or bearish.
| | Trend Tracer | | |
Enter a position if the Trend Tracer switch bullish/bearish or if it is currently bullish or bearish.
| | Trend Catcher | | |
Enter a position if the Trend Catcher switch bullish/bearish or if it is currently bullish or bearish.
| | Neo Cloud | | |
Enter a position if the Neo Cloud switch bullish/bearish or if it is currently bullish or bearish.
| | Trend Strength | | |
Enter a position if the Trend Strength is greater or lower than the specified value.
| | Session | Session interval | |
Enter a position if it is within the user specified session interval.
| | External Condition 1 | | |
Enter a position if the tested condition between the first specified external source and second one is true.
| | External Condition 2 | | |
Enter a position if the tested condition between the first specified external source and second one is true.
| | External Condition 3 | | |
Enter a position if the tested condition between the first specified external source and second one is true. Users can use price placeholers such as open, high, low, close, hl2, ohlc4, hlc3, and hlcc4 instead of a numerical value in the second source input.
| Multiple conditions can be enabled at the same time, in which case the backtester will require all conditions to be true in order to execute an order. If the **Exit On Signal** setting is enabled, existing positions will be exited on the occurrence of a confirmation/contrarian signal if enabled. ## No Existing Positions Requirement Users can enable the **Don't Allow Trades Until Closed** setting in order to only open trade when no existing positions are open. This setting allows waiting for a position to be closed before one can be opened. Enabling **Don't Allow Trades Until Closed** for long positions will prevent opening shorts as long as a long position is opened. If this same setting is not enabled for short conditions then shorts can effectively be closed by new long positions. # Exit Conditions ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/s-o/exits/settings.png) Users can close any position on a profit or loss using specific crossing conditions obtained from a user selected external source and/or by using our builtins exits. Exits conditions can be enabled in the **EXIT CONDITIONS** settings section. ## External Exits ### Exit Take Profit Long/Short take profits exits conditions will exit a long or short position when a set condition is met such that the position exit on a profit. Take profits conditions are triggered if they are toggled on for a specific order (Long/Short) and if the selected external source is either **Crossing**, **Crossing Up**, or **Crossing Down**, **Greater Than**, **Lower Than**, or **Equal** to the numerical value specified by the user. ### Exit Stop Losses Long/Short stop losses exits conditions will exit a long or short order when a set condition is met such that the position exit on a loss. Stop losses conditions are triggered if they are toggled on for a specific order (Long/Short) and if the selected external source is either **Crossing**, **Crossing Up**, or **Crossing Down**, **Greater Than**, **Lower Than**, or **Equal** to the numerical value specified by the user. ### Placeholders ![Exit Long Take Profit when closing price cross the upper Bollinger band extremity](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/s-o/exits/placeholder.png) Users who do not wish to use a numerical value to evaluate a condition with an external source may use a placeholder instead, which allows using price data. The following placeholders are supported: * `open` : Opening price * `high` : High price * `low` : Low price * `close` : Closing price * `hl2` : Median price * `ohlc4` : Average price * `hlc3` : Typical price * `hlcc4` : Weighted price ## Builtins Exits Builtin exits are included for the selected signal algorithm, these are the same as the ones present in the Signals & Overlays® toolkit and can be used in the Backtester to exit positions. Builtin exits will always exit a position on a profit. ## Time Exits Time exits allow users to exit trade from a specific time of the day. Note that trades are still exited at the opening of the next bar. The timezone is the same as the one of the chart symbol. ## Exit On Opposite Signal Enabling the **Exit On Opposite Signal** setting will close any position once an opposite signal is generated (if enabled). ## Partial Exits ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/partial.png) Users can exit a percentage of an existing position by specifying a percentage lower than 100%. This can lead to sequential exits, with reduced exposure each time an exit is triggered. # Introduction Backtester (S\&O) is a script that allows users to perform backtests using features from our [Signals & Overlays®](/docs/toolkits/signals-overlays/introduction) toolkit. Many options are included to provide more complete & diverse backtests to the user, and each core component of the system are described in the following pages: # Backtest Parameters The Backtester (S\&O) use the following default properties: | Property | Default | Description | | ------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Backtesting Window | Bars | Determines how the backtesting interval is set. If `Bars` is selected the most recent specified amount (in `Window (Bars)`) will be used to backtest the strategy. If `Date` is selected the interval will be set using the specified starting and ending dates, while using "Entire History" will use all the available historical data | | Window (Bars) | 2000 | Amount of the most recent bars used to backtest the strategy if `Bars` is selected in `Backtesting Window` | | Window Start | 2024-01-01 00:00 | Starting date of the backtesting strategy if `Date` is selected in `Backtesting Window` | | Window End | 2024-01-01 00:00 | Ending date of the backtesting strategy if `Date` is selected in `Backtesting Window` and if the `Window End` toggle is enabled | | Initial Capital | 10 000 | Initial amount of funds available at the start of the backtest | | Base Currency | Default | Currency used for performing the backtest, backtest statistics will be expressed using this curreny. If `Default` is selected the symbol currency is used | | Order Size | 1 Contract | Determines the amount of contracts/currency to buy or sell, can be expressed in contracts, currency, or percent of equity | | Commission | 0% | Fees paid per closed trades, can be expressed as currency per contracts, currency per order, or % of the total transation value | | Margin for long position | 0% | Equity percentage required to fund a position | | Margin for short position | 0% | Equity percentage required to fund a position | These should be adjusted to return more precise and accurate results of the real performance of a trading strategy. # Disclaimer Backtests are not indicative of future results. Backtesting strategies on synthetic data does not return representative results of a strategy. Backtests should be performed on charts returning real closing prices. See [here](https://www.tradingview.com/script/q9laJNG9-Backtesting-on-Non-Standard-Charts-Caution-PineCoders-FAQ/) for more information. *CFTC Rule 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.* # Optimization ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/s-o/optimization/optimization.png) When signals are used to perform a backtest, the Backtester is able to return the **Sensitivity** setting that maximized a user specified statistic such as net profit, winrate, profit factor, or maximum drawdown. Certain settings will disable the optimization procedure, such as disabling the backtesting window or using autopilot. ## Procedure ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/s-o/optimization/settings.png) Users can choose to optimize net profit, winrate, profit factor, potential ratio $(\varphi)$ or maximum drawdown depending on the options selected from the **Optimize** drop-down menu within the **OPTIMIZER** settings section. The overall profit or loss achieved (higher is better). The percentage of winning trades (higher is better). The gross profits over gross losses generated by the strategy (higher is better). A value higher than 1 suggest that the strategy generated more profits than losses. The greatest decline of the strategy relative to the highest net profits (Lower is better). A lower value is indicative of a strategy less subject to large downside variability. The ratio between the sum of maximum potential profits you could have made in your trades over the sum of maximum potential losses you could have made in your trades (higher is better). Higher values indicates that the entries generated by the strategy have the potential to lead to larger profits compared to losses. Lower values however might be indicative of a more risky strategy, with more frequent exposure to larger potential losses. If the backtest with the highest potential ratio is not the one with the highest potential profit then it can be indicative of a strategy with more potential with a tendency to exit trades potentially too late. Optimization can be performed on any given range for the **Sensitivity** setting. Optimizing the **Sensitivity** setting using a large range of values and/or using a large backtest window can increase computation time, potentially returning time-out errors. Results from the optimizer can vary from the backtest results returned by the strategy, this is due to the difference between how the Tradingview backtesting engine opens positions compared to the internal engine used to perform optimization within the script. Using different signal algorithms for long/short entry rules can return very different results from the optimizer compared to backtesting results. Take profits and/or stop losses orders are taken into account by the internal engine if these are enabled, however, there can still exist a great degree of disparity between results from the backtest and results returned by the optimizer. ### Warmup Period The warmup period allows the script to compute the signal algorithms *n* bars prior to the backtesting window, where *n* is the selected warmup period. This allows to backtest signals that are closer to the ones returned by the Signals & Overlays® toolkit, returning more accurate optimized settings as a result. ## Optimization Dashboard ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/s-o/optimization/dashboard.png) Users can see the backtests results for sensitivity values within the specified optimization range on a dashboard shown on the top-right of their chart. This dashboard presents results in descending order, with results associated to the best optimized statistic appearing on top. ### Simple ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/s-o/optimization/simple.png) Users that do not wish to have a large dashboard on the chart can use the **Simple** optimization dashboard. This dashboard will only return the **Sensitivity** setting that optimize the selected statistic alongside the statistic of interest. ### Display ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/s-o/optimization/display.png) Users can control the location as well as hide the optimization dashboard on the chart from the **DISPLAY** settings section. A dashboard location set to **None** will hide it from the chart as well as disable the optimizer. # Take Profit & Stop Loss ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/tpsl.png) Users can set take profits and stop losses orders allowing a certain degree of money management in the backtest. Take profits and stop loss orders can be enabled and adjusted from the **FIXED TPS & SLS** settings section. Take profits and stop losses orders are placed relative to the price preceding a trade, and might not be filled at the exact price set by the user. ## TP/SL Options Take profits and stop losses for specific orders can be enabled from the toggles in their settings section. Take profits and stop losses can be set using various methods described below: | Option | Description | | :-----------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | Price |
Set the take profit/stop loss orders at the specified price.
| | Currency |
Set the take profit/stop loss orders a specified amount of currency away from the closing price preceding the entry of a long/short order.
| | Ticks |
Set the take profit/stop loss orders a specified amount of ticks away from the closing price preceding the entry of a long/short order.
| | % |
Set the take profit/stop loss orders a specified percentage away from the closing price preceding the entry of a long/short order.
| | ATR |
Set the take profit/stop loss orders *N* average true ranges away from the closing price preceding the entry of a long/short order, where *N* is a specified multiplier.
| | Forecast |
(Only available for take profits orders) Use a percentile of a returned forecast to set take profits. Forecasts must be enabled in order for this to work.
| | Trailing Stop |
(Only available for stop loss orders) Enable a percentage-based trailing stop. A position will be exited if the price reaches the trailing stop.
| The average true range used to set take profits/stop losses orders uses a period of 200 bars. ### Trailing Stop ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesters/trailing.png) Users can use a percentage-based trailing stop to exit positions. The trailing stop will move in the direction of interest if its distance with the low price (in case of long positions) or high price (in case of short positions) is greater than the specified percentage. ### Take Profits Levels From Forecast When forecasts are displayed, users can set take profits using the **nth** percentile of a returned forecast. This can be done from the "TPS & SLS" settings, by selecting "Forecast" in the "Long TP" and/or "Short TP". The numerical setting selected at the right of the drop-down menus determines the percentile used, and should be set within the range \[0, 100] in order to work. Percentiles values can affect the returned levels as follows: * In case of a long trade, a lower set percentile will return take profits closer to the entry price, potentially triggering sooner. * In case of a short trade, a lower set percentile will return take profits further away from the entry price, potentially triggering later. Do note that because forecasts are based on the strategy entries, take profits levels based on it can be subject to repainting, except when using a backtesting window based on a date. # Fetching Information ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesting-assistant/fetching-information/smart_trail.png) The AI Backtesting Assistant is able to fetch our product documentation to provide relevant information to you about the features used by a retrieved strategy or to simply help you learn more about our products. The AI will automatically determine whether it requires fetching context from the documentation depending on the user query. You can force the AI to fetch information from the documentation by telling it to fetch the documentation. For example: > Tell me more about confirmation signals, use the documentation This can prevent the AI from giving partial information he might know from his existing context window. ## Detailed Strategy Descriptions Using Docs ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesting-assistant/fetching-information/explanation.png) We can request for the AI to provide important context about the conditions returned by a trading strategy. ## Using Docs to Get Tailored Strategies By asking the AI to learn more about the LuxAlgo features from the documentation, we can effectively get unique trading strategies by simply mentioning trading styles. For example, we can use the following prompt: > From the documentation search for the best features for swing trading, then find a strategy using those features that provides good results on crypto on the hourly timeframe # Fetching Strategies ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesting-assistant/fetching-strategies/chat.png) The primary role of the AI Backtesting Assistant is to help users find strategies quickly without having to iterate through various conditions, tickers, and timeframes on TradingView. Instead, we can simply ask the AI to look for the strategy that would best match our criterias. The AI Backtesting Assistant has access to approximately 1000 different strategies, half using our S\&O toolkit and the other half using our PAC toolkit. This AI tool’s backtesting data & analytics are for informational purposes only and do not constitute financial advice or recommendations to buy or sell any financial product, including but not limited to securities, derivatives, cryptocurrencies, or other investment instruments. This tool may contain errors, and past performance is not indicative of future results. Always conduct your own research and consult with a professional financial advisor. LuxAlgo is not liable for any decisions made based on any information given. Read our [full disclaimer](https://www.luxalgo.com/legal/disclaimer/). ## Strategies Configuration Strategies accessible by the AI backtesting assistant are backtested using an initial capital of 10000\$, without commissions/slippage, and using default toolkits settings (except for the PAC which use's a different invalidation behavior). Unit position sizing is used across al tickers except forex pairs who use a standard lot (100 000 units). The strategies the AI can access don’t make use of all the features within our toolkits, see the section below to learn more about the supported tickers, timeframes, and backtesting conditions. Any strategy with 0 closed trades will not be accessible by the AI. Strategies do note make use of stop losses or take profits. ### Supported Tickers The following tickers are supported: * SPY * QQQ * ES1! * NQ1! * YM1! * CL1! * NVDA * TSLA * AAPL * MSFT * META * AMZN * BTCUSDT * ETHUSDT * SOLUSDT * BNBUSDT * EURUSD * GBPUSD * USDJPY * XAUUSD ### Supported Timeframes The 5m, 15m, and 60m timeframes are supported. ### S\&O Conditions Strategies constructed from our S\&O toolkit use a single condition or a combination of two conditions for the long and short entry conditions. Only the following conditions are considered: * Confirmation Any Bullish * Confirmation Normal Bullish * Confirmation Strong Bullish * Contrarian Any Bullish * Contrarian Normal Bullish * Contrarian Strong Bullish * Reversal Zones Price Cross Under S1 * Smart Trail Bullish * Trend Tracer Bullish * Trend Catcher Bullish * Neo Cloud Bullish * Confirmation Any Bearish * Confirmation Normal Bearish * Confirmation Strong Bearish * Contrarian Any Bearish * Contrarian Normal Bearish * Contrarian Strong Bearish * Reversal Zones Price Cross Over R1 * Smart Trail Bearish * Trend Tracer Bearish * Trend Catcher Bearish * Neo Cloud Bearish * Trend Strength Trending (Trend Strength greater than 50) * Trend Strength Ranging (Trend Strength lower than 50) It is possible for a long/short entry condition to contain both bullish and bearish conditions #### S\&O Exits Strategies making use of Confirmation or Reversal Zones based conditions can make use of the following exit conditions: * Confirmation Builtin Exits * Contrarian Builtin Exits * Price Cross R1/S1 Average ### PAC Conditions Strategies based on the PAC can use a maximum of three steps and invalidate entry conditions on any repeated step. * Bullish CHoCH * Bullish BOS * Bullish Entered OB * Bullish Exit OB * Bullish New FVG * Bullish Liquidity Grab * Bearish Mitigated FVG * Bearish CHoCH * Bearish BOS * Bearish Entered OB * Bearish Exit OB * Bearish New FVG * Bearish Liquidity Grab * Bullish Mitigated FVG PAC strategies do not make use of exit conditions. ## How To Fetch Strategies ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesting-assistant/fetching-strategies/landing.png) Interacting with the AI Backtesting Assistant is straightforward. All users need to do is enter a prompt in the input prompt located at the bottom of the chat. Here are examples of prompts that will trigger the AI Assistant strategy retrieval ability: * What is the best performing strategy across all crypto tickers on the 5-minute timeframe? * Get three strategies using fair value gaps that have a winrate above 80% * Find a strategy with above average net profit but under average drawdown Users can also click on one of the suggested prompts in the search group located above the input prompt. The AI can access the following strategy backtesting results: * Net Profit * Executed Trades * Percentage Winrate * Max Drawdown Percent * Profit Factor * Average Trade * Average Winning Trade * Average Loosing Trade ![Strategy Results](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesting-assistant/fetching-strategies/table.png) These results will be returned in a table, if multiple strategies are returned, they will be all located within that table. Sometimes the AI can fetch strategies in the middle of a response; this will return another table containing the strategies fetched. A maximum of five strategies can be returned in a table, while a maximum of three strategies can be returned from a single fetching operations. If the AI needs to fetch more than 3 strategies it will fetch strategies in parallel. The AI has also access to the following information from a strategy: * Strategy start time, that is when the strategy starts being evaluated * Strategy current position (long, short, or none) * Best signal sensitivity for a strategy using confirmation or contrarian signals ![Strategy Results](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesting-assistant/fetching-strategies/best_sensitivity.png) ### Fetch Statistics Across The Strategy Population ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesting-assistant/fetching-strategies/compare.png) The AI can also get general statistics and data across the population of strategies being backtested. Example of prompts doing this are: * What is the total net profit of bitcoin strategies? * On BTCUSD, are strategies using normal signal better than the ones using strong signals overall? * What is total net profit of profitable strategies across stocks? This can be useful to get big picture information about strategies. ## Add a Strategy to Your Chart Once you get a strategy you like from the AI, you might want to add it to your chart. To do so, follow these steps: Go to your TradingView chart, then open the indicator menu, locate the Backtester of the toolkit related to the strategy you want to add. Go in the backtester settings, then select "Date" in the "Backtest Window" setting, then adjust "Window Start" with the strategy start time provided by AI. Adjust the long and short entry conditions in the backtester based on the conditions returned by the AI. Make sure to use "Invalidate On Any Repeated Step" in the "Invalidation behavior" dropdowns for PAC strategies. Strategies the AI has access to have a defined starting point. Users might not be able to reproduce exact strategy results due to the limitation on how much data certain users can access. ## Saving Strategies ![](https://mintlify.s3.us-west-1.amazonaws.com/luxalgo/public/images/backtesting-assistant/fetching-strategies/saving.png) Users can export strategies within a table as a csv using the download icon located under it. ## Prompting Tips The AI can make mistakes when fetching strategies, as this is a very complex process depending on the user query. We expect to improve the backtesting AI assistant over time; however, the following tips can help you get the most from our AI. ### Make Detailed Queries Make sure to detail every aspect of the strategy you want to fetch if you have a precise one in mind, for example: | Original | Improved | | ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | | Fetch a strategy that only makes use of confirmation signals | Fetch a strategy that only uses confirmation signals and no other conditions | | I want a PAC strategy that goes long on a new FVG, and CHoCH | I want a PAC strategy that goes long when:

- Step 1: a new bullish FVG occur
- Step 2: a bullish CHoCH occur | | I want the best strategy | I want the strategy with the highest net profit | Context and details will help the AI avoid making guesses about your query. ### Encourage the AI to Improve The AI Backtesting Assistant can be fairly self-aware if a fetched strategy doesn't meet a user criteria, and will then retry. But if the AI response is clearly mistaken, then it can be good to let him know using a prompt encouraging re-evaluation of the fetching process: > The strategy your returned is not the one I want. Correct the issue in your fetching process and retry to fetch the strategy in accordance with my query. ### Split Complex Queries Into Multiple Tasks The AI will be more prone to mistakes if the query is complex, as such, it can be best to make use of follow-ups to ask about details over a strategy rather than asking the AI to give those alongside other information. For example: > Return a good strategy on BTCUSDT, alongside the average net profit of all strategies on BTCUSDT that use Confirmation signals, then tell me what is the highest winrate strategy using the same conditions as the first one The AI Backtesting assistant might provide more relevant answers if we let context accumulate by splitting and re-ordering our initial query into multiple ones: Return a good strategy on BTCUSDT Find the strategy with the highest winrate that use the same exact entry conditions returned previously Return the average net profit of all strategies on BTCUSDT that use Confirmation signals # Introduction