# 💻CONDITION MANAGER

Code Zero Visual Trading for TradingView

**CONDITION MANAGER** is a key module of the complex, which allows you to skillfully combine various external indicators to form trading signals or calculate constants. Thanks to its power, you can build most of your trading strategies using just **CONDITION MANAGER**" as if it's your Swiss Army knife in the world of trading.

**Blocks of the module:**

**Association**

This module implements your ideas, displays signals on the history, and organizes algo-trading.

### General description of the indicator

**CONDITION MANAGER** is a real helper for traders who want to independently manage their trading strategies. It allows you to select the necessary data for analysis, such as stock prices, trading volumes, or indicators from other indicators. Based on these data, you can create rules (**RULE**) that will be the basis of the strategy.

Each rule can be configured using mathematical calculations, logical conditions, and special functions for data processing. This allows for precise market analysis and informed decision-making.

For more complex strategies, rules can be grouped (**GROUP**). There are four groups, each of which can contain a set of rules combined with logical "**AND**" or "**OR**" operators. Groups can also be interconnected by the same principles, creating complex combinations of conditions.

When all conditions are checked and they meet the set criteria, the indicator can send a signal to an external system. Such a signal can contain a text message, which is formed from standard TradingView variables and special variables created on values from rules and constants.

As for constants (**CONSTANT**), the indicator provides four special variables with numerical values that can be used to pass parameters into the strategy or as variables in alerts. These constants can have a constant value or a dynamic one that changes over time, making them useful for adapting the strategy to market changes, for example, when the price reaches the upper boundary of the Bollinger Bands.

As a result, this indicator allows traders to create individual trading strategies of any complexity, using a variety of data and conditions, and easily integrate them with external automated trading systems.

**Hint**
In each indicator at the top, there is a **DESCRIPTION **field where you can write any text that will help to label this indicator on the *TradingView* chart.

### 1. RULE

This block helps traders to choose different types of trading data, such as stock prices, sales volume, or indicators from other indicators. Based on these data, you can create special rules (**RULE**) that will manage your trading strategy.

In each such rule, you can apply mathematical calculations, use logical conditions, and combine data using aggregator functions for more precise analysis and decision-making in trading.

#### Field descriptions:

#### Data source**:**

**:**

This is a field for selecting the data source that will be used in the rule. It can be any price or indicator.

#### Source Pointer or Aggregator Function:

This field indicates which of the data fields needs to be used for the next step of the rule, or which aggregator function needs to be performed on **S1_1** / **S2_1** with parameters **S1_2** / **S2_2**.

Thus, after performing these actions, we will get the initial value for checking the rule condition (**the upper value - S1 and the lower value S2**).

#### Condition:

This field sets the condition or action by which we will determine the fulfillment of the rule.

### 2. GROUP

A rule group (**GROUP**) is like a list of instructions for a program, telling it what to do in certain situations. These instructions can be as simple as "buy when the price is above the previous high," or as complex with many details. The user has the option to select four such rule groups: **G1**, **G2**, **G3**, **G4**.

Imagine you're preparing a meal and you have recipes (rules) for a salad and a soup. If you use "**AND**," you need to prepare both the salad and soup for the meal to be complete. But if you use "**OR**," preparing just one of them is sufficient.

The same applies in trading: if you want the conditions to work together ("**AND**"), all of them must occur to execute the action. If you set "**OR**," then it is sufficient for at least one condition to occur for the system to act.

This gives traders the ability to create strategies with various "scenarios," experimenting with different sets of rules to see which ones work best.

The program has a special place where you can configure how the rules in the group will interact with each other:

### 3. Logical Union of GROUPS

**Rule groups** (*G1*, *G2*, *G3*, *G4*) can be combined with each other using the same logic as the rules within a group (**AND** or **OR**).

Imagine the rule groups as separate teams in a large football league. Each team has its own strategy and tactics, but when it comes to the championship, they unite using "**AND**" or "**OR**" to achieve a common goal - victory in the market.

If you use the "**AND**" operator to combine groups, it means that the conditions of all groups must be met simultaneously to activate the signal. It's as if all teams must win their matches for the trade to be executed. A high strategic game where everything must come together perfectly!

But if you combine groups through "**OR**," fulfilling the conditions of at least one group of rules is enough to activate the signal. That is, if even one team wins, you get the green light for the trade. This adds flexibility, as it allows for quicker responses to changing market conditions.

