Nearest Price Level to the Open

rlohmeyer

Member
Hi,

Just looking for coding to define the closest price level to the days open that is an integer divisible by 5.

Is this possible?

Thanks for any help.

Bob
 

OBW

Member
Ruby:
# +------------------------------------------------------------+
# |              Example: Round to the nearest X               |
# |                        Robert Payne                        |
# |               https://funwiththinkscript.com               |
# +------------------------------------------------------------+
input nearest_x = 5;
def daily_open = open(period = AggregationPeriod.DAY);
def round_to_nearest_x = Round(daily_open / nearest_x, 0) * nearest_x;
plot data = round_to_nearest_x;
data.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

X6t5wTP.png
 
Last edited:

Similar threads

Top