Shtick Hustler
Well-known member
- Joined
- Oct 15, 2020
- Posts
- 113
- Likes
- 50
There's probably a better way to do this, but...
Wanted to test my math on a formula I used to create custom data series. Didn't want to bother with setting up RuntimeDescriptors, etc. So created this func.
It will draw a small, colored circle for each bar of data (your eyes can connect them into a path). 'dataKey' refers to either the string key for a custom data series, i.e.: "SMA50", or an enum. It's got the 'Object' or 'Any' type, so be careful to only pass it a String or an Enum. The other args should be self-explanatory.
Call it from within the 'calculate()' func in your study/strat.
Java version
Kotlin version
				
			Wanted to test my math on a formula I used to create custom data series. Didn't want to bother with setting up RuntimeDescriptors, etc. So created this func.
It will draw a small, colored circle for each bar of data (your eyes can connect them into a path). 'dataKey' refers to either the string key for a custom data series, i.e.: "SMA50", or an enum. It's got the 'Object' or 'Any' type, so be careful to only pass it a String or an Enum. The other args should be self-explanatory.
Call it from within the 'calculate()' func in your study/strat.
Java version
void drawUglyPath(DataSeries series, int index, Object dataKey, Color color) {
   if (series.getDouble(index, dataKey) == null) {
      return;
   }
   Enums.Position position = Enums.Position.TOP;
   Double seriesValue = series.getDouble(index, dataKey);
  MarkerInfo mInfo = new MarkerInfo(Enums.MarkerType.CIRCLE, Enums.Size.VERY_SMALL, color, color, true);
     addFigure(
       new Marker(
          new Coordinate(series.getStartTime(index), seriesValue),
                  position,
                  mInfo
                ));
}
Kotlin version
fun drawUglyPath(series: DataSeries, index: Int, dataKey : Any, color: Color) {
    if (series.getDouble(index, dataKey) == null)
       return
    val position = Enums.Position.TOP
    val seriesValue = series.getDouble(index, dataKey)
    val mInfo = MarkerInfo(Enums.MarkerType.CIRCLE, Enums.Size.VERY_SMALL, color, color, true)
        addFigure(
            Marker(
               Coordinate(series.getStartTime(index), seriesValue),
                  position,
                  mInfo
            )
    )
}
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
				 
 
		