I want to plot a trading chart with my indicator that is colored depending on its height.
I prepared financial data and data of my indicator:
spy = FinancialData["SPY", "OHLCV", {{2020, 12, 1}, {2020, 12, 10}}];
indicatorData = {{{2020,12,1},1}, {{2020,12,2},2}, {{2020,12,3},3},
{{2020,12,4},-1}, {{2020,12,7},-2}, {{2020,12,8},-3}, {{2020,12,9},1}, {{2020, 12, 10}, 3}};
myIndicator =
FinancialIndicator[TimeSeries[indicatorData] &, "IndexLine" -> 0, "LineStyle" -> Blue, Filling -> 0];
The plot is given by
TradingChart[spy, {myIndicator}]
with "the uniform Blue color" indicator.
It is natural consequence because in myIndicator
I chose "LineStyle" to be Blue
.
Now, I want to change the blue curve to new one that changes its color depending on its value (height). For example, the curve is red when its value is higher than 1, while it is blue when it is lower than 0.
Is it possible to do this?
I tried a simple attempt by changing "LineStyle" -> Blue
to "LineStyle" -> "Rainbow"
, but, this did not work.
This question may be related to my previous question.
Any comment is welcome.
myIndicator = FinancialIndicator[TimeSeries[indicatorData] &, "IndexLine" -> 0, "LineStyle" -> Opacity[0], Filling -> {1 -> {0, {Red, Blue}}}]; TradingChart[spy, {myIndicator}]
? $\endgroup$