Welcome back to our TradingView tutorial series! We have reached lesson number 3 where we will be learning how to open a command on TradingView and send it to a Mizar Bot.
If you're new here and missed the first two lessons, we highly recommend starting there as they provide a solid foundation for understanding the concepts we'll be covering today. In the first lesson, you will be learning how to create a Bollinger Band indicator using Pine Script: In the second lesson, you will be guided through every step of coding the entry logic for your own Bollinger Band indicator using Pine Script:
In this brief tutorial, we'll walk you through the process of utilizing your custom indicator, Mikilap, to determine the ideal timing for sending a standard JSON command to a Mizar DCA bot. By the end of this lesson, you'll have the ability to fine-tune your trading strategies directly on Mizar using indicators from TradingView. So, sit back, grab a cup of coffee (or tea), and let's get started!
To establish a common starting point for everyone, please use the following code as a starting point. It incorporates the homework assignment from our Pine Script lesson number 2. By using this code as our foundation, we can collectively build upon it and delve into additional concepts together. So, sit back, grab a cup of coffee (or tea), and let's get started!
Our target: Use our own indicator: Mikilap, to define the timing to send a standard JSON command to a Mizar DCA bot. (1) define the JSON command in a string, with variables for - API key - BOT id - BASE asset (coin to trade) (2) send the JSON command at the beginning of a new bar (3) setup the TradingView alert to transport our JSON command via Webhook/API to the Mizar DCA bot
Below you can see the code, which defines the individual strings to prepare the JSON command. In the following, we will explain line by line, what each individual string and command is used for.
// Defintion of a Pine Script individual function to handle the Request and avoid Repainting Errors
As the JSON syntax requires quotation marks (“) as part of the command, we define the string for the entry message with single quotations ('). So please ensure to open and close these quotations before or after each operator (=, +, …).
Current status:
- We have the entry logic and show every possible entry on the chart => label. - We have the JSON command ready in a combined string (Entry_message) including the BOT identifier (API key and BOT id) as well as the coin pair to buy.
What is missing?
- To send this message at the opening of a new bar as soon as the entry logic is true. As we know these moments already, because we are placing a label on the chart, we can use this condition for the label to send the message as well.
alert(): built-in function
- We recommend checking the syntax and parameters for alert() in the Pine Script Reference Manual. As we want to send only one opening command, we are using the alert.freq_once_per_bar. To prepare for more complex Pine Scripts, we have placed the alert() in a separate local scope of an if condition, which is not really needed in this script as of now.
c) set the condition to our indicator Mikilap and the menu will change its format (configuration of the TradingView alert) https://www.tradingview.com/x/WvWMXtcg
For our script nothing else is to do (you may change the expiration date and alert name), except to add the Webhook address in the Notification tab. https://www.tradingview.com/x/U3ZZICzO
Congratulations on finishing the third lesson on TradingView - we hope you found it informative and engaging! You are now able to code a well-working easy Pine Script indicator, which will send signals and opening commands to your Mizar DCA bot.
We're committed to providing you with valuable insights and practical knowledge throughout this tutorial series. So, we'd love to hear from you! Please leave a comment below with your suggestions on what you'd like us to focus on in the next lesson.
Thanks for joining us on this learning journey, and we're excited to continue exploring TradingView with you!
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.