Can we link the watchlist to the Chartink scanner? Meaning, the results that appear on the Chartink scanner get automatically updated in the watchlist. If yes, then how?
Hello @Saurabh
Yes, we can do this by using Chartink alerts.
- First, you need to create an alert on the specific screener in Chartink.
- Once the alert is set up, it will send notifications to your system via desktop or SMS.
- By utilizing the webhook URL feature, you can receive these alerts directly on your system. These alerts can then be read by your program, which can be designed to analyze the alerts and place trades automatically in your trading account.
This method ensures seamless integration between Chartink alerts and your trading system for efficient and automated trading.
Thanks @Tradehull_Shubham
Can you provide the code used to analyze alerts, as mentioned in point number 3?
Hello @Saurabh,
Sure! Here’s how you can proceed:
Below is the code you need to run on your system:
from flask import Flask, request
import os
import datetime
import pandas as pd
app = Flask(__name__)
def log_name():
return "Dependencies\\" + datetime.datetime.now().strftime("%Y-%m-%d") + '.txt'
today = datetime.datetime.today().strftime("%d-%m-%Y")
filename = f"message_data {today}.csv"
if not os.path.exists("Dependencies\\" + filename):
with open("Dependencies\\" + filename, 'w') as file:
pass
message_dict = {}
index = 0
@app.route('/post', methods=['POST'])
def post():
global index
f = open(log_name(), 'a+')
print('New message received at ', datetime.datetime.now().time())
try:
message_dict[index] = {}
msg = True
while msg:
my_str = request.get_data()
my_str = eval(my_str.decode('utf-8'))
current_time = datetime.datetime.now().time()
my_str['datetime'] = current_time
message_dict[index] = my_str
index += 1
df = pd.DataFrame(message_dict).T
print(df)
msg = False
updated = True
while updated:
try:
today = datetime.datetime.today().strftime("%d-%m-%Y")
filename = f"message_data {today}.csv"
df.to_csv("Dependencies\\" + filename)
updated = False
except Exception as e:
pass
except Exception as e:
print(e)
f.write(str(request.get_data()) + '\n')
f.close()
return 'done'
app.run(host='0.0.0.0', port=80)
Steps to Set It Up:
- Run the above code on your system
- Save it as a Python file (e.g.,
signal_receiver.py). - Run the file using Python (
python signal_receiver.py).
- Get Your System’s IP Address
Find the IP address of the system where this file is running. Let’s assume your IP address is4.12.12.44. - Webhook URL Setup
Use the following URL as your webhook URL in Chartink to receive signals:
arduino
CopyEdit
http://4.12.12.44/post
- What the File Does
- It listens for signals sent from Chartink and logs them into a file.
- The signals will be saved in the
Dependenciesfolder in your current directory with the filename format:
message_data <date>.csv
For example:message_data 22-01-2025.csv.
- Reading Signals
Continuously monitor the CSV file (message_data <date>.csv) for new alerts. Once an alert is received, you can proceed with order placement based on the signal.
Thanks @Tradehull_Shubham for your support. But I want to know how the Python strategy file, which contains login credentials, will read this signal file. I mean, how will the signal receiver file and the Python strategy file synchronize with each other?
Hello @Saurabh ,
To integrate Chartink alerts with our Python application, here’s what we need to do:
- Set Up Chartink Alerts:
- First, log into your Chartink account and ensure you have an active subscription. This allows us to set up and receive alerts.
- Use the screener to define the criteria for the alerts according to what we’re monitoring in the markets.
- When setting up each alert, specify that notifications should be sent to your desktop or mobile device. There, you’ll also enter a special link, which I’ll provide, that directs these alerts to our server. This link will look something like
http://your_ip_address/post.
- Receiving Alerts on Our Server:
- Our server is set up to listen for these alerts from Chartink. Whenever your criteria are met, Chartink sends the information directly to our server through the link you set up.
- There’s no need to handle or store any login credentials on our server for this to work. It’s all handled securely through Chartink.
- Handling and Utilization:
Once we have everything set up, simply run the specified program on your server. It remains active and waiting for alerts. When an alert is received, the program automatically captures and stores this information in the designated file on our system, typically found under your current Dependencies/message data directory. You don’t need to do anything else; the system handles all the storage automatically as soon as any alert comes through.