AIR Supertrend (Average Interpercentile Range)Supertrend (ST) is a popular stop loss and trend identification script. The simplicity of seeing a clean trend on a chart makes it attractive, yet it is restricted by only allowing the source, length and multiplier to be adjusted, & these tend to have a limited effect on the properties of the identified trend.
There is a wide variety of interesting ST scripts on TradingView that give the user more control, but none to my knowledge, based on measuring the statistical dispersion of Average Interpercentile Range (AIR).
Two more levels of control:
Normally, ATR Average True Range is used to calculate the range in ST. ATR is initially calculated using RMA to smooth out True Range. This script gives the user the option of changing the MA to some more interesting varieties & modifying their parameters.
The default range setting when you load the indicator on a chart will be AIR.
The real strength of the indicator, however, and the reason I am publishing it, is to release AIR. Play round with the percentile range setting. Lowering it will allow you to stay longer in a trade in a volatile market. Raising it will make it tighter.
For comparison, you can switch back the range setting to ATR and load up RMA to see how the original, classic ST plots.
Alerts are included in this version. Alway use a stop loss.
DISCLAIMER: None of this is financial advice.
Credits to these authors, whose hard work inspired parts of this script:
@ KivancOzbilgic - SuperTrend
@ KioseffTrading - Tillson T3 MA
@ cheatcountry - Hann Window Smoothing
@ mutantdog - Interquartile Range function in his 'Blaze' script
Limit
Limit Order + ATR Stop-Loss [TANHEF]This indicator enables interactive placement of limit or stop-limit orders with a trailing ATR stop-loss and optional profit target (with alerts). Refer to the images below for further clarification.
Why use a trailing stop-loss?
A trailing stop-loss serves as an exit strategy when price moves against you, while also allowing you to adjust the exit point further into profit when price moves favorably. The ATR (Average True Range), a reliable measure of volatility, acts as an effective risk management tool, functioning as a trailing stop-loss.
Indicator Explanation
Initial indicator placement: Select Long Limit or Long-Stop Limit order.
Change Entry Type: Switch between Long and Short within settings.
Modify entry price: Drag circle, adjust in settings, or re-add indicator to chart.
Optional Profit Target: Use Risk/Reward ratio or specify price.
Entry anticipation: Estimated ATR stop-loss and profit target as blue circles (fluctuates with volatility changes).
Entry triggered: Actual ATR stop-loss and profit target plotted.
Exit conditions: Stop-loss or profit target hit, exit entry.
Update Frequency: Continuously, Bar Open, or Bar Open on entry then continuously.
ATR Overlap: no entry occurs if the ATR overlaps with price (stop-loss 'hit' already on entry bar)
Table: Displays input settings selected.
Show Only On Ticker: Ability to hide indicator on other tickers.
Long Limit
Long Stop-Limit
Short Limit
Short Stop-Limit
Alerts
1. 'Check' alerts to use within indicator settings (entry, trailing stop hit, profit target hit, and failed entry).
2. Select 'Create Alert'
3. Set the condition to 'Limit Order + ATR Stop-Loss''
4. Select create.
Additional details can be added to the alert message using these words in between Curly (Brace) Brackets:
{{trail}} = ATR trailing stop-loss (price)
{{target}} = Price target (price)
{{type}} = Long or Short stop-loss (word)
{{traildistance}} = Trailing Distance (%)
{{targetdistance}} = Target Distance (%)
{{starttime}} = Start time of position (day:hr:min)
{{maxdrawdown}} = max loss
{{maxprofit}} = max profit
{{update}} = stoploss update frequency
{{entrysource}} = entry as 1st bar source (yes/no)
{{triggerentry}} = Wick/Close Trigger entry input
{{triggerexit}} = Wick/Close Trigger exit input
{{triggertarget}} = Wick/Close Trigger target input
{{atrlength}} = ATR length input
{{atrmultiplier}} = ATR multiplier input
{{atrtype}} = ATR type input
{{ticker}} = Ticker of chart (word)
{{exchange}} = Exchange of chart (word)
{{description}} = Description of ticker (words)
{{close}} = Bar close (price)
{{open}} = Bar open (price)
{{high}} = Bar high (price)
{{low}} = Bar low (price)
{{hl2}} = Bar HL2 (price)
{{volume}} = Bar volume (value)
{{time}} = Current time (day:hr:min)
{{interval}} = Chart timeframe
{{newline}} = New line for text
Will my limit order be filled ?Hi
This is a small script that tries to assess the probability that a limit order sent at x % from the last close will be filled in the next y bars.
It is based on historical data and can be useful to decide where to place your limit orders and to determine how far from the price you can put the limit order to get an X% chance of getting filled.
It displays this result for both long and short entries and you can specify if you want to fill orders with wicks or not.
How To Limit Repeating SignalsAn example of how to limit the input number of allowed signals using a function containing a condition counter with a reset.
Bollinger Band strategy with split, limit, stopEntering a short position after breaking the upper Bollinger Band, entering a long position when entering after breaking the lower Bollinger Band
Provides templates for how to display position average price, stop loss, and profit price using the plot function on the chart, and how to buy splits
After entering the position, if the price crosses the mid-band line, the stop loss is adjusted to the mid-band line.
Binance_Min_Limit_Order_amount_libraryLibrary "Binance_Min_Limit_Order_amount_library"
TODO: This library give us the minimum Limit Order amount for the contract in Binance.
m_qty(n_v, m_fee, t_fee, cost, m_t)
TODO: it give us the Minimum Qty for the trading in Binance
Parameters:
n_v : TODO: min_notional_value. 5 dollar is the minimum notional amount in Binance at the moment.
m_fee : TODO: maker_fee %
t_fee : TODO: taker_fee %
cost : TODO: your investing money
m_t : TODO: if you want Limit_Order, put the "T", if you want Market_Order, put the "M" defval="M"
Returns: TODO: for the coin of binance on your chart,
Reference: www.binance.com
U.S. Futures Price LimitsThis scripts plots settlement and the circuit breaker limits for U.S. Equity Indexes. The current limits for the equity index futures are + and - 7%, 13%, and 20% from the previous day's settlement price. If price reaches these levels trading is either paused briefly or for the remainder of the day. The full resource (CME Website) is below.
There are plans to add the remainder of the most actively traded U.S. Futures Markets.
To find out more about the price limits it is best to use the CME's website as a reference.
www.cmegroup.com
BollingerBands Strat + pending order alerts via TradingConnectorSoftware part of algotrading is simpler than you think. TradingView is a great place to do this actually. To present it, I'm publishing each of the default strategies you can find in Pinescript editor's "built-in" list with slight modification - I'm only adding 2 lines of code, which will trigger alerts, ready to be forwarded to your broker via TradingConnector and instantly executed there. Alerts added in this script: 14, 17, 20 and 23.
SCRIPT INCLUDES PENDING ORDERS AND ALERTS! Alert will be sent to MetaTrader when order is triggered, but not yet filled. That means if market conditions change and order does not get filled, it needs to be cancelled as well, and there are alerts for that in the script as well.
How it works:
1. TradingView alert fires.
2. TradingConnector catches it and forwards to MetaTrader4/5 you got from your broker.
3. Trade gets executed inside MetaTrader within 1 second of fired alert.
When configuring alert, make sure to select "alert() function calls only" in CreateAlert popup. One alert per ticker is required.
Adding stop-loss, take-profit, trailing-stop, break-even or executing pending orders is also possible. These topics have been covered in other example posts.
This routing works for Forex, indices, stocks, crypto - anything your broker offers via their MetaTrader4 or 5.
Disclaimer: This concept is presented for educational purposes only. Profitable results of trading this strategy are not guaranteed even if the backtest suggests so. By no means this post can be considered a trading advice. You trade at your own risk.
If you are thinking to execute this particular strategy, make sure to find the instrument, settings and timeframe which you like most. You can do this by your own research only.
Local LimitsDisplays recent higher highs, lower highs, lower lows, and higher lows as a collection of local limit indicators.
In its simplicity is a lot more powerful than might appear at first glance.
Does not rely on volatility calculation.
Can be linked together to create an objective view of recent support and resistance levels.
Makes current trends more visible.
Excellent for use as a trailing stop algorithm.
Parameters
Single Bar Sensitivity: True (default) reacts to individual bars. False only responds to the alignment of 2 bars.
Margin (1-5): Adds extra distance from higher lows and lower highs to reduce the sensitivity of broken trends.
Single indicators with configurable sources:
Local Limit Higher
Local Limit Lower
Local Limit UpperDisplays recent higher and lower highs.
In it's simplicity is a lot more powerful than might appear at first glance.
Does not rely on volatility calculation.
Can be linked together to create an objective view of recent resistance levels.
Makes current trends more visible.
Excellent as a trailing stop (short) algorithm.
Can be used with its sibling: Local Limit Lower
Local Limit LowerDisplays recent higher and lower lows.
In it's simplicity is a lot more powerful than might appear at first glance.
Does not rely on volatility calculation.
Can be linked together to create an objective view of recent support levels.
Makes current trends more visible.
Excellent as a trailing stop algorithm.
Can be used with its sibling: Local Limit Upper
Automated - Fibs with Limit only ordersAutomated - Fibs with Limit only orders
This script was designed to demonstrate how you can use a single alert to move your limit orders around.
It is not meant to be traded live and has been built to work with Binance Futures Testnet.
You will notice a lot of plots with 5 different titles.
New = Place your limit buy at a fixed-price.
Move = Cancel the current limit buy and place it at the new fixed-price.
Filled = Cancel any limit closes and places them anew based on the new average and take profit.
Cancel = Cancels exisiting limit buys.
Cloes All = Limit close filled, no commands necessary.
The default quantity in the command is the minimum order size on Binance.
Settings
Live
- If enabled it will only place trades after the "Stat Timestamp + Start Delay" that you provide.
Start Timestamp
- Use something similar to epochconverter to get the current timestamp.
Start Delay
- Gives you 1 minute by default to start the script and create your alert before it begins looking for a new entry.
Leverage
- Default 1. Affects the "Take Profit and DCA When" Settings.
Take Profit %
- This is the percentage above the current average you'd like to place your position close at.
DCA When %
- The percentage below your last entry that you're willing to buy again.
Note: This strategy has no stop-loss and pyramiding is enabled. It is not built for, or recommended to run live.
I hope this opens some doors and helps advance your personal trading system.
Good luck and happy scripting!
Strategy Code Example 2 - Time Limiting*** THIS IS JUST AN EXAMPLE OF STRATEGY TIME LIMITING CODE IMPLEMENTATION ***
This is a follow up to my example for risk management implementation here:
Code remains mostly unchanged, but now includes a time limiting implementation.
Relevant code blocks for the time factor are preceded with a comment stating:
*** FOCUS OF EXAMPLE ***
Cheers!