TradeFab

TFi Pivot Reversal V3

The Pivot Reversal Study uses pivot points to create a support and resistance level; based on this levels the script creates virtual stop-market orders to catch the trend if the price is crossing the pivot lines.
A "Pyramiding" input allows to configure up to 3 entries; the script enters an additional position if the price falls by a configurable percentage amount (long), the reverse to short orders.
A configurable profit-target and stop-loss is being used to exit an open position.
An optional Moving Average filter can be used to enable only long or short positions.

The script renders a status box at the last bar, which shows the current position status and result of the built-in trading simulation results.
It shows the following statistic values:
  • current position PnL - also background turns green if position is in profit and red if in loss
  • the percentage distance to the profit-target and stop-loss level
  • the overall number of wins and losses and the win/loss ratio
  • the overall profit and loss amount (assuming a quantity of 1)
  • the net-profit and profit-ratio
For the correct simulation of entry/exit prices, the script contains inputs for a percentage entry and exit slippage.

The study also creates configurable alerts, which follow the exact position of the entry/exit markers. The default alert messages contain trading instruction to execute orders via Alertatron; but the message content can be replaced if configuring the alert in the Tradingview environment.

The script was mainly backtested with crypto-coins, e.g. XBTUSD at 15min timeframe. But the script also works with any other type of security and timeframe.

How to access
This strategy is a "Invite Only" script. You can can subscribe or purchase the strategy; please use the link below or send me a message via Tradingview to obtain access to the strategy and study script.
For enabling the script in your Tradingview chart window, click on "Indicators" and select "Invite-Only Scripts".

Full list of alerts
  • 'Alertatron Exit' ... Exit all open positions.
  • 'Alertatron Enter Long' ... Enter long position, w/o stop-loss being used.
  • 'Alertatron Enter Short' ... Enter short position, w/o stop-loss being used.
  • 'Alertatron Enter Long SL' ... Enter long position, w/ stop-loss being used.
  • 'Alertatron Enter Short SL' ... Enter short position, w/ stop-loss being used.

Full list of parameters
  • "Pivot Left Bars" ... Number of bars on the left of the pivot point - used for pivot /peak detection.
  • "Pivot Right Bars" ... Number of bars on the right of the pivot point - used for pivot /peak detection.
  • "MA Filter Fast" ... Moving Average filter fast period.
  • "MA Filter Slow" ... Moving Average filter slow period.
  • "Profit Target Option" ... Configure the profit-target either as a fix percentage value or an ATR.
  • "Profit Target " ... Fix percentage profit-target.
  • "Profit ATR Period" ... ATR profit-target period.
  • "Profit ATR Factor" ... ATR profit-target factor/multiplier.
  • "Stop Loss Option" ... Configure the stop-loss either as a fix percentage value or disable the stop-loss completely.
  • "Stop Loss " ... Fix percentage stop-loss.
  • "Rebuy Loss " ... Percentage loss of the initial position before script enter a nw position in the same direction.
  • "Pyramiding" ... Maximum number of positions.
  • "Show MA Plots" ... Show/hide Moving average plots.
  • "Slippage Entry " ... Percentage slippage for entering a position.
  • "Slippage Exit " ... Percentage slippage for exiting a position.
  • "Statistic Label" ... Defines the position of the statistic label relatively to the last bar in the chart.
  • "Backtest Start" ... Backtest start time; area outside this timeframe will be grayed out.
  • "Backtest Stop" ... Backtest stop time; area outside this timeframe will be grayed out.
  • "Backtest Mode" ... Closes the currently opened position if chart switches to last bar; please only enable if backtesting, otherwise it leads to unwanted alerts.
Release Notes: V3.12 Changes
  • added option for label for dark color scheme
  • added trailing stop
  • added entry/exit and daily funding fees
  • complete overhaul of statistic label, added balance and ROI

OVERVIEW
The Tradingview Pivot Reversal Study script uses pivot points to create a support and resistance level; based on this levels the script tries to catch the trend if the price is crossing these pivot lines up- or downwards.
2 Moving Averages are used to filter for the overall trend, and only enter positions in direction of the current main-trend.
The “Pyramiding” input allows to configure up to 5 entries; all positions a closed at once if the profit-target or trailing-stop has been reached.

PROFIT-TARGET/TRAILING-STOP
The script is either using a percentage fix profit-target or based on an ATR profit-target, or a trailing-stop to exit a position.

STOP-LOSS
The script allows to configure a percentage stop-loss; alternatively the stop-loss can be disabled completely.

ALERTS
Every position entry and exit triggers a configurable alert, which can be used to automate the trading.
The script provides default alert-message setup to automate trading via Alertatron API. But the message content can be modified if setting up the alerts in the local Tradingview environment.
Full list of alerts:
  • ‘Alertatron Exit’ … Exit all open positions.
  • ‘Alertatron Enter Long’ … Enter long position, w/o stop-loss being used.
  • ‘Alertatron Enter Short’ … Enter short position, w/o stop-loss being used.
  • ‘Alertatron Enter Long SL’ … Enter long position, w/ stop-loss being used.
  • ‘Alertatron Enter Short SL’ … Enter short position, w/ stop-loss being used.
  • ‘Alertatron Enter Long TS’ … Enter long position, w/ trailing-stop being used.
  • ‘Alertatron Enter Short TS’ … Enter short position, w/ trailing-stop being used.

