strawberry_white
Member
- Joined
- Jan 29, 2020
- Posts
- 8
- Likes
- 2
Hello,
I am trying to code a piece where the price bars (OHLC) on a chart get a color depending on a criteria, such as a moving average. I am used to the EasyLanguage in TradeStation, but not advanced in JAVA.
This is what I have at the moment. When the Close is above a SMA, then the bars should be green, if its below the SMA, they should be red. Thinking it does what I want it to do, but after compiling nothing appears on my chart. Anyone to point out my mistake?
DataSeries series = ctx.getDataSeries();
Double simple_mov_avg = series.sma(index, period, input);
float C ;
C = series.getClose(index);
if (C > simple_mov_avg) {
series.setBarColor(index, X11Colors.GREEN);
} else if (H < simple_mov_avg) {
series.setBarColor(index, X11Colors.RED);
}
I am trying to code a piece where the price bars (OHLC) on a chart get a color depending on a criteria, such as a moving average. I am used to the EasyLanguage in TradeStation, but not advanced in JAVA.
This is what I have at the moment. When the Close is above a SMA, then the bars should be green, if its below the SMA, they should be red. Thinking it does what I want it to do, but after compiling nothing appears on my chart. Anyone to point out my mistake?
DataSeries series = ctx.getDataSeries();
Double simple_mov_avg = series.sma(index, period, input);
float C ;
C = series.getClose(index);
if (C > simple_mov_avg) {
series.setBarColor(index, X11Colors.GREEN);
} else if (H < simple_mov_avg) {
series.setBarColor(index, X11Colors.RED);
}