Bullish ADX scripting question

Hi. I’m trying to create a script that will yield a “True” value when:

  1. The code’s ADX trend line is above 20
  2. The code’s ADX trend line has been up each of the past 10 bars
  3. The code’s ADX DMPlus value is greater than the DMMinus value
    I’d think the following script should yield this result:

D1 = GETDATA(CODE=SPX:WI, TIMEFRAME=1 Week);
A1=ADX(D1);
A2=ADX(D1, DEFAULT=DMPlus);
A3=ADX(D1, DEFAULT=DMMinus);
ADX_GT_Thresh = (A1 > 20);
ADX_IsUp = (BARSTRUE(A1() IsUp, LOOKBACK=10) = 10);
DMP_GT_DMM = (A2 > A3);
ADX_Bull = ADX_GT_Thresh and ADX_IsUp and DMP_GT_DMM;
ADX_Bull

However, displaying the script via Show View is not at all yielding the expected result. What am I doing wrong?

Thanks!

Hi Mc,

I think the issue is with the ADX_IsUp variable. A1() should just be A1 as the parentheses are for our functions only, and when dealing with equalities the ‘==’ needs to be used.

Try this and see how you go (although SPX rarely has 10 weeks of rising ADX in a row, so there aren’t that many positive results):

ADX_IsUp = (BARSTRUE(A1 IsUp, LOOKBACK=10) == 10);

Thanks, Darren! It’s working now. Much appreicated…