How to get the crossing of two different indicators - page 2

 
RaptorUK: OK, they are working on different Y axis scales, I don't see how you can accurately determine a cross and any cross is arbitrary and determined by the Y axis scaling applied to each Indicator.

Because they are different scales, there is no cross. Therefor you map each to the same scale and then look for a cross. But as RaptorUK said, the mapping is arbitrary and determined by which bars are visible.

int iLeft    = WindowFirstVisibleBar(),
    iRight   = iLeft-WindowBarsPerChart();
if(iRight < 0)          iRight = 0;                   // Chart is shifted.
int nBars    = iLeft + iRight + 1;

double stoch[]; ArrayResize(stoch, iLeft+1);          // Get values
double std[];   ArrayResize(std,   iLeft+1);
for(int iBar = iLeft; iBar >= iRight; iBar--){
   stoch[iBar] = ... iBar);
   std[iBar]   = ... iBar);
}
double stochMax = ArrayMaximum(stoch, nBars, iRight), // Compute mapping
       stochMin = ArrayMinimum(
       stdMax   =
       stdMin   =
if(stochMax - stochMin < Point) .. // Avoid div 0
if(  stdMax -   stdMin < Point) .. // Avoid div 0
                                                      // Map to +/- 1
double  stochPrvFrct = (stoch[iRight+1] - stochMin) / (stochMax - stochMin),
        stochCurFrct = (stoch[iRight  ] - stochMin) / (stochMax - stochMin),
        stdPrvFrct   = ..
        stdCurFrct   = ..;
bool    wasAbove     = stochPrvFrct > stdPrvFrct,     // Cross on map.
         isAbove     = stochCurFrct > stdCurFrct,
        cross        = wasAbove != isAbove;
Reason: