TradingView
amit1337
2021年4月11日午後10時47分

Kagi Implementation (+ATR) 

Bitcoin all time history indexINDEX

詳細

My Own Kagi Indicator Implementation!
I couldn't find anywhere on the internet a simple implementation of the Kagi indicator (apart from a seemingly complicated JavaScript implementation).
So I decided to implement it myself and test it against the built-in Kagi indicator calculated by the built-in security function - They ended up exactly the same! (You can see my orange plot completely covers the security's purple plot)
My calculations are based on this article from a site called "euroland", the article is called "Kagi Chart" (I can't post the link because of TradingView restrictions)
Bonus: The built-in kagi indicator uses only Fixed Amount Reversal Size. One that is interested in an ATR Reversal Size can modify the calculation a bit (see script's comments) to easily create and use it.

Some interesting info about the security function I discovered while doing this script:
After I implemented it I noticed that my calculations are the same except the fact that all my values are delayed by 1 bar (relative to the security's indicator). After some research I discovered that the security function uses future data in it's calculation and therefore it cannot be trusted for testing live-trading strategies, unless it is given the appropriate parameters (see script for example).

Have fun trading and don't lose money!
コメント
blackcat1402
Awesome, I like your discovery about security() function
amit1337
@blackcat1402, Thank you very much! I'm glad you liked it :)
CHOLAN_MLA
Hi Amit, What is the rules for using this indicator? I.e, How to take entry and define SL and target?
amit1337
@CHOLAN_MLA, Hi! sorry for the late response, I seemed to miss your comment.
The indicator doesn't have strict rules. It can be used with other indicators to form a strategy, and its usage is different depending on your goals, timeframe and other parameters...
kuldeep72
It is repainting. Else it is the best indicator I would say. Can you please fix the issue ?
amit1337
@kuldeep72, I don't exactly understand what you mean by "repainting". Where exactly do you believe a repaint could happen (which line could cause a repaint)?
The security function probably repaints, but calling it this way seems to fix it: "security(kagisrc, ktf, close[1], barmerge.gaps_off, barmerge.lookahead_on)".
Other than that, I believe my implementation can be used in live trading (it only uses the close series)
kuldeep72
@amit1337, I am not a programmer and hence can't comment on which line is causing a repaint. If you can share your e mail, i will send you live market screen shots, where the signal was generated in previous "n"th candle.
If this sort of issue is resolved, then this system can become a great success story.
amit1337
@kuldeep72, I sent you a private message
skhishore75
Why its repainting?? Is any possible to fix it!
96b31d34302749e6bd028b7cd81bb8
Is it possible to add mtf to your code?
詳細