Action based on the color of an indicator or candlestick
First I apologize for not having any code already for this. I've looked and all I can find are examples on how to change the color of a candle or indicator. I would like to create a strategy based on the color of either an indicator or a price bar / candlestick, but for the life of me I cannot find what I need to call to be able to do that.
In short something like:
IF (BarColor == "Green")
IF (IndicatorPlot == "Green")
Any help is appreciated and again I apologize if it looks like I haven't done any research.... I have - I just have nothing to show for it.
First, you have to identify what is making the bar color green / red. That's the key.
Example: say you have an indicator that colors the bar green if price closes above the 20 EMA or Red if price closes below the 20 EMA. The code in the indicator would look something like:
if(Close>EMA(20)) BarColor = Color.Green.
if(Close<EMA(20)) BarColor = Color.Red.
It's the code of the indicator that's coloring the bar in this example. So the strategy would have to be coded:
If(Close>EMA(20)) EnterLong(DefaultQuantity, ""); (for long buy)
if(Close<EMA(20)) EnterShort(DefaultQuantity, ""); (for short sell)
Something like that. Can you be specific as to what it is you want to do when such and such a condition occurs?
More information is needed in order to provide a specific answer.
After all, it's what you learn AFTER you know it all, that counts!
The following 3 users say Thank You to TheWizard for this post: