Heikin Ashi Candle Color Change Strategy


Category:
0
0

Hi – I am working on a stategy that buys the3 first green Heikin Ashi candle after X red candles in a row.  Right now the definitions I have scripted are not correctly identifying the candle colors (current  -> want green and prior 1 -> want red).  Current script is attached – any clues as to what I might be doing wrong?

 

Thanks

Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on June 28, 2020 10:19 pm
464 views
0
Private answer

Your code can use quite a bit of refinement. It has the look and feel of code written by an engineer (an engineer from something other than computer science). As such, it would take me far to long to fix this to hit your stated goal.

The good news is that any scan can easily be converted to a strategy.

https://www.hahn-tech.com/thinkorswim-scan-to-strategy/

So I suggest you first look at the examples given in our Stock Scanners topic. Here is one that finds the second consecutive green Heike-Ashi candle after a red candle:

https://www.hahn-tech.com/ans/two-consecutive-green-heikin-ashi-candles/

Use that code as your starting point. Also be sure to examine the structure of the code, such as how the variables are named, and the spacing between variable names and operators. Also note how the index values are used to reference previous values of a variable instead of trying to create an entirely new variable simply to read a previous bar's value. Plenty to learn here. Good luck!

FYI, chart strategies are the most challenging and complicated environments to code. Especially in Thinkorswim where there are no safeguards to prevent you writing statements that produce trading profits impossible to reproduce in a live market. Since you are very new to writing code I highly recommend you ditch the idea of trying to create your own chart strategy until you spend another 6-18 months practicing with basic chart studies and scans.

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on June 29, 2020 9:01 am