Intersection Value FunctionsWinning entry for the first Pinefest contest. The challenge required providing three functions returning the intersection value between two series source1 and source2 in the event of a cross, crossunder, and crossover.
Feel free to use the code however you like.
🔶 CHALLENGE FUNCTIONS
🔹 crossValue()
//@function Finds intersection value of 2 lines/values if any cross occurs - First function of challenge -> crossValue(source1, source2)
//@param source1 (float) source value 1
//@param source2 (float) source value 2
//@returns Intersection value
example:
value = crossValue(close, close )
🔹 crossoverValue()
//@function Finds intersection value of 2 lines/values if crossover occurs - Second function of challenge -> crossoverValue(source1, source2)
//@param source1 (float) source value 1
//@param source2 (float) source value 2
//@returns Intersection value
example:
value = crossoverValue(close, close )
🔹 crossunderValue()
//@function Finds intersect of 2 lines/values if crossunder occurs - Third function of challenge -> crossunderValue(source1, source2)
//@param source1 (float) source value 1
//@param source2 (float) source value 2
//@returns Intersection value
example:
value = crossunderValue(close, close )
🔶 DETAILS
A series of values can be displayed as a series of points, where the point location highlights its value, however, it is more common to connect each point with a line to have a continuous aspect.
A line is a geometrical object connecting two points, each having y and x coordinates. A line has a slope controlling its steepness and an intercept indicating where the line crosses an axis. With these elements, we can describe a line as follows:
slope × x + intercept
A cross between two series of values occurs when one series is greater or lower than the other while its previous value isn't.
We are interested in finding the "intersection value", that is the value where two crossing lines are equal. This problem can be approached via linear interpolation.
A simple and direct approach to finding our intersection value is to find the common scaling factor of the slopes of the lines, that is the multiplicative factor that multiplies both lines slopes such that the resulting points are equal.
Given:
A = Point A1 + m1 × scaling_factor
B = Point B1 + m2 × scaling_factor
where scaling_factor is the common scaling factor, and m1 and m2 the slopes:
m1 = Point A2 - Point A1
m2 = Point B2 - Point B1
In our cases, since the horizontal distance between two points is simply 1, our lines slopes are equal to their vertical distance (rise).
Under the event of a cross, there exists a scaling_factor satisfying A = B , which allows us to directly compute our intersection value. The solution is given by:
scaling_factor = (B1 - A1)/(m1 - m2)
As such our intersection value can be given by the following equivalent calculations:
(1) A1 + m1 × (B1 - A1)/(m1 - m2)
(2) B1 + m2 × (B1 - A1)/(m1 - m2)
(3) A2 - m2 × (A2 - B2)/(m1 - m2)
(4) B2 - m2 × (A2 - B2)/(m1 - m2)
The proposed functions use the third calculation.
This approach is equivalent to expressions using the classical line equation, with:
slope1 × x + intercept1 = slope2 × x + intercept2
By solving for x , the intersection point is obtained by evaluating any of the line equations for the obtained x solution.
🔶 APPLICATIONS
The intersection point of two crossing lines might lead to interesting applications and creations, in this section various information/tools derived from the proposed calculations are presented.
This supplementary material is available within the script.
🔹 Intersections As Support/Resistances
The script allows extending the lines of the intersection value when a cross is detected, these extended lines could have applications as support/resistance lines.
🔹 Using The Scaling Factor
The core of the proposed calculation method is the common scaling factor, which can be used to return useful information, such as the position of the cross relative to the x coordinates of a line.
The above image highlights two moving averages (in green and red), the cross-interval areas are highlighted in blue, and the intersection point is highlighted as a blue line.
The pane below shows a bar plot displaying:
1 - scaling factor = 1 -
Values closer to 1 indicate that the cross location is closer to x2 (the right coordinate of the lines), while values closer to 0 indicate that the cross location is closer to x1 .
🔹 Intersection Matrix
The main proposed functions of this challenge focus on the crossings between two series of values, however, we might be interested in applying this over a collection of series.
We can see in the image above how the lines connecting two points intersect with each other, we can construct a matrix populated with the intersection value of two corresponding lines. If (X, Y) represents the intersection value between lines X and Y we have the following matrix:
| Line A | Line B | Line C | Line D |
-------|--------|--------|--------|--------|
Line A | | (A, B) | (A, C) | (A, D) |
Line B | (B, A) | | (B, C) | (B, D) |
Line C | (C, A) | (C, B) | | (C, D) |
Line D | (D, A) | (D, B) | (D, C) | |
We can see that the upper triangular part of this matrix is redundant, which is why the script does not compute it. This function is provided in the script as intersectionMatrix :
//@function Return the N * N intersection matrix from an array of values
//@param array_series (array) array of values, requires an array supporting historical referencing
//@returns (matrix) Intersection matrix showing intersection values between all array entries
In the script, we create an intersection matrix from an array containing the outputs of simple moving averages with a period in a specific user set range and can highlight if a simple moving average of a certain period crosses with another moving average with a different period, as well as the intersection value.
🔹 Magnification Glass
Crosses on a chart can be quite small and might require zooming in significantly to see a detailed picture of them. Using the obtained scaling factor allows reconstructing crossing events with an higher resolution.
A simple supplementary zoomIn function is provided to this effect:
//@function Display an higher resolution representation of intersecting lines
//@param source1 (float) source value 1
//@param source2 (float) source value 2
//@param css1 (color) color of source 1 line
//@param css2 (color) color of source 2 line
//@param intersec_css (color) color of intersection line
//@param area_css (color) color of box area
Users can obtain a higher resolution by modifying the provided "Resolution" setting.
The function returns a higher resolution representation of the most recent crosses between two input series, the intersection value is also provided.
Macross
Versatile MA Cross [Lysergik][Dark Mode]An easy to use MA-Cross that is easily configured for any kind of TA scenario
v1.0
Features:
- 7-period MA Prediction
- Individually configurable MA types
- Optional dark-mode and custom colors for quick adaptation to your custom chart appearance
- Fill color between MA's for support / resistance clouds
- Comes with with four optional presets as well as the custom mode
Dark Mode On (top) || Dark Mode Off (bottom)
ALMA cross signal by hk4jerry<< ALMA CROSS signal >>
*NONE REPAINT STRATEGY*
--As a result of testing for a month, using alma does not result in repainting--
--ALMA 크로스 결과는 한달간의 테스트 결과, 리페인팅되지 않습니다--
(ENGLISH description O)
==NOTE==
1. MA 크로스 지표는 잘못된 신호들이 자주 등장합니다. 정확성을 더 높일수 있는 방법은 없을까 고민을 해봤습니다. 더 낮은 가격에 매수하고, 더 높은 가격에서 매도하는 것이 중요했습니다. 우리가 흔히 저점, 고점을 알아내기 위한 지표이자, 선행지표인 RSI를 추가하는 방법을 연구했습니다.
2. 예를 들어, MA 크로스 매수 신호가 발생했을때, rsi값이 50이면 가격이 더 떨어질 가능성이 큽니다. 하지만, rsi값이 30이하인 경우에만 매수 신호가 발생한다면, 그 가격이 저점일 확률이 매우 높아지는 원리 입니다.
3. 신호는 확률입니다. 트레이딩에 100%는 없습니다. 그 확률을 높이는 것은 리스크 관리 입니다. 분할 매수 관점으로 포지션을 잡으시거나, 단기 매매로 가져가시는걸 추천드립니다.
==rsi ma source 설정==
1. 'rsi ma' 값의 소스입니다.
2. 'rsi 길이' 는 값이 클수록 더욱 정확한 시그널이 발생합니다.
3. EMA 길이가 짧을수록 더 많은 시그널이 발생합니다. 그러나, 정확도는 떨어집니다.
==rsi ma 설정==
1. rsi를 source로한 EMA입니다.
2. rsi와 유사한 성격을 가집니다.
3. 'rsi ma' 값이 30이하이면 과매도, 70이상이면 과매수 입니다.
4. ' rsi ma long value' 이 30이면 매수 신호가 rsi ma 값이 30 이하인 경우에만 발생함을 의미 합니다.
5. "rsi ma short value' 가 70이면 매도 신호가 rsi ma 값이 70 이상인 경우에만 발생함을 의미 합니다.
==rsi 설정==
1. 실제 rsi(14,close) 값을 의미합니다.
2. rsi ma value와 비슷한 기능입니다.
3. rsi 길이가 14이므로, 값은 40~50 사이가 적당합니다.
4. 30 또는 70으로 설정할 시, 신호가 거의 발생하지 않습니다.
(ENG)
==NOTE==
1. MA cross indicator often shows false signals. I was wondering if there is a way to increase the accuracy further. It was important to buy at a lower price and sell at a higher price. We studied how to add RSI, which is a leading indicator and an indicator to find lows and highs, often.
2. For example, when a buy MA cross signal occurs, if the rsi value is 50, the price is more likely to fall. However, if a buy signal occurs only when the rsi value is below 30, the probability that the price is at the bottom is very high.
3. A signal is a probability. There is no 100% in trading. Increasing that probability is risk management. It is recommended to hold a position from the perspective of a split buy or take it as a short-term trade.
==rsi ma source option==
1. The source of the 'rsi ma' value.
2. The larger the 'rsi length' value, the more accurate the signal is generated.
3. Shorter EMA lengths produce more signals. However, the accuracy is reduced.
==rsi ma options==
1. EMA with rsi as the source.
2. It has similar characteristics to rsi.
3. If the 'rsi ma' value is below 30, it is oversold, and if it is above 70, it is overbought.
4. If 'rsi ma long value' is 30, it means that a buy signal will only occur when the rsi ma value is less than or equal to 30.
5. If "rsi ma short value' is 70, it means that a sell signal will only occur when the rsi ma value is above 70.
==rsi option==
1. It means the actual rsi(14,close) value.
2. This function is similar to rsi ma value.
3. Since the rsi length is 14, a value between 40 and 50 is appropriate.
4. When set to 30 or 70, almost no signal is generated.
it is a simple Ma cross alert. We can set any ma period.Simple alert for 20MA cross. We can set any ma period.
it plots the crossing candle. This script is purely testing purpose.
H/L Price Band with Signal Line (PBS)This indicator centers a moving average around the hl2 of the price. This is calculated as the difference of two moving averages. The upper band is a 9 period exponential moving average, the lower band is a 7 period moving average and the center line is the average between the two. The "Fast Line" is our signal line in this oscillator. When the price is hovering around the center of the band this indicates that a trend is pausing or reversing. When the fast line exits the band this could be a buy or sell signal. It could also indicate a very strong trend in that direction. To get the optimal entry and exit you might want to wait for the price to return to the center line. In addition to the basic functionality of this indicator I have added some bonus features. You can enable the "Slow Line" or the "Long Line" to enhance your signals. When the fast line is above the slow/long line you are in an up trend and inversely when the fast line is below the slow/long line you are in a down trend. The crossing of these lines can indicate a reversal. I have also included a "J" style amplification line. This works by enhancing the difference between the Fast and Slow/Long line to make it more visually apparent. You can also configure the "J" line to be calculated between either the slow or long line. Finally I have added the feature to amplify the band width by the standard deviation. This is set to 1 by default but you can also get a more responsive signal by setting this to 0.
This indicator works in most markets. There is a tool tip for every aspect of this indicator explaining how everything works. I hope you are very profitable with this one!
If you find this indicator is useful to you, Star it, Follow, Donate, Like and Share.
Your support is a highly motivation for me.
ADX SignalsThis script uses the Average Direction Index, On Balance Volume, and Exponential Moving Average, Moving Average Cross, MACD, Donchian Channels and two Parabolic SARs for stop loss, a normal one and a line one.
I tried to make the script as straightforward as possible, Buy when there is a buy signal and sell when there is a sell signal. I like using it on the smaller time-frames because I'm a scalper and I like going in and out quickly, but this indicator can be used on any timeframe and works on any instrument. The buy signal is triggered when the DI+ goes above the 30 level, the ADX is not increasing, on balance volume is at it's lowest, the price is above the lower Donchian Channel and last MACD hist bar is lower than the previous one. The sell signal is triggered when the DI- goes above the 30 level, the ADX is not increasing, on balance volume is at it's highest, the price is below the upper Donchian Channel and last MACD hist bar is upper than the previous one.
If you have any suggestions feel free to leave them in the comments below or Message me directly.
ANTS BEAST MODE TRIX+MACD TRIX CROSSThis indicator is both the TRIX + MACD all in one inidicator -- a + sign is displayed whenever the trix crosses
Uhl MA System - Strategy AnalysisThe Uhl MA crossover system was specifically designed to provide an adaptive MA crossover system that didn't committed the same errors of more classical MA systems. This crossover system is based on a fast and a slow moving average, with the slow moving average being the corrected moving average (CMA) originally proposed by Andreas Uhl, and the fast moving average being the corrected trend step (CTS) which is also based on the corrected moving average design.
For more information see :
In this post, the performances of this system are analyzed on various markets.
Setup And Rules
The analysis is solely based on the indicator signals, therefore no spread is applied. Constant position sizing is used. The strategy will be backtested on the 15 minute time-frame. The mult setting is discarded, the default setting used for length is 100.
Here are the rules of our strategy :
long: CTS crossover CMA
short: CTS crossunder CMA
Results And Data
EURUSD:
Net Profit: $ 0.08
Total number of trades: 99
Profitability: 35.35 %
Profit Factor: 1.834
Max Drawdown: $ 0.01
EURUSD behaved pretty well, and was most of time showing long term trends without exhibiting particularly tricky structures, the moving averages still did cross during ranging phases, since march 9 we can see a downtrend with more pronounced cyclical variations (retracements) that could potentially lead to loosing trades.
BTCUSD:
Net Profit: $ 4371.57
Total number of trades: 94
Profitability: 32.98 %
Profit Factor: 1.749
Max Drawdown: $ 1409.96
The strategy didn't started well, producing its largest drawdown after only a few trades, the strategy still managed to recover. BTCUSD exhibited a strong downtrend, the strategy profited from that to recover, signals still occurred on ranging phases, and where mostly caused by a short term volatile move, unfortunately the CMA can converge toward ranging/flat price zones where false signals might occur at higher frequency.
AMD:
Net Profit: $ 16.09
Total number of trades: 95
Profitability: 29.47 %
Profit Factor: 1.288
Max Drawdown: $ 20.11
On AMD the strategy started relatively well with a raising balance, then the balance quickly fallen, this downtrend in the balance lasted quite some time (almost 48 trades), the strategy finally recovered in Nov 2019 and the balance made a new highest high at the end of February. AMD had numerous trends during the backtesting period, yet results are poor.
AAPL:
Net Profit: $ -28.17
Total number of trades: 89
Profitability: 28.09 %
Profit Factor: 0.894
Max Drawdown: $ 63.21
AAPL show the poorest results so far, with a stationary balance around the initial capital (in short the evolution of the balance is not showing any particular trend and oscillate around the initial capital value).
AAPL had some significant retracements in its up-trend, which triggered some trades (of course), and the ranging period from Jan 24 to Feb 13 heavily damaged the strategy performance, generating 6 significant loosing trades. AAPL show the worst results so far, mostly due by ranging phases.
Conclusions
The Uhl MA crossover system strategy has been tested and based on the results don't show particularly interesting performances, and might even be outperformed by simpler MA systems that prove to be more robust against ranging markets. The total number of executed trades are on average 94, and the profitability is on average 31%. The strategy might prove more interesting if we can correct the behavior of the CMA, who sometimes converged toward ranging/flat markets.
Uhl MA Crossover SystemToday proposed indicator is based on the corrected moving average, an indicator originally proposed by Andreas Uhl professor at Salzburg University. This moving average is not the most well known, which is a pity since its design is extremely elegant.
The corrected moving average (CMA) is an adaptive moving average based on exponential averaging and aim to correct common problems of classical moving averages such as crosses occurring during sideway markets, more details will be introduced in the calculation section. The CMA aim to act as a slow moving average in a moving average crossover system.
Here a new fast adaptive moving average named corrected trend step (CTS) based on the CMA is introduced in order to provide a full moving average crossover system based on A. Uhl design.
To Andreas Uhl
Calculation And Understanding The CTS
Even if the code is quite compact, the original idea behind the CMA can be blurry for some users, however it is actually relatively simple to understand. The CMA is based on exponential averaging and a smoothing variable is therefore required, in the CMA the calculation of the smoothing variable is based on the squared distance between the precedent CMA output and a simple moving average, and the rolling variance, where the rolling variance act as threshold.
The CTS work the same way but instead of using the squared error between a simple moving average and the previous CMA output, we use the squared error between the closing price and the previous CTS output, this allow the CTS to better fit with the closing price. As said before the rolling variance act as threshold, if the squared error is lower than the rolling variance this mean that the CTS is close to the price, which can indicate a sideway market, therefore we should filter the entirety of the current price, therefore on sideways market the CTS is equal to the precedent value of the CTS.
In trending/volatile markets we expect the price to go away from the CTS, thus having an high squared error, if the squared error is greater than the rolling variance, the smoothing variable is equal to 1 - variance/squared error , here variance/squared error < 1 since the squared error is greater than the rolling variance ( remember that the smoothing variable need to be in a (0,1) range ), however if the squared error is way higher than variance this ratio will be small, which would return a non reactive output, but thats not what we want ! This is why we subtract 1 by this ratio in order to make the CTS more reactive instead of less reactive.
In case the squared error is greater than the rolling variance during sideway markets we would not expect a huge difference anyway, that is squared error ≈ variance and therefore:
1 - variance/squared error ≈ 1 - 1/1 ≈ 1 - 1 ≈ 0
This is a beautiful way to make an adaptive moving average, the CMA is not a flashy indicator, but when we look at the details behind the design we can only get amazed, or maybe that its just me, truly a great adaptive moving average.
The System
length control the filtering amount of both moving averages, with higher values of length returning larger filtering amount. Mult multiply the rolling variance by an user selected value, this also allow a greater amount of filtering.
The CTS act as a fast moving average while the CMA act as a slow moving average.
Here the indicator with length = 200, we can see how a sideway market who could have generated a large amount of signals don't affect our system.
Unlike classical crossovers systems where the slow moving average will rarely produce a cross with the fast moving average and price at the same time, the Uhl system can actually do that:
Conclusion
A moving average crossover system based on the corrected moving average proposed by Andreas Uhl has been presented, a new moving average that aim to produce good fits with the price has been created especially for this system. The logic behind the CMA has also been explained. A possible strategy analysis could be presented in the future.
In conclusion i would say the CMA is a bit underrated, in a field where arrows, signals, alerts are the only things appreciated by peoples, original content is slowly dying, this actually make today technical indicators have a pretty bad academic reputations. I'am afraid that today haiku master is Uhl rather than me, i hope to see more indicators from him in the future.
Thanks for reading !
Original paper: www.buero-uhl.de
BEST MA Cross/MACD ScreenerHello traders
Continuing deeper and stronger with the screeners' educational serie one more time
I - Concept
This is the first flexible screener I'm releasing. Screener detecting a convergence whenever the MACD and MM cross are giving a signal in the same direction.
Those who know me from TradingView ... are aware that I'm big on convergences. I totally think that 1 indicator isn't enough - whatever the timeframe.
But building my own convergence detection systems has been fruitful for me
II - How did I set the screener
The visual signals are as follow:
- square: MACD + MA cross convergence.
- diamond: Only MACD is selected
- circle: Only MA cross is selected
Then the colors are:
- green when bullish
- red when bearish
Example
Below, I highlighted why we see diamonds on the top screener panel. This is because I only selected the MACD filter
Cool Hacks
Don't forget that you can add the same indicator multiple times on your chart :)
Wishing you all the BEST trading
Dave
150MA Cross BuyAndSell Strategy [d3nv3r]This is a Buy And Sell Strategy I haven't seen anywhere so i share mine.
Used on Bitcoin - daily chart - the strategy generate sell and buy indicator on crossover and crossunder the 150 simple moving average.
Kijun-Sen Strategy [DasanC]This strategy employs the Kijun-Sen line (from Ichimoku cloud) as a baseline for decisions.
In essence, the Kijun-Sen is a kind of moving average based on the High/Low range, similar to Donchian channels.
We wait for a crossover or crossunder to enter a new trade, then exit upon the next cross.
It works on 1H timeframe and above. It also works for all the Major FX pairs (at least from my tests).
I use the ATR and a multiplier to decide the S/L position as well as the volume of the trade.
I also use an equity protector to close out of all trades if a specific DD % level is reached. In theory, this should never happen with only one trade open at a time, however, if a user wants to modify the script to pyramid orders then the equity protector could potentially "save" an account.
The default settings should produce winning results on Major pairs. You can change the backtest time in the script by altering line #53:
>if(time > timestamp(2017,1,1,0,0) and time < timestamp(2019,1,1,0,0))
TODO:
Add 2 additional forms of confirmation
Add volume to filter losing trades
Add exit indicator
Bollinger Awesome Alert R1 by JustUncleLThis indicator is an implementation of the Bollinger Band and Awesome Oscillator Scalping system.
This technique is for those who want the most simple method that is very effective. It is BEST traded during the busiest trading hours, 3am to 12am EST NY time. This method doesn't work in sideways markets, only in volatile trending markets.
Time Frames: 1, 5, 10, 15 ,30 min.
Currency pairs: majors.
Other Chart indicators:
Add Awesome Oscillator.
Optionally Add Squeeze Indicator.
Here's the strategy:
Going LONG:
Enter a long position when the black 3 EMA has crossed up through the Bollinger red middle band MA. At the same time, the Awesome should be approaching or crossing it's zeroline, going up. This is indicated by "Buy" alert.
Going SHORT:
Enter a short position when the black 3 EMA has crossed down through the Bollinger red middle band MA. At the same time, the Awesome should be approaching or crossing it's zero line, going down. This is indicated by the "Sell" Alert.
Take profit:
10-20 pips depending on pair or When Awesome Oscillator turns a different colour.
HINTS: Best trades tend to occur when price reversing bounce off outer band and outside the Optional Bollinger Squeeze indication.
Moving Average Cross Alert, Multi-Timeframe (MTF) (by ChartArt)See when two moving averages cross. With the option to choose between four moving average calculations:
SMA = simple moving average
EMA = exponential moving average (default)
WMA = weighted moving average
Linear = linear regression
The moving averages can be plotted from different time-frames, like e.g. the weekly or 4 hour time-frame using HL2, HLC3 or OHLC4 as price source for the calculation. In addition there is a background color alert and arrows when the moving averages cross each other when the price also rises or falls. And the moving averages are colored depending on their trend direction (if they are trending up or down).