Automating Scripts without Code Access
If you don't have access to a script's code, you may still be able to automate the strategy or indicator if it passes one of the three feasibility tests outlined below.
Testing Script Automation Feasibility
To determine if a script can be automated without code access, conduct the following tests in order:
Test 1: Checking for Strategy Scripts
- Apply the script to your chart and create an alert (Alt+A on Windows / Option+A on Mac).
- Under "Condition", select the strategy you want to automate and choose "Order fills only". Show Image
- If you can select "Order fills only", the strategy script is likely automatable. Proceed to the Strategy Implementation section.
Test 2: Checking for alert()
- Attach the script to your chart and click "Settings" on the script's name in the top left corner.
- In the pop-up window, select "Inputs".
- Look for "License ID" or similar in the input options.
If you don't see "Inputs", the script fails Test 2. Proceed to Test 3.
alert()
. Proceed to the alert()
Implementation section. Test 3: Checking for alertcondition()
- With the script on your chart, create an alert (Alt+A on Windows / Option+A on Mac).
- Under "Condition", select the script.
- Look for options like "Going Long" or "Going Short" above the "Crossing" field.
alertcondition()
. Proceed to the alertcondition()
Implementation section.If All Tests Fail
If the script fails all three tests, it cannot be automated without the author adding required code. You can ask the author to make it PineConnector-compatible using these instructions.
Implementing Automated Scripts
Follow the steps below to implement scripts that passed the feasibility tests.
Strategy()
Implementation
For scripts that passed Test 1:
- Apply the strategy script to your desired chart and timeframe.
- Create a new alert (Alt+A on Windows / Option+A on Mac) and select the strategy under "Condition".
- Choose "Order fills only" to ensure the alert only triggers on actual order executions. Show Image
- Configure the alert message to define the trading parameters. Use a basic format like:For more dynamic strategy alerts, utilize placeholders:
{{ticker}}
→ returns the ticker of the symbol used in alert (EURUSd, BTCUSD, etc.){{strategy.position_size}}
→ returns the size of the current position.{{strategy.order.action}}
→ returns the string “buy” or “sell” for the executed order.{{strategy.order.contracts}}
→ returns the number of contracts of the executed order.{{strategy.market_position_size}}
→ returns the size of the current position as an absolute value, i.e. a non-negative number.- Save the alert and wait for it to trigger based on the strategy's conditions.
- Triggered alerts will send the configured message, which PineConnector will use to execute the defined trades.
- Monitor your positions and manage your trades according to your plan.
- You can pause or edit the alert as needed from the TradingView Alerts panel.
- Repeat the process to automate the strategy on additional symbols and timeframes.
- Each alert operates independently, so make sure to set up alerts for all desired symbols and timeframes.
LicenseID,buy,{{ticker}},risk=1
LicenseID,buy,{{ticker}},risk=1,sl=10,tp=20
LicenseID,{{strategy.order.action}},{{ticker}},risk={{strategy.order.contracts}}
alert()
Implementation
For scripts that passed Test 2:
- Update the script's input settings, such as License ID, Stop Loss, Risk, etc. The available options may vary. Click "Ok" to save changes.
- Navigate to the desired symbol and timeframe, then create an alert.
- Select the script under "Condition" and enter this Webhook URL:
- The created alert will display the symbol and timeframe it's running on.
- Triggered alerts, along with inputted settings, will appear in the Alerts log.
- Repeat this process for any additional symbols and timeframes you wish to automate.
For PineConnector v2:
https://pineconnector.net/webhook/
For PineConnector v3:
https://webhook.pineconnector.com
alertcondition()
Implementation
For scripts that passed Test 3:
- Create an alert and select the appropriate script and option under "Condition".
- Under "Options", select "Once Per Bar Close" to minimize repainting issues.
- Configure the alert message based on whether the script is a strategy or indicator:
{{ticker}}
→ the alert's symbol (EURUSD, BTCUSD, etc.){{strategy.position_size}}
→ current position size{{strategy.order.action}}
→ "buy" or "sell" for executed order{{strategy.order.contracts}}
→ number of contracts in executed order{{strategy.market_position_size}}
→ current position size as an absolute (non-negative) value- If an alert triggers, you can pause the active alert.
- Triggered alerts will display
{{strategy.order.action}}
for indicator scripts or actual actions like "buy"/"sell" for strategy scripts. - Repeat this setup for any additional symbols and timeframes to automate.
For basic alerts:
LicenseID,buy,{{ticker}},risk=1
LicenseID,buy,{{ticker}},risk=1,sl=10,tp=20
For strategy scripts:
LicenseID,{{strategy.order.action}},{{ticker}},risk={{strategy.order.contracts}}
Some commonly used placeholders:
Feel free to reach out if you have any other questions! Happy automating!
On this page
- Automating Scripts without Code Access
- Testing Script Automation Feasibility
- Test 1: Checking for Strategy Scripts
- Test 2: Checking for alert()
- Test 3: Checking for alertcondition()
- If All Tests Fail
- Implementing Automated Scripts
- Strategy() Implementation
- alert() Implementation
- alertcondition() Implementation