Small code snippet that helps (me) a lot during debugging

Spin

Well-known member
Joined
May 22, 2019
Posts
477
Likes
191
All SDK-users know the hassle: you want to check something (a value, a marker being plotted correctly, a color change, ...) on a specific bar in the past, but you only have the 'index' to work with. So that typically means using the ruler tool extensively or counting bars manually.

But when you import these into your study:
Java:
import java.util.*;
import java.text.*;


And then drop this somewhere in one of your functions
Java:
DataSeries series = ctx.getDataSeries();
long time = series.getStartTime(index);

DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String formatted = format.format(time);

debug (index + " " + formatted  + " someValue = " + someValue);

You get this:
186

And that makes (my) life a lot easier (y)
 
Last edited:
Top