STATISTIC FUNCTIONS
The script has built-in statistics which allow to fully backtest the script.
It calculates the following statistic values and shows them in a statistic label at the last bar:
  • current position(s) PnL – also background turns green if position is in profit, red if in loss and blue if flat
  • current number of open positions and the average entry price
  • the percentage distance to the profit-target, trailing-stop and stop-loss level
  • the overall number of wins and losses and the win/loss ratio
  • the overall profit and loss amount (based on a configurable start budget and position size)
  • the net-profit and profit-ratio
  • the overall fees paid (based on configurable entry/exit/daily funding fee)
  • the balance and ROI
For the correct simulation of entry/exit prices, the script contains inputs for a percentage entry and exit slippage.

Use the link below to obtain access to this indicator.
Release Notes: V3.12 Inputs
  • "Pivot: Left Bars" ... Number of bars on the left of the pivot points – used for pivot/peak detection.
  • "Pivot: Right Bars" ... Number of bars on the right of the pivot points – used for pivot/peak detection.
  • "Filter: MA Fast" ... Moving Average filter fast period.
  • "Filter: MA Slow" ... Moving Average filter slow period.
  • "Filter: Show Plot" ... Enable/disable MA plot visualization in the chart.
  • "Profit Target: Option" ... Configure the profit-target either as a fix percentage value (Fix), a trailing-stop (Trail) or ATR.
  • "Profit Target: Fix/Trail Activation " ... Fix percentage profit-target or trailing-stop activation target.
  • "Profit Target: Trail Offset " ... Trailing-stop offset. It defines the percentage stop-loss distance from the trailing price peak.
  • "Profit Target: ATR Period " ... ATR profit-target period.
  • "Profit Target: ATR Factor " ... ATR profit-target factor/multiplier.
  • "Profit Target: Break-even Period " ... Period after profit-target is set to break-even price to close all open positions asap.
  • "Stop Loss: Option" ... Configure the stop-loss either as a fix percentage value (Fix) or disable the stop-loss completely (Off).
  • "Stop Loss: Fix " ... Fix percentage stop-loss.
  • "Start Balance " ... Start balance used for performance calculations. Any value can be defined, even fractions, e.g. 0.2 BTC.
  • "Position Size " ... Percentage size relative to the current balance of each individual position. The percentage value is not limited, which allows margin trading or leveraging of positions. Without leveraging and Pyramiding set to 5, the position size should be set to 20% to fully use the available balance.
  • "Pyramiding " ... Maximum number of positions in the same trading direction. Minimum is 1, maximum is 5. Default is set to 3.
  • "Rebuy PnL " ... Percentage gain/loss compared to the last position before entering a new position in the same direction. Default is set to 0. If 0, a new position will be entered everytime the entry trigger signals an entry until the maximum number of positions (defined via "Pyramiding") has been reached. If <0, the price relatively to the last entry has to go down (long) and up (short) by a percentage, before a new position will be entered. If >0, the price relatively to the last entry has to go up (long) and down (short) by a percentage, before a new position will be entered.
  • "Entry fee " ... Percentage entry fee relative to the position value, which has to paid for every position entry (positive value => costs, negative value => credit).
  • "Exit Fee " ... Percentage exit fee relative to the position value, which has to paid for every position exit (positive value => costs, negative value => credit).
  • "Daily Funding Fee " ... Percentage funding fee relative to the position value, which has to paid daily (positive value => costs, negative value => credit). If holding a position only for 15mins only the share of the daily value will be applied - in case of 15min = daily value / 96.
  • "Slippage: Entry " ... Percentage slippage for entering a position.
  • "Slippage: Exit " ... Percentage slippage for exiting a position.
  • "Backtest: Start Time" ... Backtest start time; area outside this timeframe will be grayed out.
  • "Backtest: End Time" ... Backtest stop time; area outside this timeframe will be grayed out.
  • "Backtest: Close Last Bar" ... Closes the currently opened position if chart switches to last bar; please enable only if backtesting, otherwise it leads to unwanted alerts.
  • "Statistic Label Position/Theme" ... Defines the position of the statistic label relatively to the last bar in the chart.
Release Notes: V3.15
  • small fix in exit balance calculation (pnlBalance needs to be cached before iterating through positions)
  • added MA filter options
  • bug fix in rebuy handling;
  • separated into Alertatron and Alpaca version

The new MA filter option allows to disable the Moving Average completely. If set to "Level#1" the fast MA has to be above the slow MA to enter a long position (reverse for short). If set to "Level#2", the condition for "Level#1" has to be tru, plus the pro=ice has to be above the slow MA for entering a long position (reverse for short).
Remove from Favorite Scripts Add to Favorite Scripts
Thanks Frank, TradeFab LLC

For purchasing/subscribing scripts: https://tradefab.org/#tradefab_products

Find us @
github.com/TradeFab
twitter.com/TradeFab
tradingview.com/u/TradeFab/

Comments

Thanks for the update Frank. Like the option to disable MA filters and the two level option for MA filters.
Reply
Looks good, Frank! I like the improvement to label function for dark background and the added stats. Trailing stop is a great add-on as are the Alertatron messages.
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out