ProfitView Strategy Template

Hello traders,

This script took me a full week of coding/testing, sweat, and tears - and I’m too nice as I’m giving it for free to the community.

If you're tired of manual trading and looking for a solid strategy template to pair with your indicators, look no further.
This Pine Script v5 strategy template is engineered for maximum customization and risk management.
Best part?
This Pine Script v5 template facilitates the dynamic construction of ProfitView alerts, sparing users the time and effort of mastering the ProfitView syntax and manually creating alert commands.

This powerful tool gives much power to those who don't know how to code in Pinescript and want to automate their indicators' signals via the ProfitView Chrome extension.


ProfitView is a trading bot software that forwards TradingView alerts to your brokers (examples: Binance, Oanda, Coinbase, Bybit, etc.) for automating trading.
Many traders don't know how to dynamically create ProfitView-compatible alerts using the data from their TradingView scripts.

Traders using trading bots want their alerts to reflect the stop-loss/take-profit/trailing-stop/stop-loss to break options from your script and then create the orders accordingly.

This script showcases how to create ProfitView alerts dynamically.


1) You'll have to create one alert per asset X timeframe = 1 chart.
Example: 1 alert for EUR/USD on the 5 minutes chart, 1 alert for EUR/USD on the 15-minute chart (assuming you want your bot to trade the EUR/USD on the 5 and 15-minute timeframes)

2) Select the Order fills and alert() function calls condition

3) For each alert, the alert message is pre-configured with the text below

Please leave it as it is.
It's a TradingView native variable that will fetch the alert text messages built by the script.

4) ProfitView doesn't use webhook technology, so setting a webhook URL from the alerts notifications tab is unnecessary.


I) Modular Indicator Connection
* plug your existing indicator into the template.
* Only two lines of code are needed for full compatibility.

Step 1: Create your connector

Adapt your indicator with only 2 lines of code and then connect it to this strategy template.

To do so:

1) Find in your indicator where the conditions print the long/buy and short/sell signals.
2) Create an additional plot as below

I'm giving an example with a Two moving averages cross.

Please replicate the same methodology for your indicator, whether a MACD , ZigZag, Pivots , higher-highs, lower-lows or whatever indicator with clear buy and sell conditions.

indicator("Supertrend", overlay = true, timeframe = "", timeframe_gaps = true)

atrPeriod = input.int(10,    "ATR Length", minval = 1)
factor =    input.float(3.0, "Factor",     minval = 0.01, step = 0.01)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)

supertrend := barstate.isfirst ? na : supertrend
bodyMiddle = plot(barstate.isfirst ? na : (open + close) / 2, display = display.none)
upTrend =    plot(direction < 0 ? supertrend : na, "Up Trend",   color = color.green, style = plot.style_linebr)
downTrend =  plot(direction < 0 ? na : supertrend, "Down Trend", color = color.red,   style = plot.style_linebr)

fill(bodyMiddle, upTrend,   color.new(color.green, 90), fillgaps = false)
fill(bodyMiddle, downTrend, color.new(color.red,   90), fillgaps = false)

buy  = ta.crossunder(direction, 0)
sell = ta.crossunder(direction, 0)

//////// CONNECTOR SECTION //////// 

Signal = buy ? 1 : sell ? -1 : 0
plot(Signal, title = "Signal", display = display.data_window)

//////// CONNECTOR SECTION //////// 

[b]Important Notes[/b]

🔥 The Strategy Template expects the value to be exactly 1 for the bullish signal and -1 for the bearish signal

Now, you can connect your indicator to the Strategy Template using the method below or that one.

Step 2: Connect the connector

1) Add your updated indicator to a TradingView chart
2) Add the Strategy Template as well to the SAME chart
3) Open the Strategy Template settings, and in the Data Source field, select your 🔌Connector🔌 (which comes from your indicator)

Note it doesn’t have to be named 🔌Connector🔌 - you can name it as you want - however, I recommend an explicit name you can easily remember.

From then, you should start seeing the signals and plenty of other stuff on your chart.

🔥 Note that whenever you update your indicator values, the strategy statistics and visuals on your chart will update in real-time

II) BOT Risk Management:

- Max Drawdown:
Mode: Select whether the max drawdown is calculated in percentage (%) or USD.
Value: If the max drawdown reaches this specified value, set a value to halt the bot.

- Max Consecutive Days:
Use Max Consecutive Days BOT Halt: Enable/Disable halting the bot if the max consecutive losing days value is reached.

