OPEN-SOURCE SCRIPT

[imba]lance algo

109 138
🟩 INTRODUCTION
Hello, everyone!
Please take the time to review this description and source code to utilize this script to its fullest potential.

🟩 CONCEPTS
This is a trend indicator. The trend is the 0.5 fibonacci level for a certain period of time.
ảnh chụp nhanh
A trend change occurs when at least one candle closes above the level of 0.236 (for long) or below 0.786 (for short). Also it has massive amout of settings and features more about this below.

With good settings, the indicator works great on any market and any time frame!

A distinctive feature of this indicator is its backtest panel. With which you can dynamically view the results of setting up a strategy such as profit, what the deposit size is, etc.
Please note that the profit is indicated as a percentage of the initial deposit. It is also worth considering that all profit calculations are based on the risk % setting.

🟩 FEATURES
First, I want to show you what you see on the chart. And I’ll show you everything closer and in more detail.
ảnh chụp nhanh
1. Position
ảnh chụp nhanh
2. Statistic panel
ảnh chụp nhanh
3. Backtest panel
ảnh chụp nhanh

Indicator settings:
ảnh chụp nhanh
Let's go in order:
1. Strategies
This setting is responsible for loading saved strategies. There are only two preset settings, MANUAL and UNIVERSAL. If you choose any strategy other than MANUAL, then changing the settings for take profits, stop loss, sensitivity will not bring any results.
You can also save your customized strategies, this is discussed in a separate paragraph “🟩HOW TO SAVE A STRATEGY”
2. Sensitive
Responsible for the time period in bars to create Fibonacci levels
3. Start calculating date
This is the time to start backtesting strategies
4. Position group
Show checkbox - is responsible for displaying positions
Fill checkbox - is responsible for filling positions with background
Risk % - is responsible for what percentage of the deposit you are willing to lose if there is a stop loss
BE target - here you can choose when you reach which take profit you need to move your stop loss to breakeven
Initial deposit- starting deposit for profit calculation
5. Stoploss group
Fixed stoploss % checkbox - If choosed: stoploss will be calculated manually depending on the setting below(formula: entry_price * (1 - stoploss percent)) If NOT choosed: stoploss will be (formula: fibonacci level(0.786/0.236) * (1 + stoploss percent))
6. Take profit group
This group of settings is responsible for how far from the entry point take profits will be and what % of the position to fix
7. RSI
Responsible for configuring the built-in RSI. Suitable bars will be highlighted with crosses above or below, depending on overbought/oversold
8. Infopanels group
Here I think everything is clear, you can hide or show information panels
9. Developer mode
If enabled, all events that occur will be shown, for example, reaching a take profit or stop loss with detailed information about the unfixed balance of the position

🟩 HOW TO USE
Very simple. All you need is to wait for the trend to change to long or short, you will immediately see a stop loss and four take profits, and you will also see prices. Like in this picture:
ảnh chụp nhanh

🟩 ALERTS
There are 3 types of alerts:
1. Long signal
2. Short signal
3. Any alert() function call - will be send to you json with these fields
Pine Script®
{
  "side": "LONG",
  "entry": "64.454",
  "tp1": "65.099",
  "tp2": "65.743",
  "tp3": "66.388",
  "tp4": "67.032",
  "winrate": "35.42%",
  "strategy": "MANUAL",
  "beTargetTrigger": "1",
  "stop": "64.44"
}


🟩 HOW TO SAVE A STRATEGY
First, you need to make sure that the “MANUAL” strategy is selected in the strategy settings.
After this, you can start selecting parameters that will show the largest profit in the statistics panel.
I have highlighted what you need to pay attention to when choosing a strategy
ảnh chụp nhanh

Let's assume you have set up a strategy. The main question is how to preserve it?
Let’s say the strategy turned out with the following parameters:

