Fibonacci-Only StrategyFibonacci-Only Strategy
This script is a custom trading strategy designed for traders who leverage Fibonacci retracement levels to identify potential trade entries and exits. The strategy is versatile, allowing users to trade across multiple timeframes, with built-in options for dynamic stop loss, trailing stops, and take profit levels.
Key Features:
Custom Fibonacci Levels:
This strategy calculates three specific Fibonacci retracement levels: 19%, 82.56%, and the reverse 19% level. These levels are used to identify potential areas of support and resistance where price reversals or breaks might occur.
The Fibonacci levels are calculated based on the highest and lowest prices within a 100-bar period, making them dynamic and responsive to recent market conditions.
Dynamic Entry Conditions:
Touch Entry: The script enters long or short positions when the price touches specific Fibonacci levels and confirms the move with a bullish (for long) or bearish (for short) candle.
Break Entry (Optional): If the "Use Break Strategy" option is enabled, the script can also enter positions when the price breaks through Fibonacci levels, providing more aggressive entry opportunities.
Stop Loss Management:
The script offers flexible stop loss settings. Users can choose between a fixed percentage stop loss or an ATR-based stop loss, which adjusts based on market volatility.
The ATR (Average True Range) stop loss is multiplied by a user-defined factor, allowing for tailored risk management based on market conditions.
Trailing Stop Mechanism:
The script includes an optional trailing stop feature, which adjusts the stop loss level as the market moves in favor of the trade. This helps lock in profits while allowing the trade to run if the trend continues.
The trailing stop is calculated as a percentage of the difference between the entry price and the current market price.
Multiple Take Profit Levels:
The strategy calculates seven take profit levels, each at incremental percentages above (for long trades) or below (for short trades) the entry price. This allows for gradual profit-taking as the market moves in the trade's favor.
Each take profit level can be customized in terms of the percentage of the position to be closed, providing precise control over exit strategies.
Strategy Backtesting and Results:
Realistic Backtesting:
The script has been backtested with realistic account sizes, commission rates, and slippage settings to ensure that the results are applicable to actual trading scenarios.
The backtesting covers various timeframes and markets to ensure the strategy's robustness across different trading environments.
Default Settings:
The script is published with default settings that have been optimized for general use. These settings include a 15-minute timeframe, a 1.0% stop loss, a 2.0 ATR multiplier for stop loss, and a 1.5% trailing stop.
Users can adjust these settings to better fit their specific trading style or the market they are trading.
How It Works:
Long Entry Conditions:
The strategy enters a long position when the price touches the 19% Fibonacci level (from high to low) or the reverse 19% level (from low to high) and confirms the move with a bullish candle.
If the "Use Break Strategy" option is enabled, the script will also enter a long position when the price breaks below the 19% Fibonacci level and then moves back up, confirming the break with a bullish candle.
Short Entry Conditions:
The strategy enters a short position when the price touches the 82.56% Fibonacci level and confirms the move with a bearish candle.
If the "Use Break Strategy" option is enabled, the script will also enter a short position when the price breaks above the 82.56% Fibonacci level and then moves back down, confirming the break with a bearish candle.
Stop Loss and Take Profit Logic:
The stop loss for each trade is calculated based on the selected method (fixed percentage or ATR-based). The strategy then manages the trade by either trailing the stop or taking profit at predefined levels.
The take profit levels are set at increments of 0.5% above or below the entry price, depending on whether the position is long or short. The script gradually exits the trade as these levels are hit, securing profits while minimizing risk.
Usage:
For Fibonacci Traders:
This script is ideal for traders who rely on Fibonacci retracement levels to find potential trade entries and exits. The script automates the process, allowing traders to focus on market analysis and decision-making.
For Trend and Swing Traders:
The strategy's flexibility in handling both touch and break entries makes it suitable for trend-following and swing trading strategies. The multiple take profit levels allow traders to capture profits in trending markets while managing risk.
Important Notes:
Originality: This script uniquely combines Fibonacci retracement levels with dynamic stop loss management and multiple take profit levels. It is not just a combination of existing indicators but a thoughtful integration designed to enhance trading performance.
Disclaimer: Trading involves risk, and it is crucial to test this script in a demo account or through backtesting before applying it to live trading. Users should ensure that the settings align with their individual risk tolerance and trading strategy.
Breakout-strategy
RSI Box Strategy (pseudo- Grid Bot)This is a strategy intended primarily for algorithmic traders. It's a pseudo-grid bot that uses a dynamic, volume-weighted grid that only updates when the RSI meets certain conditions. It's also a breakout strategy, whereas normal grid bots are not (typical grid bots sell when a higher grid is reached, whereas this strategy sells when a lower grid is breached under specific conditions). This strategy also sells 100% of pyramiding orders on close.
In a nutshell, the strategy updates its grid to the volume-weighted highest/lowest values of your given source ("src" in the settings) each time that there is a RSI crossunder/crossover. From this range it produces an evenly-spaced grid of five lines, and uses the current source to determine which grid line is closest to the source. Then, if the source crosses over the line directly above the current line, it enters a buy order. If the source crosses under the line directly below the current line, it enters a sell order.
You can configure shorts, source, RSI length, and overbought/oversold levels in the settings.
For the strategy results below: fees are at 0.1% per trade, with order size 1% of equity and a max pyramiding value of 33. For a greater R/R profile, you can increase the order size, which will increase drawdown but potentially yield better results.
Bollinger Bands - Breakout StrategyThe Bollinger Bands - Breakout Strategy is a trend-following optimized for short-term trading in the crypto market. This strategy employs the Bollinger Bands, a widely recognized technical indicator, as its primary instrument for pinpointing potential trades. It is capable of executing both long and short positions, depending on whether the market is in a spot or futures, and is particularly effective in trending markets.
The strategy boasts a high degree of configurability, allowing users to set the Bollinger Bands period and deviation, trend filter, volatility filter, trade direction filter, rate of change filter, and date filter. Furthermore, it offers options for Take Profit, Stop Loss, and Trailing Stop for both long and short positions, ensuring a comprehensive risk management approach. The inclusion of a maximum intraday loss feature adds another layer of protection, making this strategy a valuable tool for traders seeking a professional and adaptable trading system.
Name : Bollinger Bands - Breakout Strategy
Category : Trend Follower based on Bollinger Bands
Operating mode : Long and Short on Futures or Long on Spot
Trade duration : Intraday
Timeframe : 2H, 3H, 4H, 5H
Market : Crypto
Suggested usage : Trending Markets
Entry : When the price crosses above or below the Bollinger Bands
Exit : Opposite Cross or Profit target, Trailing stop or Stop loss
Configuration :
- Bollinger Bands period and deviation
- Trend Filter
- Volatility Filter
- Trade direction filter
- Rate of Change filter
- Date Filter (for backtesting purposes)
- Take Profit, Stop Loss and Trailing Stop for long and short positions
- Risk Management: Max Intraday Loss
Backtesting :
⁃ Exchange: BINANCE
⁃ Pair: BTCUSDT.P
⁃ Timeframe: 4H
⁃ Fee: 0.025%
⁃ Slippage: 1
- Initial Capital: 10000 USDT
- Position sizing: 10% of Equity
- Start : 2019-09-19 (Out Of Sample from 2022-12-23)
- Bar magnifier: on
Credits :
- LucF of Pine Coders for f_security function to avoid repainting using security.
- QuantNomad for Monthly Table.
Disclaimer : Risk Management is crucial, so adjust stop loss to your comfort level. A tight stop loss can help minimise potential losses. Use at your own risk.
How you or we can improve? Source code is open so share your ideas!
Leave a comment and smash the boost button!
Thanks for your attention, happy to support the TradingView community.
[-_-] Level Breakout, Auto Backtesting StrategyDescription:
A Long only strategy based on breakout from a certain level formed by High price. It has auto-backtesting capabilities (you set ranges for the three main parameters: Lookback, TP and SL; the strategy then goes through different combinations of those parameters and displays a table with results that you can sort by Percentage of profitable trades AND/OR Net profit AND/OR Number of trades). So you can, for example, sort only by Net profit to find combination of parameters that gives highest net profit, or sort by Net profit and Percentage profitable to find a combination of parameters that gives the best balance between profitability and profit. The auto-backtesting also takes into account the commission which is set in % in the inputs (make sure to set the same value in properties of the strategy so that auto-backtesting and real backtesting results match).
NOTE: auto-backtesting only find the best combinations and displays them in a table, you will then need to manually set the Lookback, TP and SL inputs for real backtesting to match.
Parameters:
- Lookback -> # of bars for filtering signals; recommended range from 2 to 5
- TP (%) -> take profit; recommended range from 5 to 10
- SL (%) -> stop loss; recommended range from 1 to 5
- Commission (%) -> commission per trade
- Min/Max Lookback -> lookback range for auto-backtesting
- Min/Max TP -> take profit range for auto-backtesting
- Min/Max SL -> stop loss range for auto-backtesting
- Percentage profitable -> sort by percentage of profitable trades
- Net profit -> sort by net profit
- Number of trades -> sort by number of trades
Inside Bar SetupScript Details
- This script plots Inside Bar for given day in selected time-frame (applicable only for Timeframes < Day)
- Basis plotted inside bar, relevant targets are marked on the chart
- Targets can be customised from script settings. Example, if range of mother candle is 10 points, then T1 is 10 * x above/below mother candle and T2 is 10 * y above/below mother candle. This x & y are configured via script settings
How to use this script ?
- This script works well on 10-15 mins timeframe for stocks, 15/30 mins timeframe for nifty index and 30/60 mins time frame for bank nifty index
- If mother candle high is broken, take long trade with SL of mother candle low and if low is broken, take short trade with SL of mother candle high
Remember:
1. Above logic is to be combined with support/resistances i.e. price action. This script is an add-on to price action analysis giving you more conviction.
2. If range of mother candle is very high, it is recommended to avoid the trade.
3. Basis inside bar formed on higher time frame, take trade on basis of lower time frame i.e if inside bar is formed on 60 mins, take trade on the basis of 10-15 mins time frame
Example:
1. As seen in the chart, Nifty is near it's resistance and we are seeing Inside Bar being formed, In such scenario, even if High of Mother Candle is broken, we should be more interested to short as we are near resistance and probability of getting our targets in long side is less.
2. So, if I see breakdown of mother candle i.e. price going below low of mother candle, we will short with SL of high of mother candle.
3. As seen in the chart, both the targets are achieved.
Additional Info:
1. Targets on Long/Short Side can be configured via settings. For indices 1 times/1.5 times the range works well.
2. This script plots targets basis the first inside bar formed in the day for selected time frame.
3. Inside bars formed through out the day are coloured separately but lines are plotted only on the basis of 1st formed inside bar as this strategy works well for the first formed inside bar)
4. Don't forget to check volume in case of breakout/breakdown.
Note:
1. Mother Candle - First Candle of Inside Bar
2. Child Candle - Candle formed inside Mother Candle (Second Candle of Inside Bar)
Happy Trading :)
Volatility Breakout StrategyThis is a strategy used by Larry R. Williams called Volatility Breakout.
By identifying a strong uptrend that exceeds 'a certain level' on a daily basis as a breakout signal, enter long position, take advantage of long at the the next day's open.
'a certain level (Entry Price)' is calculated by { close + 'k' * high -low }, and applied logarithmic calculation.
Stop loss level is calculated by half of the previous day's Low and Entry Price.
Strategy exit always at UTC+0.
And expressed day session with the background color.
Thanks and hope this helps you.
(kor)
이건 Larry R. Williams가 사용하는 변동성 돌파 전략입니다.
특정 수준을 넘는 강한 상승세를 돌파 신호로 파악하여 매수하고, 장시간이 종료될때에 빠르게 수익을 실현하는 전략입니다.
"특정 레벨(진입가)"은 close + 'k' * high -low 로 계산되며 로그 계산을 적용했습니다.
손절 레벨은 전일 저가 및 진입 가격의 절반으로 계산됩니다.
전략은 항상 UTC+0에서 종료합니다. ( 한국 기준 오전 9시 )
그리고 배경색으로 일일세션을 표현했습니다.
트뷰에 오픈소스의 래리윌리엄스 변동성전략이 없는것 같아 간단하게나마 만들어 보았습니다. 도움이 되었으면 좋겟워요..
72s Strat: Backtesting Adaptive HMA+ pt.1This is a follow up to my previous publication of Adaptive HMA+ few months ago, as a mean to provide some kind of initial backtesting tools. Which can be use to explore many possible strategies, optimise its settings to better conform user's pair/tf, and hopefully able to help tweaking your general strategy.
If you haven't read the study or use the indicator, kindly go here first to get the overall idea.
The first strategy introduce in this backtest is one most basic already described in the study; buy/sell is when movement is there and everything is on the right side; When RSI has turned to other side, we can use it as exit point (if in profit of course, else just let it hit our TP/SL, why would we exit before profit). Also, base on RSI when we make entry, we can further differentiate type of signals. --Please check all comments in code directly where the signals , entries , and exits section are.
Second additional strategy to check; is when we also use second faster Adaptive HMA+ for exit. So this is like a double orders on a signal but with different exit-rule (/more on this on snapshots below). Alternatively, you can also work the code so to only use this type of exit.
There's also an additional feature which you can enable its visuals, the Distance Zone , is to help measuring price distance to our xHMA+. It's just a simple atr based envelope really, I already put the sample code in study's comment section, but better gonna update it there directly for non-coder too, after this.
In this sample I use Lot for order quantity size just because that's what I use on my broker. Also what few friends use while we forward-testing it since the study is published, so we also checked/compared each profit/loss report by real number. To use default or other unit of measurement, change the entry code accordingly.
If you change your order size, you should also change the commission in Properties Tab. My broker commission is 5 USD per order/lot, so in there with example order size 0.1 lot I put commission 0.5$ per order (I'll put 2.5$ for 0.5 lot, 10$ for 2 lot, and so on). Crypto usually has higher charge. --It is important that you should fill it base on your broker.
SETTINGS
I'm trying to keep it short. Please explore it further again. (Beginner should also first get acquaintance with terms use here.)
ORDERS:
Base Minimum Profit Before Exit:
The number is multiplier of ongoing ATR. Means that when basic exit condition is met, algo will check whether you're already in minimum profit or not, if not, let it still run to TP or SL, or until it meets subsequent exit condition, then it will check again.
Default Target Profit:
Multiplier of ATR at signal. If reached before any eligible exit condition is met, exit TP.
Base StopLoss Point:
You can change directly in code to use other like ATR Trailing SL, fix percent SL, or whatever. In the sample, 4 options provided.
Maximum StopLoss:
This is like a safety-net, that if at some point your chosen SL point from input above happens to be exceeding this maximum input that you can tolerate, then this max point is the one will be use as SL.
Activate 2nd order...:
The additional doubling of certain buy/sell with different exits as described above. If enable, you should also set pyramiding to at least: 2. If not, it does nothing.
ADAPTIVE HMA+ PERIOD
Many users already have their own settings for these. So in here I only sample the default as first presented in the study. Make it to your adaptive.
MARKET MOVEMENT
(1) Now you can check in realtime how much slope degree is best to define your specific pair/tf is out of congestion (yellow) area. And (2) also able to check directly what ATR lengths are more suitable defining your pair's volatility.
DISTANCE ZONE
Distance Multiplier. Each pair/tf has its own best distance zone (in xHMA+ perspective). The zone also determine whether a signal should appear or not. (Or what type of signal, if you wanna go more detail in constructing your strategy)
USAGE
(Provided you already have your own comfortable settings for minimum-maximum period of Adaptive HMA+. Best if you already have backtested it manually too and/or apply as an add-on to your working strategy)
1. In our experiences, first most important to define is both elements in the Market Movement Settings . These also tend to be persistent for whole season since it's kinda describing that pair/tf overall behaviour. Don't worry if you still get a low Profit Factor here, but by tweaking you should start to see positive changes in one of Max Drawdown and Net Profit, or Percent Profitable.
2. Afterwards, find your pair/tf Distance Zone . When optimising this, what we seek is just a "not to bad" equity curves to start forming. At least Max Drawdown should lessen more. Doesn't have to be great already, but should be better, no red in Net Profit.
3. Then go manage the "Trailing Minimum Profit", TP, SL, and max SL.
4. Repeat 1,2,3. 👻
5. Manage order size, commission, and/or enable double-order (need pyramiding) if you like. Check if your equity can handle max drawdown before margin call.
6. After getting an acceptable backtest result, go to List of Trades tab and find the biggest loss or when many sequencing loss in a row happened. Click on it to go to exact point on chart, observe why the signal failed and get at least general idea how it can be prevented . The rest is yours, you should know your pair/tf more than other.
You can also re-explore your minimum-maximum period for both Major and minor xHMA+.
Keep in mind that all numbers in Setting are conceptually in a form of range . You don't want to get superb equity curves but actually a "fragile" , means one can easily turn it to disaster just by changing only a fraction in one/two of the setting.
---
If you just wanna test the strength of the indicator alone, you can disable "Use StopLoss" temporarily while optimising settings.
Using no SL might be tempting in overall result data in some cases, but NOTE: It is not recommended to not using SL, don't forget that we deliberately enter when it's in high volatility. If want to add flexibility or trading for long-term, just maximise your SL. ie.: chose SL Point>ATR only and set it maximum. (Check your max drawdown after this).
I think this is quite important specially for beginners, so here's an example; Hypothetically in below scenario, because of some settings, the buy order after the loss sell signal didn't appear. Let's say if our initial capital only 1000$ using leverage and order size 0,5 lot (risky position sizing already), moreover if this happens at the beginning of your trading season, that's half of account gone already in one trade . Your max SL should've made you exit after that pumping bar.
The Trailing Minimum Profit is actually look like this. Search in the code if you want to plot it. I just don't like too many lines on chart.
To maximise profit we can try enabling double-order. The only added rule coded is: RSI should rising when buy and falling when sell. 2nd signal will appears above or below default buy/sell signal. (Of course it's also prone to double-loss, re-check your max drawdown after. Profit factor play its part in here for a long run). Snapshot in comparison:
Two default sell signals on left closed at RSI exit, the additional sell signal closed later on when price crossover minor xHMA+. On buy side, price haven't met our minimum profit when first crossunder minor xHMA+. If later on we hit SL on this "+buy" signal, at least we already profited from default buy signal. You can also consider/treat this as multiple TP points.
For longer-term trading, what you need to maximise is the Minimum Profit , so it won't exit whenever an exit condition happened, it can happen several times before reaching minimum profit. Hopefully this snapshot can explain:
Notice in comparison default sell and buy signal now close in average after 3 days. What's best is when we also have confirmation from higher TF. It's like targeting higher TF by entering from smaller TF.
As also mention in the study, we can still experiment via original HMA by putting same value for minimum-maximum period setting. This is experimental EU 1H with Major xHMA+: 144-144, Flat market 13, Distance multiplier 3.6, with 2nd order activated.
Kiwi was a bit surprising for me. It's flat market is effectively below 6, with quite far distance zone of 3.5. Probably because I'm using big numbers in adaptive period.
---
The result you see in strategy tester report below for EURUSD 15m is using just default settings you see in code, as follow:
0,1 lot for each order (which is the smallest allowed by my broker).
No pyramiding. Commission: 0.5 usd per order. Slippage: 3
Opening position is only using basic strategy #1 (RSI exit). Additional exit not activated.
Minimum Profit: 1. TP: 3.
SL use: Half-distance zone. Max SL: 4.5.
Major xHMA+: 172-233. minor xHMA+: 89-121
Distance Zone Multiplier: 2.7
RSI: Standard 14.
(From our forward-testing, the difference we get from net profit is because of the spread, our entry isn't exactly at the close/open price. Not so much though, but not the same. If somebody can direct me to any example where we can code our entry via current bid/ask price, that would be awesome!)
It's already a long post (sorry), think I'm gonna pause here. Check out the code :)
---
DISCLAIMER: Past performance is no guarantee of future results , and so on.. you know the drill ;)
Please read whole description first before using, don't take 1-2 paragraph and claim it's the whole logic, you are responsible of your own actions and understanding.
Anti-Breakout StrategyAnti-Breakout Strategy
Description:
This is a contrarian entry strategy for trading false breakouts. The high/low of the breakout bar is used for the entry in the opposite direction.
To reduce repainting set ptype variable to OHL3.
Fractal Breakout StrategyFractal
A type of pattern used in technical analysis to predict a reversal in the current trend. A fractal pattern consists of five bars and is identified when the price meets the following characteristics:
1. A shift from a downtrend to an uptrend occurs when the lowest bar is located in the middle of the pattern and two bars with successively higher lows are positioned around it.
2. A shift from an uptrend to a downtrend occurs when the highest bar is located in the middle of the pattern and two bars with successively lower highs are positioned around it.
Fractal Breakout Strategy (by ChartArt)This long only strategy determines the price of the last fractal top and enters a trade when the price breaks above the last fractal top. The strategy also calculates the average price of the last fractal tops to get the trend direction. The strategy exits the long trade, when the average of the fractal tops is falling (when the trend is lower highs as measured by fractals). And the user can manually set a time delay of this exit condition. The default setting is a long strategy exit always 3 bars after the long entry condition appeared.
In addition as gimmicks the fractals tops can be highlighted (the default is blue) and a line can be drawn based on the fractal tops.This fractal top line is colored by the fractal top average trend in combination with the fractal breakout condition.
This strategy works better on higher time-frames (weekly and monthly), but it also works on the daily and some other time-frames. This strategy does not repaint, no repainting.
P.S. I thank Tradingview user barracuda who helped me with the time based exit condition code. And user RicardoSantos for coding the definition of the fractal top, which he uses in his " Fractals" scripts.
All trading involves high risk; past performance is not necessarily indicative of future results. Hypothetical or simulated performance results have certain inherent limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not actually been executed, the results may have under- or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown.
CamarillaStrategy -V1 - H4 and L4 breakout - exits addedExits added using trailing stops.
2.6 Profit Factor and 76% Profitable on SPY , 5M - I think it's a pretty good number for an automated strategy that uses Pivots. I don't think it's possible to add volume and day open price in relation to pivot levels -- that's what I do manually ..
Still trying to add EMA for exits.. it will increase profitability. You can play in pinescript with trailing stops entries..