Detecting Golden / Death Crosses Correctly In Your Algo Strategy / Indicator
When we detect a moving average cross , be it of the golden or death variety - it is crucial to avoid a false positive and get the correct cross to ensure trading the movement profitably.
What I have found broken in the majority of public code posted online is the programmer has neglected to check the previous bars position. So their cross code is working in an assumption that if x < y
it was a cross. This can give continual false positive and return a highly unprofitable strategy.
Realistically, when we look at a chart we do not make this calculation but rather if x1 < y1 and x2 > y2
wherex1
is the last bars close price and y1
is the last bars moving average. We look to see if it was under before, and over after. Thus calculating a cross correctly.
So for a Death Cross - we must detect if the slower moving average has risen above the faster. E.g if SlowMa1 < FastMa1 and SlowMa2 > FastMa2
Using two sample points we are able to see if the slower moving average of the previous bar SlowMa1
was below the faster MA and now in the next bar has risen above. Signalling a Death Cross, we can look to enter a short position.
The inverse of this can be applied to correctly detect a Golden Cross, and open a position for that.
For an indicator you can trigger an alert and append a log entry for the cross, to automate trading we can possibly work with the JavaScript libraries available in a trading bot environment like Gekko which works with popular crypto exchanges such as Poloniex and Bitfinnex.
Congratulations @tomtom87! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @tomtom87! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @tomtom87! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @tomtom87! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @tomtom87! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @tomtom87! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @tomtom87! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @tomtom87! You have received a personal award!
1 Year on Steemit
Click on the badge to view your Board of Honor.
Do not miss the last post from @steemitboard:
SteemitBoard World Cup Contest - France vs Croatia
Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes
@tomtom87 you were flagged by a worthless gang of trolls, so, I gave you an upvote to counteract it! Enjoy!!
Congratulations @tomtom87! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!