ảnh chụp nhanh
Next we need to find this section of code:
Pine Script®
// STRATS
selector(string strategy_name) =>
strategy_settings = Strategy_settings.new()
switch strategy_name
"MANUAL" =>
strategy_settings.sensitivity := 18
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
"UNIVERSAL" => 
strategy_settings.sensitivity := 20
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
// "NEW STRATEGY" => 
// strategy_settings.sensitivity := 20
// strategy_settings.risk_percent := 1
// strategy_settings.break_even_target := "1"
// strategy_settings.tp1_percent := 1
// strategy_settings.tp1_percent_fix := 40
// strategy_settings.tp2_percent := 2
// strategy_settings.tp2_percent_fix := 30
// strategy_settings.tp3_percent := 3
// strategy_settings.tp3_percent_fix := 20
// strategy_settings.tp4_percent := 4
// strategy_settings.tp4_percent_fix := 10
// strategy_settings.fixed_stop := false
// strategy_settings.sl_percent := 0.0
strategy_settings
// STRATS


Let's uncomment on the latest strategy called "NEW STRATEGY" rename it to "SOL 5m" and change the sensitivity:
Pine Script®
// STRATS
selector(string strategy_name) =>
strategy_settings = Strategy_settings.new()
switch strategy_name
"MANUAL" =>
strategy_settings.sensitivity := 18
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
"UNIVERSAL" => 
strategy_settings.sensitivity := 20
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
"SOL 5m" => 
strategy_settings.sensitivity := 15
strategy_settings.risk_percent := 1
strategy_settings.break_even_target := "1"
strategy_settings.tp1_percent := 1
strategy_settings.tp1_percent_fix := 40
strategy_settings.tp2_percent := 2
strategy_settings.tp2_percent_fix := 30
strategy_settings.tp3_percent := 3
strategy_settings.tp3_percent_fix := 20
strategy_settings.tp4_percent := 4
strategy_settings.tp4_percent_fix := 10
strategy_settings.fixed_stop := false
strategy_settings.sl_percent := 0.0
strategy_settings
// STRATS


Now let's find this code:
Pine Script®
strategy_input = input.string(title = "STRATEGY", options = [
     "MANUAL",
     "UNIVERSAL",
     "===============",
     "-------A-------",
     "-------B-------",
     "-------C-------",
     "-------D-------",
     "-------E-------",
     "-------F-------",
     "-------G-------",
     "-------H-------",
     "-------I-------",
     "-------J-------",
     "-------K-------",
     "-------L-------",
     "-------M-------",
     "-------N-------",
     "-------O-------",
     "-------P-------",
     "-------Q-------",
     "-------R-------",
     "-------S-------",
     "-------T-------",
     "-------U-------",
     "-------V-------",
     "-------W-------",
     "-------X-------",
     "-------Y-------",
     "-------Z-------"
     ], defval = "MANUAL", tooltip = "EN:\nTo manually configure the strategy, select MANUAL otherwise, changing the settings won't have any effect\nRU:\nЧтобы настроить стратегию вручную, выберите MANUAL в противном случае изменение настроек не будет иметь никакого эффекта")


And let's add our new strategy there, it turned out like this:
Pine Script®
strategy_input = input.string(title = "STRATEGY", options = [
     "MANUAL",
     "UNIVERSAL",
     "===============",
     "-------A-------",
     "-------B-------",
     "-------C-------",
     "-------D-------",
     "-------E-------",
     "-------F-------",
     "-------G-------",
     "-------H-------",
     "-------I-------",
     "-------J-------",
     "-------K-------",
     "-------L-------",
     "-------M-------",
     "-------N-------",
     "-------O-------",
     "-------P-------",
     "-------Q-------",
     "-------R-------",
     "-------S-------",
     "SOL 5m",
     "-------T-------",
     "-------U-------",
     "-------V-------",
     "-------W-------",
     "-------X-------",
     "-------Y-------",
     "-------Z-------"
     ], defval = "MANUAL", tooltip = "EN:\nTo manually configure the strategy, select MANUAL otherwise, changing the settings won't have any effect\nRU:\nЧтобы настроить стратегию вручную, выберите MANUAL в противном случае изменение настроек не будет иметь никакого эффекта")


That's all. Our new strategy is now saved! It's simple! Now we can select it in the list of strategies:
ảnh chụp nhanh

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.