INVITE-ONLY SCRIPT
HaP Robot

What is the HaP Robot?
This code is for the "HaP Robot," an advanced automated trading (algo-trading) signal generator and scanner that runs on TradingView. Its primary purpose is to scan predefined lists of stocks (in groups) based on a specific strategy and, when buy or sell conditions are met, to generate alert messages in a special format to be sent to a specific brokerage's API.
In other words, this is not just an indicator but the "brain" of an automated trading infrastructure.
Core Components and Functions:
To better understand how the code works, we can break it down into its main sections:
1. User Inputs
This section allows the user to customize the strategy and settings.
tutar (Amount): Determines the monetary amount for each trade (e.g., 10,000 TRY).
APIKEY and TOKEN: These are the credentials provided by the brokerage for automated trading. This information is included in the generated alert message.
grupSec (Group Selection): Used to select the list of stocks to be scanned. It offers 14 different groups and a "CUSTOM LIST" option. This allows the code to scan nearly 40 stocks simultaneously.
per (Period): Allows you to select the timeframe for the scans (e.g., 1h, 4h, 1D).
2. Technical Indicators and Calculations
These are the mathematical calculations that form the basis of the strategy.
V5 Critical Threshold: This is the strategy's main indicator. Unlike standard moving averages, it involves mathematical calculations that adjust its speed based on increases or decreases in market volatility. It reacts faster during high volatility and slower during low volatility. The code calculates three different V5 Critical Thresholds:
current_V5: The V5 for the current period open on the chart.
v5_daily: The V5 on the daily period. This is used as a reference point to understand the overall trend.
lower_v5: The V5 from one timeframe lower than the current period. For instance, if you are on a 1-hour chart, it calculates the 30-minute V5. This is used to catch signals earlier.
EMA (Exponential Moving Average): A simple 5-period exponential moving average used to track short-term price movements.
Blue Arrow Signal: A volatility-based trailing stop loss indicator. It generates a "Buy" signal when the price crosses above this line and a "Sell" signal when it crosses below.
3. Trading Strategy (Criteria)
Data from the indicators are combined to generate BUY and SELL signals. It executes trades using strategies compatible with the HaP system.
4. Position Management
The code includes a position tracking mechanism to prevent consecutive buys or sells on the same stock.
5. Multi-Symbol Scanning and Automated Alert System
This is the code's most critical and powerful feature.
Symbol Groups: Variables like a01, a02... a35 contain BIST stocks based on the group selected by the user. If "CUSTOM LIST" is chosen, the symbols entered manually by the user are scanned.
alertTrigger Function: This function runs the strategy for each stock individually.
It uses the request.security() command to pull the price and signal data (the Sinyal variable) for each stock in the list.
It tracks the position status for each stock separately. This allows it to manage the positions of 40 different stocks without confusion.
When a BUY signal occurs for a stock and there is no existing position for it:
It calculates how many lots/shares to buy based on the specified tutar (amount).
It creates an alert text containing information like the APIKEY, TOKEN, symbol name, buy price, and quantity.
It triggers this special text using the alert() command. This alert can be sent to the brokerage's system via TradingView's "Webhook URL" feature to execute the trade automatically.
When a SELL signal occurs for a stock and there is an existing position, it creates a sell alert in the same manner to close the position.
In Summary, What Does It Do?
This script continuously scans a stock group you've selected (e.g., Group 1, consisting of 40 stocks) on your chosen period (e.g., 4-hour). When it identifies a buying or selling opportunity based on its internal volatility-sensitive V5 and Blue Arrow strategy, it automatically prepares the order command to be sent to your brokerage (e.g., "BUY 10,000 TRY worth of THYAO at market price") and triggers it as an alert. By connecting these alerts to a webhook, you can run a fully automated trading robot.
This code is for the "HaP Robot," an advanced automated trading (algo-trading) signal generator and scanner that runs on TradingView. Its primary purpose is to scan predefined lists of stocks (in groups) based on a specific strategy and, when buy or sell conditions are met, to generate alert messages in a special format to be sent to a specific brokerage's API.
In other words, this is not just an indicator but the "brain" of an automated trading infrastructure.
Core Components and Functions:
To better understand how the code works, we can break it down into its main sections:
1. User Inputs
This section allows the user to customize the strategy and settings.
tutar (Amount): Determines the monetary amount for each trade (e.g., 10,000 TRY).
APIKEY and TOKEN: These are the credentials provided by the brokerage for automated trading. This information is included in the generated alert message.
grupSec (Group Selection): Used to select the list of stocks to be scanned. It offers 14 different groups and a "CUSTOM LIST" option. This allows the code to scan nearly 40 stocks simultaneously.
per (Period): Allows you to select the timeframe for the scans (e.g., 1h, 4h, 1D).
2. Technical Indicators and Calculations
These are the mathematical calculations that form the basis of the strategy.
V5 Critical Threshold: This is the strategy's main indicator. Unlike standard moving averages, it involves mathematical calculations that adjust its speed based on increases or decreases in market volatility. It reacts faster during high volatility and slower during low volatility. The code calculates three different V5 Critical Thresholds:
current_V5: The V5 for the current period open on the chart.
v5_daily: The V5 on the daily period. This is used as a reference point to understand the overall trend.
lower_v5: The V5 from one timeframe lower than the current period. For instance, if you are on a 1-hour chart, it calculates the 30-minute V5. This is used to catch signals earlier.
EMA (Exponential Moving Average): A simple 5-period exponential moving average used to track short-term price movements.
Blue Arrow Signal: A volatility-based trailing stop loss indicator. It generates a "Buy" signal when the price crosses above this line and a "Sell" signal when it crosses below.
3. Trading Strategy (Criteria)
Data from the indicators are combined to generate BUY and SELL signals. It executes trades using strategies compatible with the HaP system.
4. Position Management
The code includes a position tracking mechanism to prevent consecutive buys or sells on the same stock.
5. Multi-Symbol Scanning and Automated Alert System
This is the code's most critical and powerful feature.
Symbol Groups: Variables like a01, a02... a35 contain BIST stocks based on the group selected by the user. If "CUSTOM LIST" is chosen, the symbols entered manually by the user are scanned.
alertTrigger Function: This function runs the strategy for each stock individually.
It uses the request.security() command to pull the price and signal data (the Sinyal variable) for each stock in the list.
It tracks the position status for each stock separately. This allows it to manage the positions of 40 different stocks without confusion.
When a BUY signal occurs for a stock and there is no existing position for it:
It calculates how many lots/shares to buy based on the specified tutar (amount).
It creates an alert text containing information like the APIKEY, TOKEN, symbol name, buy price, and quantity.
It triggers this special text using the alert() command. This alert can be sent to the brokerage's system via TradingView's "Webhook URL" feature to execute the trade automatically.
When a SELL signal occurs for a stock and there is an existing position, it creates a sell alert in the same manner to close the position.
In Summary, What Does It Do?
This script continuously scans a stock group you've selected (e.g., Group 1, consisting of 40 stocks) on your chosen period (e.g., 4-hour). When it identifies a buying or selling opportunity based on its internal volatility-sensitive V5 and Blue Arrow strategy, it automatically prepares the order command to be sent to your brokerage (e.g., "BUY 10,000 TRY worth of THYAO at market price") and triggers it as an alert. By connecting these alerts to a webhook, you can run a fully automated trading robot.
招待専用スクリプト
こちらのスクリプトにアクセスできるのは投稿者が承認したユーザーだけです。投稿者にリクエストして使用許可を得る必要があります。通常の場合、支払い後に許可されます。詳細については、以下、作者の指示をお読みになるか、agahakanagaに直接ご連絡ください。
スクリプトの機能を理解し、その作者を全面的に信頼しているのでなければ、お金を支払ってまでそのスクリプトを利用することをTradingViewとしては「非推奨」としています。コミュニティスクリプトの中で、その代わりとなる無料かつオープンソースのスクリプトを見つけられる可能性もあります。
作者の指示
They can contact me on my X account.
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。
招待専用スクリプト
こちらのスクリプトにアクセスできるのは投稿者が承認したユーザーだけです。投稿者にリクエストして使用許可を得る必要があります。通常の場合、支払い後に許可されます。詳細については、以下、作者の指示をお読みになるか、agahakanagaに直接ご連絡ください。
スクリプトの機能を理解し、その作者を全面的に信頼しているのでなければ、お金を支払ってまでそのスクリプトを利用することをTradingViewとしては「非推奨」としています。コミュニティスクリプトの中で、その代わりとなる無料かつオープンソースのスクリプトを見つけられる可能性もあります。
作者の指示
They can contact me on my X account.
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。