ProfitView Strategy TemplateHello 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.
IMPORTANT NOTES
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.
TRADINGVIEW ALERTS
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
{{strategy.order.alert_message}}
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.
KEY FEATURES
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.
//@version=5
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)
= 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 ////////
Important Notes
🔥 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:
Leverage settings, including margin type and hedge mode.
Session:
Limit trades to specific sessions.
Dates:
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 .
WHY YOU MIGHT NEED THIS TEMPLATE
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.
REQUIREMENTS
* 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.
BACKTEST RESULTS FROM THIS POST
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,
Dave
Profitview
Strategy Backtesting Template [MYN]A few people have been asking me to share my backtesting template. Currently I use this as my starting point for validating existing strategies and developing new ones.
Features:
Trading Date Range
Trade Direction
4 progressive take profits with target percents and percentage of position to take profit on (Thanks adolgo)
Variable percentage Stop Loss
Automatic ProfitView Alert Syntax builder for Longs and Shorts
ADX checkbox to automatically add conditional logic to your strategy
AlphaTrend For ProfitViewThis strategy is based on the AlphaTrend indicator by KivancOzbilgic A full description of this algorithm functionality may be found by clicking the linked image above.
Changes and/or additions:
It is now a backtestable strategy
Updated alert trigger logic
Easy integration with ProfitView to use this algorithm for automated trading
When you create an alert, and you are using ProfitView, select " alert() function calls only " as the condition option. If you would rather set your own custom alert message, select " Order fills only " instead.
There is a selectable setting in the options to trigger alert() function calls immediately, that you may use to see what text it will send.
EMA Stoch Strategy For ProfitViewThis strategy will enter positions when the set stochastic conditions are met, and uses the moving average to filter the direction of the trades (long/short). The background is used to illustrate the strength of the stochastic values.
The following is a step by step guide in order to automate the trading of the strategy with ProfitView:
In the indicator settings, set the desired stochastic and ema values, and the stochastic condition you want to use to enter a trade.
In the indicator, set which exchange, symbol, and account to execute trades on.
In the indicator, set the PV Alert names you intend to use. If you want to use the same names as provided in the pastebin below, you may set the three names to Market Long, Market Short, TP SL Hit.
In PV, create two new PV Alerts in the PV Alert tab in accordance to these specifics pastebin.com .
On the Tradingview chart you want the indicator run on, create a new TV alert with this script as its condition, and specify the alert to "alert() function calls only".
BEST RSI Divergences Screener (Regular and Hidden)Hello traders
My way to fight this situation is to stay productive.
Hope some of my scripts will help you out as most of us are locked-down at home, hence have more time for trading - and preparing ourselves when the sun will shine on us again
I - Concept
This is an upgrade of this script which captured only the regular divergences
This screener detects whether the regular RSI divergences based on the TradingView Divergence built-in indicator (made by the gentleman @everget I believe)
With this screener, you can see in 1 view which of your favorite cryptos/stocks/forex pairs/etc. showing strong regular and hidden divergences
The gentlemen (and demoiselles) traders can play with the lookback/ranges inputs to adjust the divergences based on what they think is best of their trading/timeframe/instrument/life
On that script screenshot, I'm showing the BYBIT:BTCUSD part of the screener matching with the divergences on the chart
II - How did I set the screener
The visual signals are as follow:
- square: whenever a regular or hidden divergence is detected
Then the colors are:
- green when there is bullish divergence
- red when there is bearish divergence
🔔🔔 I also added the alerts for capturing those bullish/bearish divergences
III - Does it repaint?
It should not :)
Best regards
Dave
BEST Risk to Reward UtilityHello Traders
This is a proof of concept and a cool pinescript utility
It displays a risk to reward division as a fractional value.
For example
Risk: 300
Reward: 600
This will be displayed as 1/2 as we can earn 2 units for a potential loss of 1 unit
(600/300 = 2) for those wondering the NASA level mathematics behind :)
Best regards
Dave
BEST ABCD Pattern StrategyHello traders
This is the strategy version of this script
I - Concept
I present to you, ladies and gentlemen, the first screener for harmonic patterns.
Starting with an ACBD pattern screener this time!!
I used the calculations from Ricardo Santo's script
In short, he's using fractals (regular or Bill Williams ) for the pattern calculations. A masterpiece !!!
II - Definitions
The ABCD pattern ( AB=CD ) is one of the classic chart patterns which is repeated over and over again.
The ABCD pattern shows perfect harmony between price and time.
The Williams Fractal is an indicator, developed by Bill Williams, that aims to detect reversal points (highs and lows) and marks them with arrows.
Up fractals and down fractals have specific shapes. The Williams Fractal indicator helps users determine in which direction price will develop
💎Strategy filters💎
I included some cool backtest filters:
- flexible take profit in USD value (plotted in blue)
- flexible stop loss in USD value (plotted in red)
The take profit and stop loss should work with Forex/FX pairs as well
All the BEST
Dave
BEST Engulfing + Breakout StrategyHello traders
This is a simple algorithm for a Tradingview strategy tracking a convergence of 2 unrelated indicators.
Convergence is the solution to my trading problems.
It's a puzzle with infinite possibilities and only a few working combinations.
Here's one that I like
- Engulfing pattern
- Price vs Moving average for detecting a breakout
Definition
Take out the notebooks :) and some coffee (good for focus). I'm bullish in coffee
The engulfing pattern is a two-candle reversal pattern.
The second candle completely ‘engulfs’ the real body of the first one, without regard to the length of the tail shadows.
The bullish Engulfing pattern appears in a downtrend and is a combination of one red candle followed by a larger green candle
The bearish Engulfing pattern appears in a downtrend and is a combination of one green candle followed by a larger red candle
Example: imgur.com
We're bored sir... what's the point of all this?
In summary, an engulfing is a pattern to track reversals. (the whole TradingView audience stands up now giving a standing ovation)
Adding the Price vs Moving average filters allows to track reversals with momentums (half of the audience collapsed because this is too awesome)
Ok sir... you picked up my interest
I included some cool backtest filters:
- date range filtering
- flexible take profit in USD value (plotted in blue)
- flexible stop loss in USD value (plotted in red)
All the best
Dave
BEST USA Bank Holidays HelperHello traders
This is a quick helper displaying the US bank holidays labels 1 day before the actual bank holiday date
Useful to be reminded when it's better to not trade as the big "whales" aren't trading either - and are probably drinking cocktails on their yachts in the Caribbeans island
This is my way of saying that, the days where the USA are off, the derivatives like indices aren't likely to give big opportunities
Of course, big move might happen but statistically, we're better off going to the Caribbeans islands as well (or preparing for the next trading day)
Bonus
The indicator displays in fuschia (never knew how to write that word properly without checking google first...) the 2019 US bank holidays
Best regards and enjoy your cocktails today :)
Dave
Best Supertrend CCI StrategyHello traders
Someone requested the strategy version of the Supertrend CCI indicator
It's a Supertrend not based on candle close but based on a CCI ( Commodity Channel Index )
How does it work?
Bull event: CCI crossing over the 0 line
Bear event: CCI crossing below the 0 line
When the event is triggered, the script will plot the Supertrend as follow
UP Trend = High + ATR * Factor
DOWN Trend = Low - ATR * Factor
This is an alternative of the classical Supertrend based on candle close being above/beyond the previous Supertrend level.
Hope you'll enjoy it and it will improve your trading making you a better trader
Dave
Best Volatility Calculator (Multi Instruments)Hello traders
A bit of context
Definition: Volatility is defined as the close of current candle - close of the previous N candle
This is an alternative version of my Best Volatility Calculator
The other version is displayed on a panel below. This one overlays on the chart using the "overlay=true" setting
This indicator shows the average volatility, of last N Periods, for the selected time frames and for 2 selected instruments.
You can select up to 2 timeframes with this version
Presented as Currency, Pip, percentage labels in a panel below.
Will calculate in real-time only for the current instrument on the chart.
The indicator is coded to not be repainting
Example
In the indicator screenshot, I used a lookback period of 1.
That compares the current candle close versus the previous one for the daily and weekly timeframe
Showing how the results look like using FOREX instruments (where using the PIPS labels make more sense than with cryptocurrency assets)
Best regards
Dave
Best Ichimoku ScreenerHello traders
Continuing deeper and stronger with the screeners' educational series one more time
I - Concept
This screener detects whether the price goes above, below or stays in between the Ichimoku cloud
II - How did I set the screener
The visual signals are as follow:
- square: Above or Below
Then the colors are:
- green when above the cloud
- red when below the cloud
- orange when in the cloud
Best regards,
Dave
BEST Dollar Cost AverageHello traders
This is an upgraded version of my Dollar Cost Average (Data Window) script
1 - What is Dollar-Cost Averaging ( DCA )?
Dollar-Cost Averaging is a strategy that allows an investor to buy the same dollar amount of investment at regular intervals. The purchases occur regardless of the asset's price.
I hope you're hungry because that one is a biggie and gave me a few headaches. Happy that it's getting out of my way finally and I can offer it
🔸 This indicator will analyze for the defined date range, how a dollar-cost average ( DCA ) method would have performed (green panel) versus investing all the hard earnt money at the beginning (orange panel)
=> green versus orange
2- What's on the menu today?
My indicator works with all asset classes and with the daily/weekly/monthly inputs.
⚠️⚠️⚠️ However, results are only visible on the DAILY timeframe chart
As always, let's review quickly the different fields so that you'll understand how to use it (and I won't get spammed with questions in DM ^^)
🔸 Use current resolution: if checked will use the resolution of the chart
🔸 The timeframe used for DCA: different timeframe to be used if Use current resolution is unchecked
🔸 Amount invested in your local currency: The amount in Fiat money that will be invested at each period selected above
🔸 Starting Date
🔸 Ending Date
🔹 The script screenshot shows a DCA with 100 USD invested daily from 01.01.2017 to 01.28.2020
3- Bonus (DATA WINDOW)
🔸 Please check this screenshot to understand what you're supposed to see: Data window
And a quick video that I did months ago explaining how we can use this data window effectively
4 - Specifications used
I got the idea from this website dcabtc.com and the result shown by this website and my indicator are very interesting in general and for your own trading
The formula used for the DCA calculation is the one from the Investopedia website.
Best regards and best of luck
Dave
BEST ABCD Pattern ScreenerHello ladies and gentlemen traders
Continuing deeper and stronger with the screeners' educational series one more time.
This one is heavy crazy mega cool (pardon my french).
I - Concept
I present to you, ladies and gentlemen, the first screener for harmonic patterns.
Starting with an ACBD pattern screener this time!!
I used the calculations from Ricardo Santo's script
In short, he's using fractals (regular or Bill Williams ) for the pattern calculations. A masterpiece !!!
The screener will show in 1 consolidated chart the ABCD patterns for 5 selected assets. Could be stocks, forex, crypto, whatever you feel like making money with
II - Definitions
The ABCD pattern ( AB=CD ) is one of the classic chart patterns which is repeated over and over again.
The ABCD pattern shows perfect harmony between price and time.
More info here
The Williams Fractal is an indicator, developed by Bill Williams, that aims to detect reversal points (highs and lows) and marks them with arrows.
Up fractals and down fractals have specific shapes. The Williams Fractal indicator helps users determine in which direction price will develop
Source: www.tradingview.com
III - How did I set the screener
The visual signals are as follow:
- square: whenever there is an ABCD pattern detected
Then the colors are:
- green when a bullish pattern is detected
- red when a bearish pattern is detected
🔸 The script screenshot shows two red squares matching two ABCD bearish pattern from the above panel. As the chart is showing APPL, I highlighted where the screener mentioned the fruit stock ( APPLE, pun, bad joke, Dave out...)
🔸 I tried to make it as clear as I could with red arrows
Once again, we pushed together the limits of pine script beyond of what we thought was possible, beyond the realm of this world, reaching finally the dreamt pine script heaven (am I going too far? feel free to tell me)
Best regards,
Dave
BEST Supertrend MAHello traders,
That one is an experiment
I was curious to see what a supertrend based on moving average cross could give
How does it work?
Bull event: fast moving average crossing over the slow moving average
Bear event: fast moving average crossing under the slow moving average
When the event is triggered, the script will plot the Supertrend as follow
UP Trend = ohlc4+ ATR * Factor
DOWN Trend = ohlc4- ATR * Factor
Interesting to see the results given by ohlc4 vs hl2 and hl3
Documentation: www.tradingview.com
This is an alternative of the classical Supertrend based on candle close being above/beyond the previous Supertrend level.
Hope you'll enjoy it and it will improve your trading making you a better trader
Dave
BEST Trend Direction Helper (Strategy Edition)Hello traders
A follower asked me to convert my Trend Direction Helper into a strategy
So blessed this indicator reached the 1400+ likes milestone - I can't believe how many people are trading with it
I based the setup as follow:
- Entries on those green/red labels
- exit whenever a Simple Moving Averages cross in the opposite direction happen
- possibility to filter only Longs/Shorts or both
Also...
The strategy includes the Zig Zag/Pivots high/low and other options from the indicator version. I only added a quick strategy component with a hard exit concept based on SMA cross
All the best fam and... HAPPY NEW YEAR !!!!!!!!!!!
Dave
Customizable Trend Direction (Open-Source)Hello everyone
I received a ton of requests for this script so I decided to share it
I did it for a client who didn't want to pay (you can all blame... or even thank him for this script) in the end and I don't want to sell it on my website.
Not because it's not interesting but because my website will be a place to showcase and rent the Algorithm Builders mostly
What is it about?
Basically, it shows how you could convert a plotshape into a label.new object. Very interesting if you want someday to convert your V3 script into V4
With this script, it shows that you can in V4 ( but couldn't do in V3 ) do the followings :
- change dynamically the size (from tiny to huge) of any object
- change dynamically the text (from whatever to whatever) of any object
Screenshot of the user interface
imgur.com
Other use cases
I did it with the Trend Direction but could work with anything really.
- Any indicator with a visual signal. You can know personalized from a user interface the text, size and also the vertical shift. I didn't do it for that one but label.new takes a (x,y) coordinates so playing with y is fairly easy to achieve a dynamic vertical shift
- Even with this script Plotchar-How-to-draw-external-symbols-on-a-chart/ but would require to be updated with a label.new object and with a shape.none parameter so that we'll only see the icon/symbol displayed
- The colors also can be change dynamically using presets Presets-Selector-FRIDAY-NIGHT-CHALLENGE/ . If you have an indicator showing a BULLISH and a BEARISH signal, then you could, for instance, configure colors presets according to the timeframe of the chart or the indicator input, etc (sky is the limit ^^)
Be sure to hit the thumbs up at it motivates me to research what Pinescript can offer and share with the community
Dave
____________________________________________________________
- I'm an officially approved PineEditor/LUA/MT4 approved mentor on codementor. You can request a coaching with me if you want and I'll teach you how to build kick-ass indicators and strategies
Jump on a 1 to 1 coaching with me
- You can also hire for a custom dev of your indicator/strategy/bot/chrome extension/python