Testing and Customizing Your Trading Algorithms
Testing and Customizing Your Trading Algorithms
TESTING &
CUSTOMIZING
.YOUR TRADING ALGORITHMS
Disclaimer
The information provided in this guide is for educational and informational purposes only.
AlgoTrade Pro, its creators, and affiliated entities do not provide financial, investment, or trading
advice. The use of the algorithms, strategies, and tools described in this guide is entirely at the
user's own risk. Trading in financial markets, including but not limited to stocks, forex,
cryptocurrencies, and other asset classes, involves substantial risk and may result in significant
or complete loss of capital. All trades should be considered in light of your individual risk
tolerance, financial situation, and investment objectives. It is important to conduct your own
research, seek professional advice, and consider your personal circumstances before engaging
in any trading activity.
While AlgoTrade Pro aims to provide accurate and effective algorithms and tools, no guarantees
are made regarding the performance or profitability of any strategy or trading algorithm. Past
performance is not indicative of future results. Market conditions, liquidity, volatility, and other
factors can influence the effectiveness of trading strategies, and results may vary from user to
user.
Any backtesting or forward testing done using AlgoTrade Pro's tools is for educational and
research purposes only. Results obtained through backtesting are not necessarily reflective of
actual market conditions, and live trading may produce different outcomes. The algorithms and
strategies should be tested in a simulated environment before live trading with real capital.
By using the tools, algorithms, or strategies provided in this guide, you acknowledge that you
assume full responsibility for any trading decisions made. AlgoTrade Pro and its creators,
including any third-party contributors, are not responsible for any financial losses, damages, or
other consequences arising from the use of these tools or strategies. Users should only trade
with capital they can afford to lose.
AlgoTrade Pro, its creators, and affiliated entities are not liable for any direct, indirect, incidental,
special, consequential, or punitive damages arising from the use or inability to use the
information or tools presented in this guide, including but not limited to losses in trading or
investments.
All content provided in this guide, including the algorithms, strategies, and related materials, is
the intellectual property of AlgoTrade Pro and may not be reproduced, distributed, or shared
without proper authorization.
AlgoTrade Pro reserves the right to update or modify the contents of this guide at any time
without prior notice. The information contained within may change as new updates or features
are introduced.
AlgoTrade Pro reserves the right to update or modify the contents of this guide at any time
without prior notice. The information contained within may change as new updates or features
are introduced.
Contents
Disclaimer ...................................................................................................................................... 0
1. Introduction............................................................................................................................... 8
1.1 Purpose of the Manual ........................................................................................................ 8
1.2 Overview of the Algorithm .................................................................................................. 8
1.3 Why Customizing the Algorithm Matters ............................................................................ 9
1.4 Getting Started with TradingView ....................................................................................... 9
2. Quick Version........................................................................................................................... 10
2.1. Adding the Algorithm to Your Chart ................................................................................. 10
2.2. Customizing the Algorithm: Settings Menu...................................................................... 11
2.3. Inputs Tab: Customization Options .................................................................................. 12
2.4. Monitoring Strategy Performance.................................................................................... 20
3. Long Version ............................................................................................................................ 22
3.1. Adding the Algorithm to Your Chart ................................................................................. 22
3.2. Customizing the Algorithm: The Settings Menu ............................................................... 23
3.3. Inputs Tab: Key Customization Options ............................................................................ 25
3.3.1. Trading Range: Defining Your Backtest Period .......................................................... 25
3.3.2. Trading Sessions: Defining Your Active Trading Hours ............................................... 28
3.3.3. Day Filter ................................................................................................................... 29
3.3.4. Risk Management: Calculating Risk Per Trade........................................................... 30
3.3.5. Position Sizing: ATR and Contract Sizing .................................................................... 33
3.3.6. Take Profit Options .................................................................................................... 35
3.3.7. Additional Rules ........................................................................................................ 37
3.3.8. Indicators ................................................................................................................... 39
3.3.9. Trade Type ................................................................................................................. 43
3.3.10. PineConnector ......................................................................................................... 44
3.3.11. Monthly Results Table ............................................................................................. 53
3.4. Properties Tab .................................................................................................................. 55
3.4.1. Initial Capital.............................................................................................................. 55
3.4.2. Base Currency ............................................................................................................ 56
3.4.3. Order Size .................................................................................................................. 56
3.4.4. Pyramiding................................................................................................................. 56
3.4.5. Commission ............................................................................................................... 57
3.4.6. Verify Price for Limit Orders ...................................................................................... 58
3.4.7. Slippage ..................................................................................................................... 58
Index of Figures
Figure 1 - TradingView's Indicators Tab ....................................................................................... 10
Figure 2 - Invite-Only Scripts Tab ................................................................................................. 10
Figure 3 - Script's Settings Button................................................................................................ 11
Figure 4 - Algorithms’ Main Tabs ................................................................................................. 11
Figure 5 - Trading Range Section ................................................................................................. 12
Figure 6 - Trading Sessions Section.............................................................................................. 12
Figure 7 - Custom Session Time Option ...................................................................................... 13
Figure 8 - Day Filter Section......................................................................................................... 13
Figure 9 - Risk Management Section ........................................................................................... 14
Figure 10 - Position Sizing Section ............................................................................................... 14
Figure 11 - Risk Management Options ........................................................................................ 14
Figure 12 - Exit Condition Type Options ...................................................................................... 15
Figure 13 - Trading Nuances Section ........................................................................................... 15
Figure 14 - Baseline ATR Bands ................................................................................................... 16
Figure 15 - C1's Indicators Options .............................................................................................. 16
Figure 16 - C2's Indicators Options .............................................................................................. 17
Figure 17 - Volume's Indicators Options ..................................................................................... 17
Figure 18 - Exit's Indicators Options ............................................................................................ 17
Figure 19 - Baseline's Indicators Options .................................................................................... 18
Figure 20 - Indicator's Inputs (Examples) .................................................................................... 18
Figure 21 - Trading Options Section ............................................................................................ 18
Figure 22 - PineConnector Section .............................................................................................. 19
Figure 23 - Monthly Performance Table Example ....................................................................... 19
Figure 24 - Monthly Performance Table Section ......................................................................... 19
Figure 25 - Overview Tab ............................................................................................................. 20
Figure 26 - Performance Summary Tab ....................................................................................... 20
Figure 27 - List of Trades Tab ....................................................................................................... 20
Figure 28 - Properties Tab ........................................................................................................... 21
Figure 29 - "Go To" Button Location ............................................................................................ 26
Figure 30 - Insert your Date here ................................................................................................ 26
Figure 31 - Last Available Bar Example ........................................................................................ 27
Figure 32 - Sessions Plots on the chart (London Example) ......................................................... 29
Figure 33 - Risk Management: Fixed Risk Per Trade Option ........................................................ 30
1. Introduction
The goal is to streamline strategy testing and automation on TradingView, enabling both
beginner and experienced traders to analyze past market data, optimize their strategies, and
leverage automation in their trading process. This guide includes both a Quick Version for
immediate implementation and a Long Version for in-depth understanding.
Additionally, the bot can be configured to provide alert notifications whenever new signals
appear, making it a partially automated solution. This allows traders to receive real-time
notifications (e.g., via mobile message or push notifications), prompting them to act on trades.
Although this requires the trader to manually execute the trade in their broker's platform, it still
significantly reduces the need for constant monitoring.
For traders seeking complete automation, the bot can also be fully integrated with their trading
strategy, including real-time execution, depending on the setup.
• Risk management with customizable stop loss, take profit, and trailing stop features.
By utilizing the bot, traders can quickly test and refine their strategies without the need for
manual backtesting, allowing them to focus on more strategic decision-making and improve
overall trading performance.
Once logged in, navigate to the Indicators tab in the TradingView platform:
3. You will find the algorithm listed there. Click on it once to add it to your chart.
From there, you can begin customizing the algorithm and integrating it into your trading strategy.
This process is simple, and we provide further instructions on how to modify the settings to suit
your needs.
2. Quick Version
This quick guide provides an overview of the main steps and settings for using the algorithm and
monitoring its performance on TradingView. Follow the steps and customize the settings as
needed. For a more detailed explanation, refer to the Long version.
3. Select the Invite-only Scripts tab where all exclusive scripts are available.
4. Find the name of the algorithm you were granted access to and click on it.
5. The algorithm will be automatically added to your chart after a few seconds.
Tip: If the algorithm doesn’t appear immediately, wait for a few seconds or refresh the
TradingView page.
Within the settings menu, you will find four main tabs:
• Inputs
• Properties
• Style
• Visibility
Here, we will detail the options available in the Inputs tab, which is the most extensive and
important for customizing the algorithm.
1. Properties: This tab allows users to adjust the core parameters of the indicator or
strategy, such as fundamental settings that affect its behavior.
2. Style: In this tab, users can customize the visual appearance of the indicator or strategy,
including colors, line styles, and other visual elements that make it easier to interpret on
the chart.
3. Visibility: This tab controls when and where the indicator or strategy will be visible, such
as on specific timeframes or chart types, helping users refine their trading setup.
1. Trading Range:
Start Date and End Date: Define the period for backtesting.
- Example: If you want to test the algorithm from 2020 to 2022, set the start date to
01/01/2020 and the end date to 31/12/2022.
- For live trading, set the end date to a future date, like 31/12/2050.
The algorithm will only take trades within the defined date range.
This feature can be used for in-sample and out-of-sample testing, allowing you to compare the
strategy’s effectiveness.
2. Trading Sessions:
Enable the option Activate Trading Sessions to restrict trading to specific sessions of the day.
Choose between Sydney, Tokyo, London, and New York sessions, or create your own custom
session by setting start and end times.
Adjust for UTC on the “Custom session Time”: Keep in mind that times are set in UTC. If you're
in a different timezone, you will need to adjust for that.
Show Session Plots: Displays the sessions on the chart with different colors.
Exit at End of Session: Forces the algorithm to close all positions at the end of the session, even
if Take Profit or Stop Loss has not been triggered.
3. Day Filter:
By default, all days are selected. To unselect a day, simply click the checkbox next to the day.
4. Risk Management:
Fixed Risk per Trade or Fixed Contracts: Choose how you want to manage your risk.
- If you choose fixed risk, the algorithm will calculate the amount to risk per trade based
on your risk percentage (e.g. 2% = 0.02; 0,5% = 0.005, etc.)
- If you opt for fixed contracts (TradingView lot size), risk will be determined by the
number of contracts in each trade.
Compounding: If enabled, the algorithm will reinvest profits from previous trades, increasing the
risk amount as the balance grows.
5. Position Sizing:
Choose how to calculate your Stop Losses, Take Profits and/or Trailing Stop Losses. You have got
two options:
- 1 Take Profit (1 TP): The entire position will be closed at the Take Profit level selected by
the user in the previous section, whether using a fixed pip value or an ATR multiple.
- 2 Take Profits (2 TPS): This option utilizes a more advanced risk management strategy.
In this case, a portion of the position will be closed at the first Take Profit level defined
by the user, while the remaining part of the position will stay open with a Trailing Stop
Loss (also defined by the user in the Position Sizing Section).
The purpose of the Trailing Stop Loss is to maximize profits by scaling as the price moves
in favor of the trade, without a fixed Take Profit.
To define the percentage of the position that will be closed at the first Take Profit, users
can configure the Partial Profits Percentage option (e.g. 50% = 0.5)
7. Additional Rules:
Candle Rule: Adds a waiting period (user-defined on the “Multiple”) before confirming a trade,
ensuring all conditions stay aligned. For example, if one condition (like volume) is unmet, the bot
will wait for one more candle to see if it aligns. This rule is helpful for higher timeframes, filtering
out false signals and improving entry accuracy.
Baseline ATR Rule: Ensures entries are only considered if the price is within a specific distance
from the baseline, defined by a Multiple of the ATR. This limits entries to a range near the trend
level, preventing trades when the price is too far away. The ATR Plus and ATR Minus bands
visually represent the allowed entry range.
8. Indicators:
- C1 (Main Indicator): The primary indicator that can be selected from the "Indicators"
tab. Once selected, you can assign it specific functions like trigger, confirmation, or exit
signal. We currently offer over 50 options, with new indicators being added regularly.
This flexibility allows you to tailor the strategy to your trading style by choosing the most
appropriate indicator for your setup.
- C2 (Secondary Indicator): Also known as the "Filter," this indicator functions in the same
way as the C1, allowing you to select from the same range of options. The key difference
is that it acts solely as a secondary confirmation tool for trade entries, enhancing the
accuracy of your signals.
- Volume: Similarly to the C2 Indicator Option, there are over 10 volume indicators
Image
available for selection. These can be used to confirm entry 3 - C2
signals, Indicator
providing additional
Options
context to the market's activity and ensuring more robust (Examplewhen
decisions with some
entering a
trade. options)
- Baseline Indicator: This includes over 15 options like moving averages, which function
similarly to the C1 indicator. You can use it as a trigger, confirmation, or exit signal, just
like the main indicator. Baseline indicators are useful for identifying trends or price
movements in the market, and their signals can confirm other indicators. New baseline
options are regularly added to the platform.
Each of these indicator options comes with an additional section to adjust their inputs and
settings, providing you with full control over the customization of your trading strategy. Below
the section where you select your indicators, you will find the inputs for each available option in
a list, where you can modify the settings as needed. Here are a few examples below:
9. Trade Type:
Set whether the algorithm should trade buy only, sell only, or both.
10. PineConnector:
To automate the strategy by using the PineConnector, enable the "Use PineConnector
Automation" option. Simply click this option if you wish to use this functionality.
Next to it, you’ll find a tooltip with a detailed description that guides you step-by-step on how to
automate your strategy using PineConnector. There are four fields you need to fill in, and the
tooltip provides clear instructions for each of them.
Additionally, for symbol changes, there is a section for the symbol override, with tooltips
explaining how it works.
Enable this option to display the algorithm’s monthly results, making it easier to track
performance over time.
1. Overview: Displays the equity curve, net profit, win rate, profit factor, max drawdown,
average profit/loss per trade, and average trade duration.
2. Performance Summary: Provides detailed statistics specific to the selected asset, such
as annualized return, Sharpe ratio, and max consecutive wins/losses.
3. List of Trades: Shows all trades executed. The Export Data button allows you to
download the data as a CSV file for further analysis in Excel, which is useful if you want
to track results across multiple assets. For more information on using the exported data,
check our Trading Journal Guide.
4. Properties: Shows the settings used for the current results, including risk management
and position sizing.
This was a quick overview of the essential steps to get started with the algorithm. For a more
detailed explanation, including in-depth insights into the algorithm’s functionality and additional
educational content, please proceed to the next page: Long version. Here, we provide
comprehensive information to help you make the most of this tool and optimize your trading
strategy effectively.
3. Long Version
This detailed guide provides an in-depth explanation of each step and setting required to fully
customize and optimize the algorithm on TradingView. It covers everything from adding the
algorithm to your chart, adjusting key settings like trading sessions, risk management, position
sizing, and trade rules, to understanding important indicators and their impact on the strategy.
With comprehensive examples and technical insights, this version is designed for traders looking
to fine-tune their approach and enhance their algorithmic trading experience.
1. Log into your TradingView Account: Ensure you are logged into your TradingView
account where your subscription is active.
2. Click on "Indicators" at the Top of the Screen: On the TradingView interface, you'll find
the "Indicators" button at the top toolbar of your chart. Click it to open the indicators
search menu. (Check Figure 1)
3. Navigate to the "Invite-Only Scripts" Tab: In the search bar, click the "Invite-Only
Scripts" tab, where all the exclusive scripts you have access to are listed. (Check Figure
2)
4. Select the Algorithm: Scroll through your list of "Invite-only" scripts and locate the
algorithm you wish to use. Once you find it, simply click on it, and the script will be
automatically added to your chart.
Tip: If you don’t see the script immediately after clicking, try refreshing your page or waiting for
a few moments.
1. Hover Over the Algorithm Label on Your Chart: Place your cursor over the algorithm’s
label on the chart. This is where you’ll initiate the settings menu for further adjustments.
2. Open the Configuration Menu: Click the "Settings" icon (represented by a gear) that
appears when hovering over the algorithm label. This will bring up the settings menu,
allowing you to modify the algorithm’s parameters. (Check Figure 3)
Inside the settings menu, you’ll see four primary tabs, each designed to handle a specific aspect
of the algorithm: (Check Figure 4)
• Inputs: This is the most comprehensive section, allowing you to adjust various inputs
like trading range, risk management settings, position sizing, and more. Here, you can
define how the algorithm will operate, including custom configurations for your trading
style.
• Properties: This tab includes core parameters that affect the behavior of the algorithm.
It’s essential for adjusting foundational settings that influence how the algorithm
behaves in different market conditions.
• Style: The Style tab provides options for customizing the visual appearance of the
algorithm. You can adjust the color scheme, line styles, and other aesthetic elements to
make the algorithm easier to interpret on your chart. This can help you visualize trade
entries, exits, and signals clearly.
• Visibility: This tab controls the visibility of the algorithm on different timeframes and
chart types. By adjusting these settings, you can ensure that the algorithm only displays
on the timeframes where it’s most relevant to your strategy.
In the chapters ahead, we will break down each of these tabs in detail, explaining the purpose
of each setting and how to optimize them for your trading goals.
Whether you're focusing on risk management, fine-tuning your position sizes, or customizing
your chart's visual appearance, we’ll guide you through every step of the customization process
to ensure you can make the most out of this powerful tool.
Once you’ve selected the appropriate range of dates for your backtest, you can move on to
dividing the data into In-Sample (IS) and Out-of-Sample (OOS) sets. This process will allow you
to test the strategy's robustness and ensure that it’s not overfitted to the training data.
Start Date and End Date: You can define the range of dates for which you want the algorithm to
perform the backtest. (Check Figure 5)
- Example: If you wish to backtest your algorithm from 01/01/2020 to 31/12/2022, simply
input these dates in the respective fields. The algorithm will then run simulations within
this time frame to evaluate performance.
For live trading, simply set the end date to a far-off date (e.g., 31/12/2050) to allow the algorithm
to continuously run without an end date.
The key to robust backtesting lies in the use of In-Sample and Out-of-Sample Testing. Once you
have defined your trading range, the next logical step is to separate your historical data into
these two distinct subsets:
• In-Sample Testing uses data from the period during which the model was trained. This
dataset is used to adjust and optimize the algorithm’s parameters, ensuring it performs
well within the tested time frame.
• Out-of-Sample Testing, on the other hand, tests the algorithm using data it has never
encountered before. The goal is to ensure that the strategy is robust enough to
generalize to unseen data and provide a realistic evaluation of how it will perform in
unknown market conditions.
To define these two types of tests, it’s important to first understand the maximum amount of
historical data available to you based on your TradingView plan and the asset/timeframe you are
working with. Here’s how to determine the available data:
1. Go to the TradingView chart and click on the “Go To” button (Alt + G).
2. Choose a very old date (the more distant, the better) and click OK.
3. TradingView will display the maximum amount of historical data available for the asset
and timeframe you are using.
After determining the maximum amount of data available, you can split the data into two parts:
• In-Sample (IS): The first half of the data is used to create and optimize the strategy.
• Out-of-Sample (OOS): The second half is used to test the robustness of the strategy,
assessing how well it performs on data that was not used during the creation and
optimization process.
This division is crucial to evaluate how the strategy holds up and adapts to new market
conditions. The robustness of the strategy is determined by how well it performs in OOS testing
compared to the IS testing. Generally, the strategy is considered robust if the results from the
OOS are within a 20% difference from the IS results. This indicates that the strategy is stable and
likely to perform similarly in future, unseen market conditions.
If you wish to learn more about In-Sample and Out-of-Sample Testing, I recommend exploring
this Learning Link that outlines best practices and how to apply these concepts effectively in your
strategies.
Additionally, if you want to see the creation of a strategy from scratch, implementing the IS and
OOS concepts, I have prepared an Exclusive Playlist on my YouTube channel, where I guide you
step-by-step through the process of developing and testing strategies on TradingView.
Activate Trading Sessions: You can enable or disable specific trading sessions for different
financial centers around the world (Check Figure 6). The four primary sessions are:
• Sydney: 09:00 PM to 6:00 AM UTC: This session marks the opening of the global market,
often characterized by lower volatility compared to later sessions. It’s ideal for those
who prefer to trade during the quieter hours or those looking to trade specific currencies
like AUD.
• Tokyo: 12:00 AM to 9:00 AM UTC: The Tokyo session is one of the most active periods
for trading the Japanese yen (JPY) and other Asian currencies. During this time,
significant movements often occur in major currency pairs like EUR/JPY and USD/JPY.
• London: 7:00 AM to 4:00 PM UTC: As one of the most liquid trading sessions, the London
session sees a high volume of trades and is especially important for forex traders. This
session overlaps with both the Sydney and New York sessions, creating potential for
heightened market activity and volatility.
• New York: 1:00 PM to 10:00 PM UTC: The New York session overlaps with the London
session and is one of the most liquid trading periods, particularly for the USD. It’s
typically characterized by sharp movements in major currency pairs and significant
market news releases.
Create Custom Sessions: If you wish to trade outside of the standard sessions, you can create a
custom trading session by adjusting the start and end times. All times are calculated based on
UTC, so be sure to convert these times if you're in a different time zone (Check Figure 7).
Example: If you're based in New York and want your algorithm to run from 9:00 AM to 10:00 PM
local time, you will need to adjust the times in UTC. For this, the corresponding time would be
2:00 PM to 3:00 AM UTC, taking into account the five-hour difference between UTC and Eastern
Standard Time (EST).
Show Session Plots: Enabling this option will display a visual representation of the active trading
sessions on your chart. This makes it easier to quickly identify when each session starts and ends,
giving you a clear view of the market’s active periods. These session plots are color-coded and
will adjust based on the times you set in the Trading Sessions configuration.
Exit at End of Session: For traders who prefer to avoid holding positions overnight or after a
particular session ends, you can enable the Exit at End of Session option. This feature
automatically closes all open positions when a trading session concludes, regardless of whether
the Take Profit (TP) or Stop Loss (SL) levels have been reached. This ensures that no trades are
left open after the session closes, helping you avoid the risk of sudden price movements or
market gaps that can occur when the market is closed.
Fixed Risk per Trade: This setting allows you to define a specific percentage of your account
balance that you are willing to risk on each signal. By adjusting this value, you can ensure that
your risk remains constant regardless of account fluctuations.
How it works:
- To activate this feature, simply click on the “Use Fixed Risk Per Trade” button. Once
enabled, you’ll need to enter the risk value as a decimal, not as a percentage. For
example:
▪ If you want to risk 2% of your account balance per trade, enter 0.02 in
the input field.
- This means that for every trade, the algorithm will risk the maximum percentage of your
current balance as defined.
This risk calculation is applied per signal generated by the algorithm. It ensures that each trade
is sized based on the maximum risk you are willing to take at that moment, without needing to
manually adjust the position sizes.
Fixed Lot Size: Alternatively, you can opt to risk a specific number of contracts (lot size) for each
trade, regardless of the account balance. This approach can be beneficial if you prefer a more
predictable and consistent risk amount, rather than fluctuating based on the current balance.
- A contract typically represents a unit of trading for a given asset, such as futures or
options. The size of a contract is fixed based on the asset being traded.
- Lot size, in the context of Forex, refers to the number of units or size of the position
you’re taking. For example, in Forex trading, a standard lot represents 100,000 units of
the base currency.
- When you're trading assets like Futures, the lot size can also be represented in terms of
contracts. A contract size defines how much of the underlying asset is being traded.
In TradingView, if you prefer to use a fixed number of contracts or lots for your trades:
- Turn off the “Use Fixed Risk Per Trade” option by clicking the button to disable it.
- Input the number of contracts you wish to use per trade.
This method is often used by traders who are comfortable with fixed exposure levels, ensuring
the same risk amount on each trade, regardless of account size or market conditions.
Compounding:
The Compounding feature allows the algorithm to reinvest profits into subsequent trades,
effectively growing the trade size as the account balance increases. This is an excellent way to
accelerate profits over time, especially in markets with consistent upward trends. However, this
also means that as your account balance grows, so does your exposure, increasing the potential
risk.
How it works:
- In backtest mode, you can disable this option to test your strategy without reinvesting
profits, focusing only on the initial account balance and position sizes.
- In live trading or forward testing modes, enabling compounding allows the algorithm to
increase trade sizes as profits accumulate. This can significantly boost the overall
profitability of your strategy in the long term.
In periods of market retracement or drawdowns, compounding can help reduce the impact of a
drawdown by allowing the algorithm to adjust position sizes downward in accordance with your
balance, minimizing the effect of losses.
You have the flexibility to choose between two methods for calculating these levels (Check Figure
10):
1. ATR (Average True Range): This method allows the algorithm to adjust the Stop Loss,
Take Profit, and Trailing Stop Loss levels based on current market volatility. The ATR
value dynamically changes depending on how much the price moves, which helps the
algorithm adapt to more or less volatile market conditions.
2. Fixed Distance (in pips): If you prefer to use a consistent pip value for your risk
management levels, you can select the Fixed Distance method, where the Stop Loss,
Take Profit, and Trailing Stop Loss will remain at a fixed distance (in pips) from the entry
price.
If you prefer a fixed pip distance for your risk management levels, deselect the checkbox for “Use
ATR Method (or pips?)”. Then, you can input the number of pips you want for your Stop Loss,
Take Profit, and Trailing Stop Loss (Check Figure 11).
How It Works:
If you opt for the ATR method, select the corresponding box (“Use ATR Method (or pips?)”) to
enable it. Below, you will be prompted to choose an ATR length (the default is 14) (Check Figure
10).
What is the ATR? The ATR (Average True Range) is a technical indicator widely used to measure
market volatility. It was developed by J. Welles Wilder and calculates the average range between
the high and low prices over a specified number of periods. In simple terms, ATR measures how
much the price of an asset moves up and down within a given time period. Read More About
ATR
• Dynamic Adjustment: ATR automatically adjusts your risk levels according to the current
volatility of the market, making your risk management more flexible.
• Avoids Premature Stops: In more volatile markets, ATR allows for a wider Stop Loss,
reducing the chance of being stopped out prematurely due to normal market
fluctuations.
• Improves Take Profit Levels: With ATR, Take Profit levels can be adjusted to a more
realistic value based on expected price movement, ensuring you don’t set unrealistic
targets during periods of low volatility.
How It Works:
- After selecting the ATR method, you'll need to enter a value for the Multiplier. This value will
act as a constant and will be multiplied by the ATR number to determine the final distance for
your Stop Loss, Take Profit, and Trailing Stop Loss levels.
- For example, if the ATR value is 255 it means it is equivalent to 25.5 pips, and if you set a
Multiplier of 3, the algorithm will set the Stop Loss and Take Profit levels at 76.5 pips (3 x 25.5
pips) from the entry price.
- The same Multiplier applies to the Trailing Stop Loss, ensuring that the stop loss level moves
as the market fluctuates. For example, if the market moves in your favor, the Trailing Stop Loss
will also adjust by the same amount (in this case, 76.5 pips) based on the volatility.
1 Take Profit (1 TP): This is the simplest option, where you define a single Take Profit level for
the entire position. Once the price reaches this level, the entire position will be closed, locking
in the profits. This method is ideal for traders who prefer to exit the position at one specific
target, taking profits once that level is hit, regardless of how the market moves afterward.
(Remember, the calculation of the Take Profit level is based on the method you selected in the
previous section—either with a fixed pip value or using the ATR multiple.)
2 Take Profits (2 TPS): This option introduces a more advanced risk management strategy aimed
at scaling profits. The goal is to manage risk while maximizing potential gains as the market
moves in your favor.
In this case, part of the position is closed at the first Take Profit level defined earlier, which is the
same level you would use in the 1 TP option. The remaining portion of the position stays open
and is then managed using a Trailing Stop Loss, which allows the stop loss to move in line with
the market as it continues to move in the favorable direction.
The Trailing Stop Loss is updated only when the market moves in the direction of the trade. For
example, in a long position, the trailing stop will adjust upward as the price increases, but if the
price starts to fall, the stop loss remains at its last updated level. The same logic applies to short
positions, where the trailing stop is updated downwards as the price decreases. However, if the
price moves upwards, the trailing stop remains at its most recent update.
The distance of the trailing stop loss is always based on the value of the ATR or Pips that you
selected in the previous section.
This strategy is ideal for traders looking to scale their positions and capture more profit during
favorable market trends, while still managing risk through the trailing stop loss. You can also
define the Partial Profits Percentage, determining the percentage of the position that will be
closed at the first Take Profit level (e.g., 50% = 0.5).
Candle Rule: The Candle Rule introduces a waiting period (defined by the user in the “Multiple”
input) before confirming the validity of a trade entry. This rule ensures that the conditions for
entering a trade remain valid over a longer period, reducing the chance of executing trades based
on transient or false signals.
For example, if one condition (such as volume) is unmet, the bot will wait for one more candle
to see if the condition aligns properly with the rest of the trading criteria. This extra waiting
period helps to verify that the market is genuinely moving in the expected direction and that the
signal is not a momentary fluctuation.
This rule is particularly useful for higher timeframes (such as 4-hour, daily, or weekly charts),
where the market's movements may be more volatile and prone to generating false signals over
short periods. By waiting for the next candle to close, the strategy ensures that there is greater
alignment between multiple technical factors before entering a position. It improves entry
accuracy and can filter out many of the spurious signals that might appear in lower timeframe
trading, leading to more reliable trades.
Baseline ATR Rule: The Baseline ATR Rule ensures that a trade will only be considered if the
price is within a specific distance from a predefined baseline level. This baseline is calculated
using a multiple of the ATR value, which allows the algorithm to dynamically adjust for varying
market volatility.
The purpose of this rule is to restrict trades to areas that are relatively close to the trend level,
thereby preventing trades when the price has already moved too far away from the baseline.
This approach helps to avoid entering trades that are overly extended, reducing the likelihood of
entering against the prevailing market direction.
In practical terms, the algorithm will only consider entries that are within a certain distance of
the baseline, as defined by a multiple of the ATR value. This is visually represented by the ATR
Plus and ATR Minus bands, which mark the upper and lower boundaries of the entry range.
These bands visually guide traders by showing the allowed distance for valid entries from the
baseline (Check Figure 14).
These rules work together to ensure that trades are executed only when the conditions align
consistently, helping to filter out noise and increasing the likelihood of successful trade entries.
Whether you're looking for accurate entries or ensuring that you don't enter trades too far from
the trend, these rules serve as essential tools for improving the overall performance of the
algorithm.
3.3.8. Indicators
Indicators play a crucial role in shaping how the algorithm identifies trade opportunities, filters
out bad signals, and manages trade exits. In this section, you can configure multiple types of
indicators, each with its own function within the strategy. The flexibility in choosing from a wide
selection of indicators allows you to fine-tune your trading approach, adapting it to different
market conditions and personal preferences.
Each indicator has a dedicated input section where you can adjust its parameters, such as period
length, calculation method, or specific thresholds. Below is a breakdown of the different types
of indicators available in the system and their respective functions (Check Figure 20):
C1 (Main Indicator)
The C1 Indicator serves as the primary indicator for your strategy. This is the core signal
generator that determines trade entries, confirmations, and exits, depending on how it is
configured (Check Figure 15).
• You can select your C1 Indicator from the "Indicators" tab, where over 50 different
options are available, with new indicators being continuously added.
• Once an indicator is selected, you can assign it specific roles, such as a trigger signal
(entry condition), confirmation (to strengthen the validity of a trade setup), or even an
exit signal (to determine when to close a trade).
• The ability to customize the C1 Indicator provides full flexibility, allowing traders to adapt
the system to different market conditions and trading styles.
• Some examples of indicators available for C1 include Moving Averages, RSI, MACD,
Bollinger Bands, SuperTrend, Squeeze Momentum, and more.
Choosing the right C1 Indicator is crucial because it forms the foundation of your trading logic. A
poorly chosen main indicator can lead to unreliable signals, while a well-optimized one can
significantly enhance accuracy.
The C2 Indicator acts as a secondary filter to refine trade entries. While it functions in the same
way as the C1 Indicator (selected from the same range of indicators), its purpose is strictly to
confirm the validity of trade signals (Check Figure 16).
• The key difference between C1 and C2 is that C1 generates signals, while C2 validates
them, ensuring that only the highest-probability trades are executed.
• By adding a second layer of confirmation, the C2 Indicator reduces false signals and
prevents entries that lack strong supporting conditions.
• For example, a trader might use C1 = RSI (Relative Strength Index) for
overbought/oversold signals, and C2 = MACD (Moving Average Convergence
Divergence) to confirm trend direction.
Using a dual-indicator approach (C1 + C2) helps eliminate low-quality setups, filtering out trades
that do not align with the broader market conditions.
Volume Indicator
Volume plays a critical role in understanding market participation and the strength behind price
movements. The Volume Indicator functions similarly to the C2 Indicator, acting as an additional
confirmation tool for trade entries (Check Figure 17).
• Over 10 volume-based indicators are available for selection, allowing traders to analyze
different aspects of market activity.
• For example, if the C1 and C2 indicators suggest a buy trade, but the volume is low, the
trade may lack momentum and could result in a false breakout.
By integrating a Volume Indicator, traders can avoid entries that lack the necessary momentum,
improving trade accuracy.
Exit Indicator
The Exit Indicator provides an additional tool for closing trades based on indicator-based signals.
While stop-loss and take-profit levels define predefined exit points, an Exit Indicator reacts
dynamically to price movements and can help close positions at the optimal moment (Check
Figure 18).
• Just like the C1 and C2 Indicators, you can select an Exit Indicator from the same set of
available indicators.
• This allows traders to secure profits or minimize losses before a trend reverses
completely.
For example:
- A trader using a Moving Average as an Exit Indicator could set a rule to close the trade
when the price crosses below a short-term moving average, signaling a trend shift.
- Another trader might use RSI as an Exit Indicator, closing trades when RSI moves into
overbought/oversold levels, indicating exhaustion.
The Exit Indicator provides an additional level of trade management, ensuring that positions are
not held beyond optimal conditions.
Baseline Indicator
The Baseline Indicator is another essential tool within the strategy, offering over 15 different
options, including various types of moving averages and trend-following tools. It functions
similarly to the C1 Indicator, allowing traders to use it as a (Check Figure 19):
However, the Baseline Indicator has a unique role compared to C1 and C2. It is primarily used to
identify the overall trend or market structure, helping traders determine whether they should
be focusing on buying, selling, or staying out of the market.
For example:
- If the price is above the Baseline Indicator (e.g., a 200-period EMA), the trend is bullish,
and only long trades will be considered.
- If the price is below the Baseline Indicator, the trend is bearish, and only short trades
will be considered.
The ATR Plus and ATR Minus bands (discussed in the "Baseline ATR Rule") help visualize how far
the price has deviated from the Baseline, ensuring trades are executed within a reasonable
distance from the trend level.
Using a Baseline Indicator helps traders avoid counter-trend trades and ensures that positions
align with the prevailing market direction.
Each of these indicator options comes with a dedicated settings section, allowing full
customization of their inputs and parameters (Check Figure 20).
This high level of customization ensures that each trader can adapt the system to their own
trading preferences and strategies, maximizing flexibility and efficiency.
The indicator selection process is one of the most critical aspects of setting up the algorithm.
With the ability to choose from over 50 primary indicators, 10+ volume indicators, and 15+
baseline indicators, traders have unmatched flexibility in building a system that aligns with their
goals.
By properly configuring C1, C2, Volume, Exit, and Baseline Indicators, traders can:
With new indicators being regularly added, the system continues to evolve, offering more
possibilities for refining and improving trading strategies over time.
The algorithm provides two trade type options (Check Figure 21):
• Take Long Positions: When this option is selected, the algorithm will only execute buy
trades (long positions). This setting is ideal for traders who are confident in a bullish
market trend and prefer to capitalize only on upward movements. By limiting trades to
buys, the strategy avoids entering short positions, which may be useful in assets that
historically trend higher over time (e.g., certain stocks or crypto assets).
• Take Sell Positions: This option restricts the algorithm to executing sell trades (short
positions) exclusively. It is suitable for traders who expect a bearish market condition
and want to profit from price declines. This setting is commonly used in markets where
downward trends are frequent, such as during economic downturns or in assets that
experience strong cyclical declines.
• Both Options: This is the most flexible option, allowing the algorithm to execute both
buy and sell trades based on the entry conditions defined in previous sections. It enables
the trader to take advantage of both bullish and bearish movements, making it a suitable
choice for range-bound markets or trend-following strategies that aim to profit from
price movements in either direction.
Choosing the correct trade type depends on market conditions, asset characteristics, and your
trading objectives. For example, some traders may prefer to trade both directions in highly
volatile forex pairs, while others may focus only on long positions in stock indices that have a
long-term upward bias.
This setting is easily adjustable, allowing traders to modify their approach as market conditions
change.
3.3.10. PineConnector
What is PineConnector?
PineConnector is a powerful tool that enables full automation of your trading strategy. By
integrating PineConnector with your broker, you can execute trades automatically based on
signals from TradingView, eliminating the need for manual intervention. This transforms your
strategy into a fully automated trading system, ensuring efficiency and consistency in trade
execution.
Supported Platforms
To automate your strategy on MetaTrader 5 using PineConnector, follow these key steps:
1. Download the PineConnector EA – Access your PineConnector portal and download the
MT5 EA.
2. Install the Expert Advisor – Place the downloaded files in the Experts folder of your
MetaTrader 5 directory.
3. Enable DLL Imports & Algo Trading – Adjust the settings in MetaTrader 5 to allow the
execution of automated trades.
4. Attach the EA to the Chart – Refresh the Expert Advisors section and attach
PineConnector EA to your trading chart.
5. Enter Your License Key – Copy and paste your License ID from the PineConnector portal
to activate the EA.
For a detailed step-by-step guide, please refer to the official PineConnector documentation:
Once PineConnector is correctly installed on your MetaTrader platform, you need to configure it
in TradingView within the Indicators Testing Bot. This is done by enabling automation in the bot
settings and filling in the necessary parameters (Check Figure 22).
Inside the Indicators Testing Bot, select the option “Use PineConnector Automation” to activate
automated trade execution.
There are four key inputs that must be correctly set up to ensure proper automation:
1) License ID
• Insert your PineConnector License ID, which can be found in your PineConnector
account.
The value you enter here must match the risk type selected in your PineConnector account
settings. PineConnector allows two risk types:
a) Fixed Lot Size → If you selected "Lots" in PineConnector “Volume Type” Option, the
value you enter here represents the lot size per trade.
o Example: If you want to open trades with 0.01 lots, enter "0.01" in this field.
b) Percentage of Account Balance → If you selected "Percentage", the value you enter
here defines the percentage of the account used per trade.
o Example: If you want each position to risk 1% of your account balance, enter
"1".
3) Spread Filter
This input prevents trades from being opened if the spread exceeds a set value. Example:
- If trading EUR/USD, and you don’t want to enter a trade if the spread is higher than 2
pips, enter "2" in this field.
- If the spread exceeds 2 pips, PineConnector will block the trade.
To disable this filter, enter a large number like 1000, ensuring all trades are executed regardless
of the spread.
⚠ Important: The ideal spread filter value depends on the asset you are trading: EUR/USD has
a much lower spread than Bitcoin, so different values may be needed.
• This defines the pip value for different markets and ensures stop loss (SL) and take profit
(TP) calculations are correct.
This option adds labels at each valid entry point, displaying the exact message that would be
sent to PineConnector. It’s useful for verifying whether the automation is set up correctly before
executing real trades. If the labels show incorrect data, you can adjust your settings before
activating live trading.
To better understand how PineConnector automation works in practice, let’s look at an example.
In this case, we have a short trade signal on the EUR/USD pair with Debug Labels enabled.
By enabling Debug Labels, we can see the exact message that would have been sent to
PineConnector when this valid signal was identified by the algorithm.
- Stop Loss & Take Profit: These values correspond exactly to the number of pips calculated by
the algorithm.
Important: Ensure that in PineConnector, the stop loss and take profit values are set to pips,
as this is the format the algorithm sends (Check Figure 46).
- Spread Filter: Here, we see the spread filter value (2 pips), ensuring the trade is only executed
if the spread is below this level.
- Comment Field: The comment field may contain additional information used by the algorithm
to classify the input type.
⚠ Note: Depending on whether you choose one take profit (TP1) or two take profits (TP1 &
TP2), the algorithm sends two separate signals to PineConnector. This ensures that when TP1 is
reached, TradingView notifies PineConnector to close the first position while keeping the
second trade open until TP2 is hit (the Trailing SL).
This system ensures proper trade execution and management, giving you full control over risk
and profit-taking within PineConnector.
If the user has additional indicators or exit conditions besides Stop Loss (SL) and Take Profit
(TP), TradingView will also send a message to PineConnector when an early exit condition is met.
Now that we’ve configured the algorithm, the final step is to set up alerts to automate trade
execution.
• Ensure that all input parameters in the algorithm’s settings match your trading strategy.
3. Create an Alert
6. Optional Notifications
• You can enable additional notifications (email, app alerts, etc.), but the main signal will
now be sent directly to PineConnector.
From this point forward, any new trade signal detected by the algorithm will be automatically
sent to PineConnector, executing the trade on your broker account.
Setting Up Alerts for Multiple Assets & Timeframes: If you want to trade multiple assets or
timeframes, simply repeat this alert setup process for each one.
The Symbol Mapping feature allows users to seamlessly convert symbol names from
TradingView to those used by their broker. This ensures that when a trading signal is generated
on TradingView, it is automatically translated into the correct format required by the broker,
eliminating errors in order execution.
This feature is particularly useful when switching between brokers, as different brokers may use
custom symbol formats (e.g., including prefixes or suffixes). With Symbol Mapping, traders no
longer need to delete and recreate alerts whenever they change brokers.
• TradingView might generate a signal for EURUSD, but your broker may require it to be
formatted as i.EURUSD.micro.
• Symbol Mapping automatically converts the TradingView signal into the correct format
so that the trade is properly processed in MetaTrader 4/5.
For a detailed explanation and setup guide, refer to the official PineConnector documentation:
Setting Up PineConnector “Symbol Mapping”
If your PineConnector does not support Symbol Mapping, you can still manually adjust symbols
using the MetaTrader Symbol option in our algorithm (Check this Figure).
• This feature allows you to manually add prefixes or suffixes to match the broker’s
symbol format.
• Simply enter the correct symbol name required by your broker in the designated field,
ensuring that trade signals are processed correctly.
This provides a simple workaround for brokers with different symbol conventions, allowing full
automation without needing to modify PineConnector settings.
By enabling this option, the algorithm will generate a comprehensive monthly table displaying
key performance metrics. This feature helps traders gain deeper insights into their trading
results, facilitating data-driven decision-making and continuous strategy optimization (Check
Figure 23).
1. Monthly Breakdown
- Each month is displayed separately, showing Net Profit/Loss for that period.
- This allows traders to identify fluctuations in profitability and assess whether specific
market conditions impact their results positively or negatively.
- Comparing month-to-month performance helps determine whether adjustments to the
strategy are necessary.
2. Annual Summary
- At the end of each year, the table provides a Total Profit or Loss for that year.
- It also displays the Maximum Drawdown for the entire year, giving insight into the
largest equity decline experienced within that period.
- This data is crucial for understanding risk exposure and refining risk management
strategies.
- To provide a holistic view of the strategy’s long-term performance, the table includes an
aggregated section with:
▪ Total Profit/Loss – The cumulative net profit or loss over all recorded
periods.
✓ Detect Performance Trends – By analyzing which months are most profitable, traders
can determine whether their strategy performs better in specific market conditions.
✓ Evaluate Long-Term Profitability – The inclusion of CAGR allows traders to measure their
returns over time and compare them to benchmarks like stock market indices or other
investment strategies.
By leveraging this data, traders can make informed decisions, improve their strategy’s
robustness, and maximize long-term profitability while managing risk effectively.
Essentially, the Properties menu allows users to fine-tune the operational aspects of the
algorithm to ensure it aligns with their risk profile and trading goals.
How it affects the strategy: The initial capital is crucial because it sets the base for calculating
position sizes, risk per trade, and overall strategy performance. A larger initial capital allows for
more flexibility in managing trades and can influence the amount of leverage or margin used.
Customizing it: Adjusting the initial capital directly impacts the risk and position size calculations.
For example, a higher initial capital allows for a larger position size at the same risk percentage,
and this could result in higher profits (or losses) depending on the strategy's performance.
How it affects the strategy: The base currency is used to calculate the value of positions, profits,
and losses. It ensures that all results and trades are standardized to the currency of the account.
Customizing it: If you're trading in a specific market (e.g., EUR/USD), you'll need to set your base
currency to match the currency of the asset you're trading. It helps ensure that your account's
balance and margin are accurately represented in the right currency.
How it affects the strategy: The order size determines how much capital will be deployed on
each trade. It directly affects risk, with larger orders increasing potential profits or losses.
Adjusting order size also impacts the ability to handle drawdowns and leverage.
Customizing it: You can define the order size according to your risk tolerance. Larger order sizes
increase risk exposure, so it’s essential to balance it with other risk management factors like stop
loss, margin, and position size.
3.4.4. Pyramiding
What it is: Pyramiding allows you to add additional positions to an existing trade. It increases
exposure by adding new orders in the same direction when the price moves in your favor.
How it affects the strategy: Pyramiding can significantly increase profits when the market trends
in your favor. However, it also increases risk, especially in volatile markets. It’s crucial to set this
value based on your strategy and risk tolerance.
Default Setting of 2: By default, our algorithms use a pyramiding setting of 2, which means the
algorithm will open two trades for every valid signal. The reason for this is to allow the strategy
to have a Take Profit level for one position and a Trailing Stop Loss for the second position. The
two trades are opened with half the risk or half the position size defined in the input to ensure
that the overall risk remains consistent. This is necessary for achieving accurate and reliable
results because, in real trading, you might want to lock in profits on one portion of the position
while letting the other run with a trailing stop.
Why 2 is necessary: The dual position setup is crucial for achieving more refined risk
management and precise take profit/trailing stop executions. Don’t worry if you see two
positions opened simultaneously—this is by design and does not alter the validity or integrity of
the strategy's results.
3.4.5. Commission
What it is: The fee charged by the broker per trade. It can be a fixed fee or a percentage of the
order size.
How it affects the strategy: Commissions impact the net profitability of your strategy. Higher
commissions eat into your profits, especially with frequent trading. Adjusting this input helps
ensure that the strategy is optimized for real-world trading costs.
Customizing it: Be sure to input the commission structure that your broker uses (either fixed or
percentage). This ensures that the backtested results reflect the true cost of trading, helping you
make more accurate performance predictions.
How it affects the strategy: This is useful for confirming that the market is at the desired price
before submitting a limit order. It helps avoid slippage and ensures that limit orders are filled
only at favorable prices.
Customizing it: Enabling this option makes sure that limit orders are executed only if the price
condition is met, preventing undesirable entries.
3.4.7. Slippage
What it is: Slippage refers to the difference between the expected price of an order and the
actual price at which the order is filled.
How it affects the strategy: Slippage can occur due to market volatility or order execution delays.
It’s important to set a slippage tolerance that reflects the market conditions in which your
strategy operates. Too much slippage can result in worse trade executions, affecting profitability.
Customizing it: Set a reasonable slippage value to account for market conditions, especially
when trading volatile assets. Too tight a slippage value might prevent some trades from
executing, while too loose a value could result in unfavorable fills.
How it affects the strategy: This defines how much capital needs to be reserved for long
positions. A lower margin requirement allows you to open larger positions with the same amount
of capital, but it also increases your risk of margin calls.
Customizing it: Adjust the margin based on your broker’s requirements and your risk tolerance
for long positions.
How it affects the strategy: Similar to the margin for long positions, this determines how much
capital is needed to short an asset. Short positions can be riskier, so it's important to manage
this margin properly.
Customizing it: Input the appropriate margin level for short positions based on your broker’s
requirements and risk management preferences.
3.4.10. Recalculate
What it is: The option to recalculate the strategy based on any changes made to the input
parameters.
How it affects the strategy: Recalculating ensures that the strategy’s performance is updated
based on any new adjustments. This is important after changing parameters like order size, risk,
or margin, as it ensures that the backtesting reflects the new settings.
Customizing it: It's a good practice to recalculate whenever you make any adjustments to your
strategy to ensure the results are as accurate as possible.
How it affects the strategy: This setting simulates order fills more realistically, accounting for
slippage and execution delays. It’s important for simulating live market conditions, where orders
might not always fill immediately.
Customizing it: Enabling "Fill Orders" ensures that the backtest reflects more realistic trading
scenarios, including potential delays or slippage when orders are placed.
3.7.1. Overview
Equity Curve and Key Metrics (Check Figure 25)
• View the Equity Curve for the overall strategy performance, along with key metrics such
as:
o Max Drawdown: The largest drop in account value during the testing period.
o Average Profit/Loss per Trade: The average profit or loss per trade.
• This section provides more detailed data specific to the asset being tested. Metrics
include:
o Sharpe Ratio: The ratio of the strategy’s average return to its risk.
• The List of Trades section shows the entire history of executed trades. The Export Data
button allows you to download the results in CSV format, which can be analyzed in Excel
or other data analysis tools.
Tip: Exporting data from multiple assets can help aggregate results for a more comprehensive
analysis.
For detailed instructions on how to work with the exported data, refer to the Trading Journal
Guide.
3.7.4. Properties
Algorithm Settings Overview (Check Figure 28)
• This section displays the settings that were used to generate the current results, such as
risk management parameters and position sizing. It allows you to review and adjust
settings based on the observed performance.
4. Appendix
• Algorithmic Trading: The use of automated computer programs to execute trades based
on predefined conditions, minimizing human intervention and increasing efficiency.
• Asset Pip Value: The value of a pip movement for a given asset. It varies depending on
the market (e.g., 1 for Forex, stocks, indices, and metals; 10 for cryptocurrencies and
commodities).
• ATR Bands (ATR Plus & ATR Minus): Bands derived from the Average True Range (ATR)
that help determine the acceptable range for trade entries. These bands act as volatility
filters in strategy execution.
• Backtesting: The process of testing a trading strategy on historical data to evaluate its
effectiveness before applying it in live trading.
• Baseline ATR Bands: Bands calculated from the Average True Range (ATR) that help
determine how far the price has deviated from the baseline indicator.
• Baseline Confirmation: A method where the price must be above or below the baseline
indicator to validate trade entries.
• Broker: A financial intermediary that facilitates buying and selling assets in financial
markets. MetaTrader (MT4/MT5) is a common platform used for broker execution.
• CAGR (Compound Annual Growth Rate): A metric that measures the average annual
return of an investment over a specified period.
• Debug Labels: A feature in the algorithm that displays the exact message that would be
sent to PineConnector at each entry point, allowing users to verify the correctness of
trade execution before real trading.
• Entry Condition: The set of rules that must be met before the algorithm executes a trade.
• Equity Growth: The increase in account balance over time as a result of executed trades.
• Exit Condition: The predefined rule that determines when a trade should be closed. It
can be based on a stop loss, take profit, trailing stop, or an exit indicator.
• Fill Orders: The process of executing trades in backtests according to the conditions
specified in the algorithm, simulating real-market order execution.
• Fixed Risk per Trade: A risk management setting where the algorithm risks a fixed
percentage of the account balance on each trade.
• Fixed Lot Size: A risk-setting method where each trade opens with a predefined lot size,
regardless of account balance.
• Indicator-Based Exit: A trade exit strategy based on an indicator rather than a static stop
loss or take profit level.
• Leverage: A tool that allows traders to control larger positions with a smaller amount of
capital. Higher leverage increases both potential gains and risks.
• Liquidity: The ease with which an asset can be bought or sold in the market without
significantly impacting its price.
• Margin Call: A broker notification requiring a trader to deposit additional funds due to
insufficient margin to maintain open positions.
• Market Conditions Filter: A rule in the algorithm that prevents trades in unfavourable
market conditions (e.g., low volatility, excessive spread, etc.).
• MetaTrader Symbol Mapping: A feature that allows users to modify the asset symbol in
TradingView to match the broker’s symbol format in MetaTrader.
• Open-Ended Alert: A TradingView alert setting that ensures the alert remains active
indefinitely until manually cancelled by the user.
• Out-of-Sample Testing (OOS): The process of testing a strategy on historical data that
was not used during its development, ensuring the model's robustness in unseen market
conditions.
• Overfitting: A situation where a strategy is overly optimized for historical data but
performs poorly in live trading due to excessive curve-fitting.
• Partial Profit Percentage: The percentage of a position that is closed at the first take
profit level when using multiple take profits.
• Pyramiding: A trading strategy that allows for the gradual increase of position size by
adding trades in the same direction as the trend.
• Profit Split Strategy: A strategy that involves closing part of the position at an initial
profit target while letting the remaining portion run with a trailing stop loss.
• Real-Time Alerts: Notifications generated by TradingView that alert traders about new
trade signals based on algorithmic conditions.
• Risk-to-Reward Ratio (R:R): A metric that compares the potential profit of a trade to its
potential loss.
• Risk-Free Trade: A trade where the stop loss is moved to breakeven, ensuring no capital
is lost if the market reverses.
• Scalping Strategy: A high-frequency trading strategy that aims to capture small price
movements over short timeframes.
• Slippage Filter: A setting in PineConnector that ensures trades are only executed if
slippage remains within a predefined threshold.
• Stop Limit Order: A trade execution order that converts into a limit order once a specific
price is reached.
• Take Profit Strategy: A method of exiting trades at predefined levels to secure profits.
• Trailing Stop Activation: The process of enabling a trailing stop loss that moves
dynamically as the price advances in the trade’s favor.
• Trading Journal: A record-keeping tool used to track and analyze past trades to improve
strategy performance.
• Trading Volume: The total number of contracts or shares traded in a given market over
a specified period.
• Trading Window: The period in which an algorithm is allowed to execute trades, often
based on defined market sessions.
• Unrealized Gains/Losses: The profit or loss of open positions that have not yet been
closed.
• UTC Offset: The adjustment required to convert a local trading session time into
Coordinated Universal Time (UTC) for TradingView settings.
• Volatility Filter: A setting that prevents trades from being executed if market volatility is
too low or too high, based on predefined conditions.
• Webhooks: A TradingView feature that allows trade alerts to be sent directly to third-
party automation services like PineConnector.
• Win Streak (Winning Streak): The maximum number of consecutive profitable trades
recorded in backtesting.
• Win Rate (Success Rate): The percentage of trades that result in a profit over a given
period.
Strategy Overview
This strategy integrates multiple indicators for entry, confirmation, and exit, along with risk
management settings based on the ATR (Average True Range) and a Two Take Profits (2 TPS) exit
strategy.
Indicator Setup:
• Main Indicator (C1 - Trigger): [QQE MT4] → This indicator serves as the primary trigger
for trade entries.
• Volume Indicator (Confirmation): [WAE] → Confirms that trade entries align with high
market participation.
• Exit Indicator: [Aroon] → Used to close positions early when specific market conditions
are met.
• Baseline Indicator (Trigger, Confirmation & Exit): [T3 MA] → Defines trend direction,
validates entries, and can also act as an exit signal.
• Position Sizing: Based on ATR, allowing dynamic Stop Loss and Take Profit adjustments
based on market volatility.
• ATR Multiplier for Stop Loss: 2.0x ATR → Ensures the Stop Loss adapts to market
volatility.
• ATR Multiplier for Take Profit: 2.5x ATR → Defines the first profit target, balancing risk
and reward.
• ATR Multiplier for Trailing Stop Loss: 2.0x ATR → The trailing stop follows price
movements, locking in profits while maintaining the same risk structure as the initial
Stop Loss.
o First Take Profit (TP1): Closes 50% of the position at 2.5x ATR (defined via the
Partial Profits Percentage input set at 0.5).
o Second Take Profit (TP2) / Trailing Stop Loss: The remaining position stays open
with a Trailing Stop Loss, allowing the trade to continue capturing profits while
protecting gains.
o Exit Rule: If the trailing stop is hit or the Exit Indicator signals a reversal, the
trade is closed.
Below are some images showing the exact configuration of the algorithm in the Inputs menu.
In this case, the entry is triggered when the candlestick marked with the green circle crosses
and closes below the T3 MA Baseline. This occurs because the baseline indicator (T3 MA) has
been configured as a trigger, meaning that whenever price crosses and closes below this moving
average, a short trade is initiated—provided that all other confirmation indicators align.
1. Baseline as a Trigger: The price crosses and closes below the baseline (T3 MA),
generating a short signal based on the user-defined settings.
2. Main Confirmation Indicator (C1 - QQE MT4): The QQE MT4 indicator confirms the
short entry because it is in a downtrend, supporting the trade direction.
3. Secondary Confirmation Indicator (C2 - DPO): The Detrended Price Oscillator (DPO) is
positioned below the zero level, further validating the bearish market structure and
confirming the trade.
4. Volume Confirmation (WAE - Volume): The Waddah Attar Explosion (WAE) indicator
displays a red bar above the yellow threshold, confirming that sellers are in control and
that the market has strong selling momentum.
5. Risk Management – Stop Loss & Take Profit Placement: The trade follows the Two Take
Profits (2 TPS) strategy, where:
o 50% of the position is closed at the first Take Profit (TP1), marked as “TP / SL
1”.
o The remaining 50% of the position remains open with a Trailing Stop Loss,
dynamically adjusting as price moves.
6. Exit Indicator (Aroon Indicator - Used as Exit Confirmation): The position is fully closed
at the point labelled "Exit Short 2". This occurs because, as shown by the red-circled
area, the Aroon Indicator crosses, signalling a trend reversal and confirming the need
to exit the trade.
This is the exact message that PineConnector would send to the broker when this trade was
identified as a valid entry by the algorithm:
• The goal is to fine-tune parameters and maximize profitability within known market
conditions.
The backtest results for the EUR/USD pair over the 2-year period from 2021 to 2022
demonstrate the effectiveness of the strategy under the given settings. Below is a breakdown of
the key performance metrics:
• Total Trades Executed: 382 trades, corresponding to 191 valid signals (since each trade
signal generates two separate positions due to the 2 Take Profits (2 TPS) strategy).
• Win Rate: 51.31%, meaning that just over half of the valid signals resulted in profitable
trades.
• Profit Factor: 1.666, indicating that for every $1 lost, the strategy generated $1.666 in
profit—suggesting a solid risk-reward ratio.
Since the strategy uses the Two Take Profits (2 TPS) setting, each valid signal results in two
separate positions being opened, each with half the original risk. This ensures that the
overall statistical integrity of the strategy remains unchanged.
For instance:
• Because each trade splits into two separate orders (one closing at TP1 and the other
managed with a trailing stop loss), the final trade count appears as 382 trades in the
strategy tester.
• The risk remains balanced because each of these two trades carries half the originally
intended position size, ensuring that the total risk per signal remains consistent.
• This dataset is used to validate the strategy on unseen market conditions, testing its
robustness.
• The goal is to ensure the strategy generalizes well and does not suffer from overfitting.
The out-of-sample backtest results for the EUR/USD pair over the 2-year period from 2023 to
2024 show how the strategy performed in unseen market conditions. Below is the breakdown of
the key performance metrics:
• Total Trades Executed: 380 trades, corresponding to 190 valid signals (each signal
generated two separate positions due to the 2 Take Profits (2 TPS) strategy).
• Win Rate: 47.89%, slightly lower than the in-sample results, suggesting different market
dynamics.
• Profit Factor: 1.475, meaning that for every $1 lost, the strategy generated $1.475 in
profit—still a positive expectancy, though slightly reduced from the in-sample period.
• Maximum Drawdown: 9.60%, slightly higher than the previous period, indicating an
increase in risk exposure.
By comparing the in-sample (2021-2022) and out-of-sample (2023-2024) results, we can derive
valuable insights:
Consistent Profitability: Despite slightly lower performance in the out-of-sample test, the
strategy still generated a strong net profit and maintained a positive profit factor, proving its
ability to adapt to changing market conditions.
Win Rate Variation: The win rate dropped from 51.31% to 47.89%, indicating that the
market structure in the second period may have been more volatile or had different trends.
However, the strategy remained profitable, showing its robustness.
Drawdown Management: The maximum drawdown increased from 7.53% to 9.60%, which
suggests that while the strategy performed well, the risk exposure was slightly higher in the out-
of-sample period. Traders may consider adjusting risk parameters (e.g., lowering ATR multipliers)
based on market conditions.
Profit Factor Remains Strong: The profit factor of 1.475 in the out-of-sample test confirms
that the strategy still maintained an edge, even if slightly weaker than before. This is a key sign
that the system is not overfitted and continues to function in different environments.
The overall results confirm that the strategy is reliable, adaptable, and capable of generating
long-term profits. While market conditions evolved between the two testing periods, the risk
management settings and trade execution methodology ensured consistent performance,
making this a viable trading approach for various market conditions.
This is just one example of how we can use the Indicators Testing Bot or any of my other
algorithms to develop trading strategies, analyze performance, and extract meaningful results.
By following this structured approach, traders can validate their strategies before deciding
whether to automate them.
Beyond this specific use case, traders can take their analysis even further:
• Instead of testing on a single asset like EUR/USD, the same strategy could be applied to
other forex pairs, indices, commodities, or stocks to assess its robustness across
different markets.
• All executed trades can be downloaded in CSV format, allowing users to build a more
sophisticated Trading Journal in Excel—as previously demonstrated in an earlier
section.
• Instead of trading a single asset, traders can combine multiple assets into a portfolio
and analyze overall profitability, risk, and diversification effects when applying the same
strategy.
The true power of this tool lies in its ability to provide data-driven insights that allow traders to
refine, optimize, and automate strategies based on tested and proven performance metrics.
Trading Psychology & Discipline – Mark Douglas (Free PDF & Lectures):
https://www.academia.edu/36209064/Mark_Douglas_Trading_in_the_Zone - Learn how
emotions impact trading and how to develop a disciplined, systematic approach.
These resources offer valuable insights into trading and strategy optimization, helping you make
more informed decisions.
5. Conclusion
Thank you for taking the time to explore the full capabilities and functionalities of our algorithmic
trading strategies. We hope this guide has provided you with a deeper understanding of how to
effectively use and optimize the strategy settings to align with your trading objectives. Whether
you are backtesting strategies, automating trades, or refining your risk management approach,
this manual serves as a comprehensive resource to enhance your trading experience.
Our mission is to provide traders with powerful tools that enable better decision-making, reduce
manual workload, and ultimately improve trading performance. By leveraging the flexibility and
automation features of our algorithms, you can focus on strategy development and execution
with confidence.
If you’re interested in expanding your trading capabilities further, you can explore our premium
tools:
Indicators Testing Bot Premium – Full access to the most advanced version of our testing
bot, allowing you to backtest and refine multiple indicators:
https://www.algotradepro.com/indicators-testing-bot-access
Indicators Testing Bot 15 – Test up to 15 indicators in your strategy for optimized decision-
making: https://www.algotradepro.com/indicators-testing-bot-15
Indicators Testing Bot 30 – Expanded version for those who require more extensive testing
capabilities: https://www.algotradepro.com/indicators-testing-bot-30
ATP Portfolio – Gain insights into our curated portfolio, tracking high-potential trades and
investments: https://www.algotradepro.com/atp-portfolio-access
Trading Journal – A dedicated journal for tracking, analyzing, and refining your trades over
time: https://www.algotradepro.com/trading-journal
You can acquire these tools through our official website: https://www.algotradepro.com/
If you have any questions about their features or how they can benefit your trading, feel free to
This manual is continuously updated to reflect improvements, new features, and the latest
advancements in trading automation. If you have any feedback, suggestions, or if you notice any
errors, please don’t hesitate to let us know. We highly value your input and are committed to
refining this resource to ensure it remains as accurate and useful as possible.
Get in Touch
If you have any questions, require assistance, or would like to provide feedback, we are here to
help.
Email: [email protected]
Website: https://www.algotradepro.com/
YouTube: https://www.youtube.com/@algotradepro
Discord: https://discord.gg/Wg5AsWx4
We value your trust and commitment to using our trading strategies. Wishing you continued
success and profitable trading!