For traders seeking to automate their strategies, OpenAlgo and TradingView offer a powerful combination. OpenAlgo is an open-source algo-trading platform allowing seamless integration with various brokers and charting tools, including TradingView. By connecting these platforms, you can execute your TradingView strategies automatically without writing any code!
Here’s a step-by-step guide to get you started:
Prerequisites:
- OpenAlgo: Ensure you have OpenAlgo installed in a Python environment (preferably Python 3.10 or higher).
- Ngrok: Install and configure Ngrok with a custom domain for secure communication between platforms.
- .env File: Set up your .env file with the Ngrok custom domain and other necessary configurations.
Step 1: Start OpenAlgo and Log In
- Launch the OpenAlgo application.
- Open a web browser and navigate to the OpenAlgo host URL (typically http://127.0.0.1:5000/).
- Log in using your OpenAlgo credentials.
Step 2: Choose Your Broker
- Upon successful login, you’ll be presented with a list of supported brokers. Select your preferred broker and complete the necessary authentication steps.
Step 3: Download Master Contract and Access TradingView Tab
- Wait for the master contract to download successfully. This contract facilitates communication between OpenAlgo and your broker.
- Once downloaded, navigate to the “Tradingview” tab within the OpenAlgo interface.
Step 4: Generate TradingView JSON Message
- In the TradingView JSON Generator section, enter the OpenAlgo trading symbol for the instrument you want to trade.
- Select the appropriate exchange and product type (e.g., MIS, CNC).
- Click “Generate JSON” to create the message your TradingView strategy will send to OpenAlgo.
- Copy the generated JSON message.
Step 5: Create a TradingView Alert
- In TradingView, open the chart with the strategy you wish to automate.
- Access the “Indicators & Strategies” menu and select your chosen strategy.
- Click on the three dots next to the strategy name and choose “Add alert on…”.
- Select the strategy name as the condition for the alert.
- In the “Alert message” box, paste the JSON message you copied from OpenAlgo.
- Optionally, you can configure the alert with a specific expiration date or choose to trigger it “Every Time” the condition is met.
- Under “Notifications,” select “Webhook URL” and paste the TradingView Webhook URL provided by OpenAlgo. This URL directs the alert message to the OpenAlgo platform.
- Click “Create” to finalize your alert setup.
Step 6 (Optional): Configure Trading Quantity
- If your strategy requires a specific trade quantity, return to the “Indicators & Strategies” menu in TradingView.
- Right-click on your strategy and choose “Properties.”
- Adjust the “Order size” parameter to your desired quantity.
- Click “OK” to save the changes.
That’s it! You’ve successfully connected your TradingView strategy to OpenAlgo for automated trading. Now, whenever your strategy generates a buy or sell signal, the corresponding order will be automatically placed through your chosen broker. Remember, OpenAlgo’s open-source nature empowers you to explore, modify, and customize the platform to suit your specific trading needs.