AVWAP Pinch Script - VERGENCE Issue

Hi,

I’m trying to create a AVWAP Pinch script and am having some issues.

The AVWAP’s are calculated from last 3 months high and low.

The three conditions are;

  1. The high and low AVWAP's are within 10% of each other with the high AVWAP above the low AVWAP (first signal).
  2. The high and low AVWAP's converge for the next 5 bars from the first signal (second signal).
  3. The CLOSE() is still within the high and low AVWAP's after the second signal
I think it might be an issue with the lookback period for the VERGENCE and then the CLOSE after the VERGENCE. Can I reference the look back period to V4 and then sequence the S3 then S4 then S5?
//Set the look back period from the last bar eg 63 bars for 3 months 
V1 = BARINDEX()==LAST(BARINDEX())-63;
//Find high and low signal dates in the look back period
S1 = HIGH() == HIGHESTSINCE(V1); 
S2 = LOW() == LOWESTSINCE(V1); 
//Remove non trading days, non zero results, showing most recent result as latest value 
V2 = BarDate(NonZero(S1)); 
V3 = BarDate(NonZero(S2)); 
//Calculate AVWAP's from signal dates 
C1 = AVWAP(BACKTYPE=Fixed, DATE=V2); 
C2 = AVWAP(BACKTYPE=Fixed, DATE=V3); 
//Calculate $ difference between high and low AVWAP
C3 = C1-C2; 
//Calculate the % difference between high and low AVWAP
C4 = C3/C1; 
//Is the differece between high and low AVWAP's less than 10% and greater than 0% 
S3 = C4 >= 10 and C4 <= 0; 
// Bar Date of S3 signal 
V4 = BARDATE(S3); 
//AVWAP's converging for next 5 days from S3 signal
S4 = VERGENCE(C1,C2,, LOOKBACK=5) 
//Close withing high and low AVWAPS
S5 = CLOSE() <C1 and >C2; 

S3 and S4 and S5


            

Hi Tim,

I haven’t tested this, but C4 needs to be multiplied by 100 to make it in to a percentage. Also, S3 has the signs the wrong way round:

//Calculate the % difference between high and low AVWAP
C4 = C3/C *100;
//Is the differece between high and low AVWAP’s less than 10% and greater than 0%
S3 = C4 <= 10 and C4 >= 0;