This approach allows for more flexible and adaptive strategies that can respond to various market behavior scenarios, using combinations of different rule groups. It's like having not one, but several coaches, each offering their game plan, and you choose the best option for attacking or defending your investments.

### 4. Constants

**IMPORTANT**

In the constants block, all calculations are performed sequentially, one after the other, starting from the top and moving downwards. Regardless of whether it's multiplication or division - there are no "priority" operations, everything goes in order, like in a shopping list: first, we buy bread, then milk, and only after that - chocolate.

**Clarification**:

*TakeProfit**: *
`close + 1.5 * ATR`

you need to calculate in this way:

`ATR * 1.5 + close`

First, the multiplication is carried out and the closing price is added to the result.

**Clarification**:

*StopLoss**: *

`low - 1.5 * ATR`

you need to calculate in this way:

`ATR * (-1.5) + low`

First, multiplication is performed to obtain a negative value, and then the minimum price is added to the result.

A **constant** is like a calculator that allows you to combine various data, such as prices and indicator values, and perform simple mathematical operations with them, such as addition or multiplication. You can use a constant to automatically calculate important trading parameters, such as the price for taking profit (*TakeProfit*) or setting a stop loss (*StopLoss*).

The constant (* as shown below*) has 3 blocks of data sources (or user input values) that have the same logic as in the rule block (

**RULE**) and can also be turned on and off (block

**1**). Between these blocks, you can perform mathematical operations: addition (✚), subtraction (➖), modulo subtraction (

**[**➖

**]**), multiplication (✖️), and division (➗) (blocks

**2**,

**3**). An additional '

**NONE**' mode indicates that the next data source should not be included in the calculation chain. Continuing our culinary analogy, it's like deciding not to add salt to a dish - we simply ignore this ingredient.

Imagine that you want to set the *TakeProfit* price based on the current closing price plus one and a half times the value of *ATR* (Average True Range). To do this, you simply need to take the last closing price (**S3**), add to it the result of multiplying the *ATR* (**S1**) by *1.5* (**S2**), and you get your *TakeProfit* price: **close** (**S3**) ✚ **ATR** (**S1**) ✖️**1.5 **(**S2**).

### 5. Alerts

**Alerts** are a built-in feature of *TradingView* that we enhance with additional functionality.

* TradingView alerts* are instant notifications you receive when the market situation matches the conditions you have set. For example, "

*Apple's stock price has risen above $150*". All users can receive pop-up notifications, sound signals, email-to-SMS, and push notifications sent to their phone. Users with

*TradingView Essential, Plus, and Premium subscriptions*can also receive

*Webbhook*notifications when alerts are triggered.

In the **ALERT** block, you need to set the text of the alert template to be sent and the frequency of its sending.

You can supplement the standard variables for messages on *TradingView* with your own, which you create in the "Rules" (**RULE**) and "Constants" (**CONSTANT**) blocks.

**Setting up an alert**

*You can read about how to set up alert sending on the TradingView website:*

*How to connect sending to various trading systems:*

3Commas: https://3commas.io/trading-view

aleeert: https://aleeert.com/docs/

**Hint**

Please note that alerts can also be sent from the **CONDITION MANAGER STRATEGY** module.

### 6. Backtesting Line

The visual back-testing system **CONDITION MANAGER** allows you to test strategies on historical data. This is an additional testing system that complements, rather than replaces, the historical data strategy back-testing system of the *TradingView* platform.

On the chart, this appears as a line of gray squares on each bar, and when your strategy indicates that a condition is met, the squares turn blue. This helps you understand when the strategy is working and to quickly make changes if needed.

These blue squares are your benchmarks on the path to a profitable strategy. They help you identify the points in time when your approach was effective and, conversely, when it's necessary to stop and rethink your tactics.

For convenience, this back-testing line can be displayed at the top, bottom, or turned off.

### 7. Output data

The indicator has from 1 to 7 output values. The first output provides information on whether the conditions are met, and the remaining six are the values of the constants (the outputs are activated depending on whether the constant is enabled: **CONSTANT_1**, **CONSTANT_2**, **CONSTANT_3**, **CONSTANT_4, CONSTANT_5, CONSTANT_6**.

Last updated