Assistance with new +DI high within last 75 candles scan

perseverance_trading1

New member
VIP
Hi Community,

I am attempting to code a new +DI high within last 75 candles on the scanner.

Is there a more efficient way to code this besides comparing the current +DI to each period prior as listed below?

At some point, the number of compares between the periods becomes too great.

I am open to any and all recommendations.

Thank you!



Code:
DIPlus("length" = 13) is greater than DIPlus("length" = 13)[1] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[2] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[3] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[4] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[5] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[6] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[7] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[8] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[9] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[10] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[11] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[12] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[13] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[14] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[15] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[16] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[17] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[18] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[19] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[20] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[21] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[22] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[23] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[24] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[25] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[26] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[27] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[28] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[29] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[30] and

DIPlus("length" = 13) is greater than DIPlus("length" = 13)[31] and DIPlus("length" = 13) is greater than DIPlus("length" = 13)[32]
 
Last edited:

generic

Active member
@perseverance_trading1 Something like this?
Code:
declare lower;

input length = 14;
input high_lookback = 75;
input averageType = AverageType.WILDERS;


plot "DI+" = DMI(length, averageType)."DI+";
"DI+".SetDefaultColor(GetColor(1));

plot high = highest("dI+", high_lookback);
plot newhigh = if "dI+" >= high then "di+" else double.NaN;
newhigh.setpaintingStrategy(paintingStrategy.ARROW_UP);
 
Last edited:

perseverance_trading1

New member
VIP
That's it. I really appreciate your help there @generic.

With much appreciation. ⭐💪🙏

Code:
declare lower;

input length = 14;
input high_lookback = 75;
input averageType = AverageType.WILDERS;


def "DI+" = DMI(length, averageType)."DI+";


def high = highest("dI+", high_lookback);
def newhigh = if "dI+" >= high then "di+" else double.NaN;
plot scan = "dI+" >= high;
 

Similar threads

Top