Trend Analysis
Silver Long/Short Combines Gold and Silver price ratio with SMA trend indicators for buy and sell signals.
Slow Heiken Ashi and Exponential Moving average Strategy 2.2Strategy using Slow Heiken Ashi by Glaz and Exponential moving averages. Looking for someone to help me turn the strategy into non-reoccuring alerts as I am having trouble doing so.
Strategy Test - Cancel Limit Order and Position SizingWhile working thru another project had the need to troubleshoot the canceling of a limit order syntax/process as well as work thru the code and logic to automagically set the position sizing based off two user inputs (Amount to Risk in USD and Leverage to Use) and the potential entry and stop levels for an inside bar candle pattern in this scenario. Once we find the distance between the entry and stop level we can figure out the stop percentage amount which matches up with what a user would see manually drawing using the long or short tool in tradingview. Once we have the user inputs and levels we can get an amount to be used in later qty= type of places in zeeee pine script....
N Bars Down Backtest Evaluates for n number of consecutive lower closes. Returns a value
of 1 when the condition is true or 0 when false.
WARNING:
- For purpose educate only
- This script to change bars colors.
N Bars Up Backtest Evaluates for n number of consecutive higher closes. Returns a value
of 1 when the condition is true or 0 when false.
WARNING:
- For purpose educate only
- This script to change bars colors.
HA smoothed eliminator v2 This script is published to show the difference between Heiken ASHI and Japanese candlesticks. I do not recommend using it in trading. the indicator is taken from here
[fikira] Fibma/Fibema StrategyMy strategy regarding the Fibma/Fibema lines (also see my Fibma/Fibema study)
You can enable/disable each strategy to see what
works best in what timeframe
Thanks!
Noro's BottomSensivity v0.6 strategy + rsi + AlarmThe original indicator is Noro's BottomSensivity v0.6
I simply turned noro's bottom sensibility 6.0 indicator, which I consider a great tool to find market bottom, into a strategy.
I also added an additional RSI filter with inputs that can be set by the user for entry and exit from the market.
I have tried to insert an alarm so that I can be notified when this particular purchase condition is formed.
I also tried to insert an additional filter that would allow me to make further pyramid purchases only after a certain percentage of drawdown from the first entry so as to reduce the average purchase price but I was not able ... if someone could implement this I would appreciate it.
Well..this is the first time that I try to program / modify a strategy / indicator, there are certainly some gross errors (as in my English too), please forgive me, I will appreciate the corrections that more experienced users will want to make.
I wish you all a good day, pfjons
Darvas Box Strategy V2What Is the Darvas Box?
The Darvas Box strategy was developed by Nicholas Darvas. Aside from being a well known dancer, he began trading stock in the 1950s. Based on his success in trading, he was approached to write a book on his strategy. The book, “How I Made $2,000,000 in the Stock Market,” outlines his rather simple approach … simple once you understand the basic concepts and rationale of the strategy.
Darvas originally started with $10,000. He was willing to plunk the whole amount into one stock. This is because he always used a stop loss to control risk, so the whole amount of capital was not fully in jeopardy. As his capital grew, he would allocate capital to various stocks.
Darvas Box Strategy
As the name implies, Darvas Box is based on boxes that a price was trading in. For example, if the price is moving between $45 and $50, that is a box. Mr. Darvas’s goal was to only buy stocks that were moving into higher and higher boxes.
If the price moved above $50, to $50.50, Mr. Darvas bought the stock because it was now moving into a higher box. If the price dropped below $45 (of the $45 to $50 box), to $44.50, then the stock was moving down a box, and therefore was negated as a purchase candidate.
The box limit is not set, but is determined by market forces. If the price is moving between $47 and $48, that creates a box. If it moves higher, the next box may be between $50 and $53, which is the next point where the price stalls and moves back and forth.
A price can stay in a box for as long as it wants. As long as it doesn’t drop below the low of the box, it remains a buy candidate if it moves above the upper limit of the box.
Mr. Darvas gives the following example in his book, of a stock breaking higher into a new box:
If the stock acted right, it started to push from its 45/50 box into another, upper box. Then its movement began to read something like this: 48 – 52 – 50 – 55 – 51 – 50 – 53 – 52.
It has now quite clearly establishing itself in its next box—the 50/55 box.
Darvas Box is an indicator that simply draws lines along highs and lows, and then adjusts them as new highs and lows form. The indicator is available on many trading platforms, such as Thinkorswim. Traders may wish to draw their own boxes though, based on recent highs and lows; Darvas was able to do so (based on telegram quotes) more than half a century ago.
Darvas Box Rules
Darvas established some rules, not just for his strategy, but for himself. After going though his initial learning period of subscribing to a whole bunch of “advisory services,” he found that none of them worked, and they often contradicted each other. Therefore, he proposed seven basic rules to impose on himself.
The following are summarized from his book.
I shall not follow advisory services.
I shall be cautious of broker advice.
I shall ignore Wall Street sayings or truisms, no matter how ancient or revered.
I shall only trade stocks on major exchanges with adequate volume .
I shall not listen to (or trade off of) rumors or tips, no matter how well researched they may sound.
I will use a sound strategy instead of gamble…I must study this strategy (originally this approach was fundamental analysis , which didn’t work for him, so he developed his Darvas Box trading method).
I will hold one position for longer, as opposed to juggling a bunch of positions for a short period of time.
See also 7 Rules Every Contrarian Investor Must Follow
These rules helped Nicholas Darvas develop his strategy, and have the discipline to stick to it. The basic Darvas Box strategy rules are as follows:
Darvas looked for increasing volume when selecting stocks to trade; this alerted him to stocks that were being accumulated and were likely to see strong trends.
Darvas believed in buying stocks that presented an upper box limit breakout, but also had an upward Earnings trend. This was especially the case when the major indexes had experienced a decline.
When an upper box limit is broken, buy. From his book, the entry price was usually about 1 to 2% above the upper box limit.
If you enter a trade and the price proceeds to drop out of the new box, and back into the old box, exit the trade.
Entry and stop loss orders should be set in advance, so trades aren’t missed and risk is controlled.
Place, and trail the stop loss order to below the low of the most recent box. This initial stop loss was pretty tight, because Darvas assumed when a price broke out of an old box, it was entering a new box. Therefore, the stop was placed just below the high of old box which was just broken (low of new box).
Record trades, including reasons why you entered and exited.
General conditions of the market must favor buying. Don’t buy stocks when the major indexes are in a bear market, or when volume is flat or declining.
If you are stopped out, but the price moves back into the higher box again providing another buy signal, buy again, using the same stop loss location.
Since the stop is being trailed up, more funds can be added on each consecutive breakout.
Risks and Considerations
During choppy market conditions the strategy is likely to produce many small losses in a row. This is a trend following method, so a trend needs to develop to produce a profit.
Based on his book, the initial stop loss was set just below the breakout price (likely low of the new box). It was then trailed up as new boxes formed. This method takes a lot of discipline, and a trader can’t get emotionally attached to a stock. Buy and sell when the signals say so.
Traders also need the intestinal fortitude to get back into a trade, if the signals say so, even if they were stopped out. Darvas also added to positions as breakouts to higher boxes occurred. This means bigger gains on trades that work out, but if the trend doesn’t continue, adding to positions near (what ends up being) the top of a move can work against you.
The method could also be employed using short selling when the boxes are dropping. An entry occurs when the price moves below the lower limit of the box; a stop is placed just above the entry price (in the old box) and then trailed down above the top of new lower boxes.
A stop loss won’t save you from losing more than expected if the price gaps through your order. Consider this when assessing how much capital you are willing to commit to a stock.
traderhq.com
Note : Sorry an error occurred in the first version, i installed the second version (security(syminfo.tickerid, 'D', high)v4 not working in different time periods
Tradingview Screener 52 Week High Low
52 Week High Low
EASYMOKU INDICATORThis is the popular Ichimoku Indicator with an easier way to adjust the settings that can help you in your trading.
Components of the Ichimoku indicator:
Tenkan Sen: Basically it is a moving average that goes from 7 to 9 periods.
Kijun Sen: Like Tenkan Sen, we are facing a moving average, but this time from 22 to 26 periods.
Chikou Span: It is the one that represents the current price, but reflected in 22 to 26 periods back.
Senkou Span A: Unlike Chikou Span, this line is drawn over the next 22 to 26 periods, and its calculation is obtained from the average between Tenkan Sen and Kijun Sen. It is a projected average in the future.
Senkou Span B: It is the result of calculating the average between the maximum and minimum over the last 44 to 52 periods, representing the following 22 to 26 periods (as well as the Senkou Span A)
As with Occidental trading systems, based on the crossings of averages, with the Ichimoku we will use the crossing of the Tenkan Sen (fast moving average) with the Kijun Sen (slow moving average) as buying and selling signals.
Strategy of this script:
A strong bullish signal is when price and Chikou Span rises above Kumo cloud and Tenkan Sen cross above Kijun Sen.
A strong bearish signal is when price and Chikou Span falls below Kumo cloud and Tenkan Sen croos under Kijun Sen.
Darvas Box StrategyWhat Is the Darvas Box?
The Darvas Box strategy was developed by Nicholas Darvas. Aside from being a well known dancer, he began trading stock in the 1950s. Based on his success in trading, he was approached to write a book on his strategy. The book, “How I Made $2,000,000 in the Stock Market,” outlines his rather simple approach … simple once you understand the basic concepts and rationale of the strategy.
Darvas originally started with $10,000. He was willing to plunk the whole amount into one stock. This is because he always used a stop loss to control risk, so the whole amount of capital was not fully in jeopardy. As his capital grew, he would allocate capital to various stocks.
Darvas Box Strategy
As the name implies, Darvas Box is based on boxes that a price was trading in. For example, if the price is moving between $45 and $50, that is a box. Mr. Darvas’s goal was to only buy stocks that were moving into higher and higher boxes.
If the price moved above $50, to $50.50, Mr. Darvas bought the stock because it was now moving into a higher box. If the price dropped below $45 (of the $45 to $50 box), to $44.50, then the stock was moving down a box, and therefore was negated as a purchase candidate.
The box limit is not set, but is determined by market forces. If the price is moving between $47 and $48, that creates a box. If it moves higher, the next box may be between $50 and $53, which is the next point where the price stalls and moves back and forth.
A price can stay in a box for as long as it wants. As long as it doesn’t drop below the low of the box, it remains a buy candidate if it moves above the upper limit of the box.
Mr. Darvas gives the following example in his book, of a stock breaking higher into a new box:
If the stock acted right, it started to push from its 45/50 box into another, upper box. Then its movement began to read something like this: 48 – 52 – 50 – 55 – 51 – 50 – 53 – 52.
It has now quite clearly establishing itself in its next box—the 50/55 box.
Darvas Box is an indicator that simply draws lines along highs and lows, and then adjusts them as new highs and lows form. The indicator is available on many trading platforms, such as Thinkorswim. Traders may wish to draw their own boxes though, based on recent highs and lows; Darvas was able to do so (based on telegram quotes) more than half a century ago.
Darvas Box Rules
Darvas established some rules, not just for his strategy, but for himself. After going though his initial learning period of subscribing to a whole bunch of “advisory services,” he found that none of them worked, and they often contradicted each other. Therefore, he proposed seven basic rules to impose on himself.
The following are summarized from his book.
I shall not follow advisory services.
I shall be cautious of broker advice.
I shall ignore Wall Street sayings or truisms, no matter how ancient or revered.
I shall only trade stocks on major exchanges with adequate volume.
I shall not listen to (or trade off of) rumors or tips, no matter how well researched they may sound.
I will use a sound strategy instead of gamble…I must study this strategy (originally this approach was fundamental analysis, which didn’t work for him, so he developed his Darvas Box trading method).
I will hold one position for longer, as opposed to juggling a bunch of positions for a short period of time.
See also 7 Rules Every Contrarian Investor Must Follow
These rules helped Nicholas Darvas develop his strategy, and have the discipline to stick to it. The basic Darvas Box strategy rules are as follows:
Darvas looked for increasing volume when selecting stocks to trade; this alerted him to stocks that were being accumulated and were likely to see strong trends.
Darvas believed in buying stocks that presented an upper box limit breakout, but also had an upward Earnings trend. This was especially the case when the major indexes had experienced a decline.
When an upper box limit is broken, buy. From his book, the entry price was usually about 1 to 2% above the upper box limit.
If you enter a trade and the price proceeds to drop out of the new box, and back into the old box, exit the trade.
Entry and stop loss orders should be set in advance, so trades aren’t missed and risk is controlled.
Place, and trail the stop loss order to below the low of the most recent box. This initial stop loss was pretty tight, because Darvas assumed when a price broke out of an old box, it was entering a new box. Therefore, the stop was placed just below the high of old box which was just broken (low of new box).
Record trades, including reasons why you entered and exited.
General conditions of the market must favor buying. Don’t buy stocks when the major indexes are in a bear market, or when volume is flat or declining.
If you are stopped out, but the price moves back into the higher box again providing another buy signal, buy again, using the same stop loss location.
Since the stop is being trailed up, more funds can be added on each consecutive breakout.
Risks and Considerations
During choppy market conditions the strategy is likely to produce many small losses in a row. This is a trend following method, so a trend needs to develop to produce a profit.
Based on his book, the initial stop loss was set just below the breakout price (likely low of the new box). It was then trailed up as new boxes formed. This method takes a lot of discipline, and a trader can’t get emotionally attached to a stock. Buy and sell when the signals say so.
Traders also need the intestinal fortitude to get back into a trade, if the signals say so, even if they were stopped out. Darvas also added to positions as breakouts to higher boxes occurred. This means bigger gains on trades that work out, but if the trend doesn’t continue, adding to positions near (what ends up being) the top of a move can work against you.
The method could also be employed using short selling when the boxes are dropping. An entry occurs when the price moves below the lower limit of the box; a stop is placed just above the entry price (in the old box) and then trailed down above the top of new lower boxes.
A stop loss won’t save you from losing more than expected if the price gaps through your order. Consider this when assessing how much capital you are willing to commit to a stock.
traderhq.com
Tradingview Screener 52 Week High Low
52 Week High Low
Pair Trade cryptoPair trade for crypto with inputs:
* length of correlation and moving average
* trade pair
* spread threshold to enter long / short
* spread threshold to exit long / short
Pair TradePair trade with inputs:
* length of correlation and moving average
* trade pair
* spread threshold to enter long / short
* spread threshold to exit long / short
Long Term Long/Short Strategy (Pair Trading)Longing or shorting an asset ratio depending on long term trend.
Long term trend is defined by crossing of an asset or index and its SMA.
Input values:
* trend asset
* SMA configuration (periods, resolution)
* strategy: long only, long/short, short only
Grover Llorens Activator Strategy AnalysisThe Grover Llorens Activator is a trailing stop indicator deeply inspired by the parabolic SAR indicator, and aim to provide early exit points and reversal detection. The indicator was posted not so long ago, you can find it here :
Today a strategy using the indicator is proposed, and its profitability is analyzed on 3 different markets with the main time frame being 1 hour, remember that lower time frames involve lower absolute price changes, therefore we are way more affected by the spread, and we can require a larger position sizing depending on our investment target, trading higher time-frames is always a good practice and this is why 1 hour is selected. Based on the result we might make various conclusions regarding the indicator accuracy and might have ideas on future improvements of the indicator.
I'am not great when it comes to strategy design, i still hope to share correct and useful information in this post, let me know your thoughts on the post format and if i should make more of these.
Setup And Rules
The analysis is solely based on the indicator signals, money management isn't taken into account, this allow us to have an idea on the indicator robustness and resilience, particularly on extremely volatile markets and ones exhibiting a chaotic structure, altho it is normally good practice to close any position before a market closure in order to avoid any potential major gaps.
The settings used are 480 for length and 14 for mult, this create relatively mid term signals that are suited for a trend indicator such as the Grover Llorens Activator, unfortunately we can't infer the indicator optimal settings, thats how it is with any technical indicator anyway.
Here are the rules of our strategy :
long : closing price cross over the indicator
short : closing price cross under the indicator
We use constant position sizing, once a signal is triggered all the previous positions are closed.
Description Of The Statistics Used
Various statistics are presented in this post, here is a brief description of the main ones :
Percent Profitability (higher = better): Percentage of winning trades, that is : winning trades/total number of trades × 100
Maximum Drawdown (lower = better) : The highest difference between a peak and a valley in the balance, that is : peak - valley , in percentage : (peak - valley)/peak × 100
Profit Factor (higher = better) : Gross profit divided by gross loss, values under 1 represent gross losses superior to the gross profits
Remember that more volatility = more risk, since higher absolute price changes can logically cause larger losses.
EURUSD
The first market analyzed is the Forex market with the EURUSD major pair with a position sizing of 1000 units (1 micro lot). Since October EURUSD is not showing any particular strong trend but posses a discrete rising motion, fortunately cycles can be observed.
The equity was rising until two trades appeared causing a decline in the equity. Before October a bearish market could be observed.
We can see that the equity is rising, the trend still posses various retracements that affect our indicator, however we can see that the indicator totally nail the end of the trend, thats the power of converging toward the price.
In short :
$ 86.63 net profit
340 closed trades
37.65 % profitable (thats a lot of loosing trades)
1.19 profit factor
$ 76.67 max drawdown
Applying a spread would create negative results (in general the average spread is used), not a great start...
BTCUSD
The cryptocurrency market is relatively more volatile than others, which also mean potentially higher returns, we test the indicator using certainly the most traded cryptocurrency, BTCUSD. We will use a position sizing of 1 unit.
In the case of BTCUSD the strategy balance is relatively stationary around the initial capital, with of course high dispersion.
from september to december the market is bearish with various ranging periods, no apparent cycles can be observed, except maybe in the ranging period of october, this ranging period is followed by a non linear trend (relatively parabolic) that the indicator failed to capture in its integrity (this is a recurrent problem and it is starting to piss me off xD).
In short :
$ 2010.64 net profit (aka how i bet the crypto market)
395 closed trades
38.23 % profitable
1.036 profit factor
$ 5738.01 max drawdown (aka how i lost to the crypto market)
AMD
AMD stand for Advanced Micro Devices and is a company focused on the development of computer technology, i love the microprocessor market and i really like AMD who start this year in a pretty great way with a net bullish trend.
The performance of the indicator on AMD is decent (at last !) with the equity producing many new higher highs. The indicator performance still drop in the middle end of 2019 with a large equity drawdown of 17$ caused by the gap of august 8. Unfortunately AMD, like lot of well behaving stocks can only tells us that the indicator has good performances on heavily trending markets with no excess of noise or chaotic structures.
In short :
$ 17.86 net profit (Enough for a consistent lunch)
295 closed trades
36.27 % profitable
1.414 profit factor
$ 10.37 max drawdown.
Conclusion
A strategy using the recently proposed Grover Llorens activator has been presented. We can easily conclude that the indicator can't possibly generate long term returns under chaotic and volatile markets, and could even produce unnecessary trades in trending markets without much parasitic fluctuations such as noise and retracements (think about a simple linear trend) since the indicator converge toward the price and would therefore automatically cross over/under the trend, thus guaranteeing a false signal.
However we have seen its ability to provide accurate early reversal detection shine from time to time, thus over performing lagging indicators in this aspect, however the duration of price fluctuations isn't fixed at a certain period, the rate of convergence should be way faster during volatile fluctuations, of moderate speed during more cyclic fluctuations, and really slow with apparent long term trends, this could be achieved by making the indicator adaptive, but it won't really make it necessarily perform better.
That said i still believe that converging trend indicators are really interesting and aim to capture the non lasting behavior of price fluctuations, they shouldn't receive so much hate (think about the poor p-sar).
Thanks for reading !
Trend Following or Mean RevertingThe strategy checks nature of the instruments. It Buys if the close is greater than yesterday's high, reverse the position if the close is lower than yesterday's low and repeat the process.
1. If it is trend following then the equity curve will be in uptrend
2. If it is mean reverting then the equity curve will be downtrend
Thanks to Rayner Teo.
Linear Regression Pearson's R - Trend Channel StrategyThis script takes advantage of the Pearson's R attribute of the data set you provide.
Pearson's R attempts to find how correlated data is with a potential pattern. If the number is negative the correlation is upwards . If it's positive the correlation is downwards . Pearson's R can only be a number between -1 and 1. It should be impossible to ever reach -1 or 1 as that would be a perfect correlation.
This particular strategy involves using linear regression and Pearson's R to keep recalculating steps back from the current position until the Pearson's R reaches the desired amount. For example, in my experience I have found that 0.85 for as a buy point is very good as it means the trend is very reliable and solid. When the market tends to be bullish it tends to do so longer then when it's bearish.
Likewise when a downtrend is more real, I found that 0.71 for the negative Pearson's R value is ideal and gives the best results.
These can all be changed in the settings section (with the gear icon) next to when you set your results.
This strategy is really fun/useful to watch if you have the replay bar mode enabled for TradingView. This script supports this and all you have to do is go into the settings and enable realtime mode . Doing this you can actually see the trend lines change in realtime and comes in very handy for seeing long term reversals as you will see the Pearson's R value start to go down or up indicating the path it's going on.
WARNING: This script is very intensive on the processing power of your machine. If you find that it's to slow you may have to go into the settings of the script and adjust the 'step by' parameter so that it calculates a little faster. It won't be as accurate but it will be good enough. I feel I've optimized it with it's current setting as an example of what you want to aim for.
If there are any questions do no hesitate to message or ask me. I love feedback on the community for new features and ideas!
This works best with with XBTUSD on the 4 hourly chart . It does not seem to work well if you go below hourly or go above daily.
UT Bot Strategy with Backtesting Range [QuantNomad]UT Bot indicator was inially developer by @Yo_adriiiiaan
Idea of original code belongs @HPotter
I can't update my original UT Bot Strategy so I publishing new strategy with backtesting range included.
I just took code of Yo_adriiiiaan, cleaned it, deleted all useless pieces of code, transformet to v4 and created a strategy from it.
Also I added an input that allows you to swich to signals from Heiking Ashi. I saw that author uses HA for the indicator and on HA it look much nices then on real candles.
Do not add this strategy to HA candles, use usual candles and this checkbox.
Original script:
UT Bot
Key Reversal Up Backtest
A key reversal is a one-day trading pattern that may signal the reversal of a trend.
Other frequently-used names for key reversal include "one-day reversal" and "reversal day."
How Does a Key Reversal Work?
Depending on which way the stock is trending, a key reversal day occurs when:
In an uptrend -- prices hit a new high and then close near the previous day's lows.
In a downtrend -- prices hit a new low, but close near the previous day's highs
WARNING:
- For purpose educate only
- This script to change bars colors.
How To Set Backtest Time Ranges
Example how to set the time range window to be backtested for both entries and exits. Additional examples are also included showing how to set the date range and toggle plot visibility.
By incorporating this code with your own strategy's logic, it will allow you to backtest various time windows.
Much gratitude to @LucF and @a.tesla2018 for help with including ':1234567' for time ranges on weekends. Thank you both!
NOTICE: This is an example script and not meant to be used as an actual strategy. By using this script or any portion thereof, you acknowledge that you have read and understood that this is for research purposes only and I am not responsible for any financial losses you may incur by using this script!