Adding Up/Down Arrows on Study + Scanner

swetrades

New member
Hi Everyone,

First post on the forum! I found a study that plots the prior day's high/low onto a chart. I find this useful for directional bias intraday. I'm a complete newb when it comes to scripting on ThinkorSwim and wanted to see if it's possible to add Up/Down arrows to the code for the following scenarios below:
  1. Stock crosses above yesterday's high: Up Arrow (Green Color)
  2. Stock crosses above yesterday's low: Up Arrow (Green Color)
  3. Stock crosses below yesterday's high: Down Arrow (Red Color)
  4. Stock crosses below yesterday's low: Down Arrow (Red Color)
How do I create a scanner for these scenarios as well?

Code:
#Study:Common Level
#by thetrader.top
declare hide_on_daily;
declare once_per_bar;

input timeFrame = {default DAY, WEEK, MONTH};

plot high = If(GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN, high(period = timeFrame)[1], Double.NaN);
plot Low = If(GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN, low(period = timeFrame)[1], Double.NaN);

high.SetDefaultColor (Color.GREEN);
high.SetPaintingStrategy(PaintingStrategy.DASHES);
Low.SetDefaultColor(Color.RED);
Low.SetPaintingStrategy(PaintingStrategy.DASHES);
 

Pensar

Well-known member
VIP
@swetrades
Code:
# Study: Common Level
# by thetrader.top
# 06.01.21 - arrows added

declare hide_on_daily;
declare once_per_bar;

input timeFrame = {default DAY, WEEK, MONTH};

plot high = If(GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN, high(period = timeFrame)[1], Double.NaN);
plot Low = If(GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN, low(period = timeFrame)[1], Double.NaN);
plot crossabovehigh = close crosses above high;
plot crossbelowhigh = close crosses below high;
plot crossbelowlow = close crosses below low;
plot crossabovelow = close crosses above low;

high.SetDefaultColor (Color.GREEN);
high.SetPaintingStrategy(PaintingStrategy.DASHES);
Low.SetDefaultColor(Color.RED);
Low.SetPaintingStrategy(PaintingStrategy.DASHES);
crossabovehigh.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
crossabovehigh.setdefaultcolor(color.green);
crossbelowhigh.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
crossbelowhigh.setdefaultcolor(color.yellow);
crossbelowlow.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
crossbelowlow.setdefaultcolor(color.red);
crossabovelow.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
crossabovelow.setdefaultcolor(color.dark_orange);

# end code
 

Similar threads

Top