-
-
Save basnijholt/a78fe8deafe76bf3cc1f7e9817f9169e to your computer and use it in GitHub Desktop.
//@version=4 | |
study(title="CTO Line", shorttitle="CTO", overlay=true, resolution="") | |
smma(src, length) => | |
smma = 0.0 | |
smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length | |
smma | |
v1 = smma(hl2, 15) | |
m1 = smma(hl2, 19) | |
m2 = smma(hl2, 25) | |
v2 = smma(hl2, 29) | |
p2 = v1<m1 != v1<v2 or m2<v2 != v1<v2 | |
p3 = not p2 and v1<v2 | |
p1 = not p2 and not p3 | |
c = p1 ? color.orange : p2 ? color.silver : color.navy | |
line1 = plot(v1, "Line 1", color=c) | |
line2 = plot(v2, "Line 2", color=c) | |
fill(line1, line2, color=c) |
It works. Currently, the pine script in tradingview is on version 5 so if you copy the code into trading view you need to change to version 4. You will get a warning about the version number just ignore. Also, you can replace line 14,15,16 with the below to look more like the original line. There is a small error rate of about 0.2% compared to the original line.
c = p1 ? color.rgb(255, 255, 0, 50) : p2 ? color.rgb(178, 181, 190, 50) : color.rgb(0, 0, 255, 50) line1 = plot(v1, "Line 1", color=c, linewidth=3) line2 = plot(v2, "Line 2", color=c, linewidth=3)
What I can say about CTO Larson is that I like him, he has worked in GSM and so have I. He understands the technical and he has a close group of individuals you want to be part of. Easy to copy the above and paste, but you need the training he provides to get the fundamentals right. My only wish he stayed with Ericsson, because now I have to deal with Hauwei. Maybe there's a correlation between him leaving erricson and hauwei becoming number one RAN supplier, and maybe this new adventure he has will benefit more people.
Thank you. I convert it into javascript to use with my broker API, but I'm not an expert in pine script, I'm not sure if the value is smoothed over time or only once.
That is, does the block
smma(src, length) =>
smma = 0.0
smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length
smma
v1 = smma(hl2, 15)
- first initialize the smma to the sma then smooth it once
meaning that for every candle, it will get the sma then smooth it once - or will it smooth it every time a new candle appears?
that is, keeping the previous smoothed version in memory and applying the new value to smooth it?
I guess my question could also be phrased as do smma becomes a series that stays available when the function is called with the same arguments?
Both are simple to code but they are quite different...
@cuterendra you can add with a basic account, as long as you stay within the 3 indicators displayed limit. (that's what I do and it works fine)
If this makes it easier, here is a v5
//@version=5
indicator(title='CTO Line', shorttitle='CTO', overlay=true, timeframe='')
smma(src, length) =>
smma = 0.0
sma = ta.sma(src, length)
smma := na(smma[1]) ? sma : (smma[1] * (length - 1) + src) / length
smma
v1 = smma(hl2, 15)
m1 = smma(hl2, 19)
m2 = smma(hl2, 25)
v2 = smma(hl2, 29)
p2 = v1 < m1 != v1 < v2 or m2 < v2 != v1 < v2
p3 = not p2 and v1 < v2
p1 = not p2 and not p3
c = p1 ? color.orange : p2 ? color.silver : color.navy
line1 = plot(v1, 'Line 1', color=c)
line2 = plot(v2, 'Line 2', color=c)
fill(line1, line2, color=c, transp=90)
How is this supposed to be used? I know it's best on 4hr time frames. When I use it as an indicator for a strategy backtest it actually doesn't perform very well. Something like 46% over the course of 3 years.
I used logic such as:
Close and open long position when orange is triggered.
Close and open short when blue is triggered.
I even experimented with closing the position if it enters a greyzone and awaiting for a new color to occur to re-enter. This marginally improved the backtest.
Am I using this indicator wrong or something or is it not made for automated trading?
Alternatively I can reach a 260% gain on BTC since 2020 using tradingviews default "supertrend" indicator and fiddling around with the ATR params. I thought larson line would be better..!
Worked great!! Thanks.
Hi @BreWep its clear you have respect for Larsson. i do too.. his course price is just too steep for me.
do you have any content from his course fundamentals that you could share.
it would really help. and thanks for the help on the pine editor for the larsson line.
BTW he says that the indicator is free the course is paid so no need to feel guilty of using this source code
not worked