- Max Consecutive Days: Set the maximum number of consecutive losing days allowed before halting the bot.

- Max Losing Streak:
Use Max Losing Streak: Enable/Disable a feature to prevent the bot from taking too many losses in a row.

- Max Losing Streak Length: Set the maximum length of a losing streak allowed.
Margin Call:

- Use Margin Call: Enable/Disable a feature to exit when a specified percentage away from a margin call to prevent it.
Margin Call (%): Set the percentage value to trigger this feature.

- Close BOT Total Loss:
Use Close BOT Total Loss: Enable/Disable a feature to close all trades and halt the bot if the total loss is reached.

- Total Loss ($): Set the total loss value in USD to trigger this feature.
Intraday BOT Risk Management:

- Intraday Losses:
Use Intraday Losses BOT Halt: Enable/Disable halting the bot on reaching specified intraday losses.
Mode: Select whether the intraday loss is calculated in percentage (%) or USD.

- Max Intraday Losses (%): Set the value for maximum intraday losses.
Limit Intraday Trades:

- Use Limit Intraday Trades: Enable/Disable a feature to limit the number of intraday trades.

- Max Intraday Trades: Set the maximum number of intraday trades allowed.
Restart Intraday EA:

- Use Restart Intraday EA: Enable/Disable a feature to restart the bot at the first bar of the next day if it has been stopped with an intraday risk management safeguard.

III) Order Types and Position Sizing

- Choose between market, limit, or stop orders.
- Set your position size directly in the template.

Please use the position size from the “Inputs” and not the “Properties” tab.
I know it's redundant. - the template needs this value from the "Inputs" tab to build the alerts, and the Backtester needs it from the "Properties" tab.

IV) Advanced Take-Profit and Stop-Loss Options

- Choose to set your SL/TP in either pips or percentages.
- Option for multiple take-profit levels and trailing stop losses.
- Move your stop loss to break even +/- offset in pips for “risk-free” trades.

V) Miscellaneous
Retry order openings if they fail.

Order Types:
Select and specify order type and price settings.

Position Size:
Define the type and size of positions.

Leverage settings, including margin type and hedge mode.

Limit trades to specific sessions.

Limit trades to a specific date range.

Trades Direction:
Direction: Specify the market direction for opening positions.

VI) Notifications (Telegram/Discord/Email/IFTTT/Twilio/SMS)
Customize notifications sent to Telegram, Discord, Email, IFTTT, Twilio, and ProfitView Logger.

VII) Logger

The ProfitView commands are logged in the TradingView logger.
You'll find more information about it in this TradingView blog post.


1) Transform your indicator into a ProfitView trading bot more easily than before
Connect your indicator to the template
Create your alerts
Set your EA settings

2) Save Time
Auto-generated alert messages for ProfitView.
I tested them all and checked with the support team what could/couldn’t be done.

3) Be in Control
Manage your trading risks with advanced features.

4) Customizable
Fits various trading styles and asset classes.


* Make sure you have your ProfitView account and do the settings correctly in your Chrome extension. If you don't know how to do it, read the documentation + ask for help in the ProfitView Discord support channel.
* If there is any issue with the template, ask me in the comments section - I’ll answer quickly.


1) I connected this strategy template to a dummy Supertrend script.
I could have selected any other indicator or concept for this script post.
I wanted to share an example of how you can quickly upgrade your strategy, making it compatible with ProfitView.

2) The backtest results aren't relevant for this educational script publication.
I used realistic backtesting data but didn't look too much into optimizing the results, as this isn't the point of why I'm publishing this script.
This strategy is a template to be connected to any indicator - the sky is the limit. :)

3) This template is made to take 1 trade per direction at any given time.
Pyramiding is set to 1 on TradingView.

The strategy default settings are:

* Initial Capital: 100000 USD
* Position Size: 1%
* Commission Percent: 0.075%
* Slippage: 1 tick
* No margin/leverage used

Best regards,

👨‍💻 Need help you with your FTMO/TopStep verif?

⭐️ Listed as TradingView Trusted Pine Programmer

📧 dave@best-trading-indicator

Telegram: Daveatt

⏩ Course: best-trading-indicator.com

Twitter: twitter.com/bti_trading
Script open-source

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzarlo gratuitamente, ma il riutilizzo del codice è subordinato al rispetto del Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questo script sui tuoi grafici?