Stochastic Slope

 

Trying to calculate slope for stochastic, dont know what is is wrong. Getting a wrong value. Please what is wrong with the SlopeStoch variable ? Note , SlopePeriod = 1

  if (CopyBuffer(myStochastic[x], 0, 0, 2, StochMain) != 2) return 0;
        if (CopyBuffer(myStochastic[x], 1, 0, 2, StochSignal) != 2) return 0;
        
        if (CopyBuffer(myCCIe[x], 0, 0, 3, CCI_Entry) != 3) return 0;
        if (CopyBuffer(myCCIt[x], 0, 0, 3, CCI_Trend) != 3) return 0;
        
        bool StochBuy = StochMain[CheckCandle] > StochSignal[CheckCandle] && 
                        StochMain[CheckCandle] <= 19 ? true : false;
         
        bool StochSell = StochSignal[CheckCandle] > StochMain[CheckCandle] && 
                         StochSignal[CheckCandle] >= 81 ? true : false;  
                         
          
         SlopeStoch = (StochMain[0] - StochMain[SlopePeriod]) / SlopePeriod; 

SlopePeriod = 1

if SlopeStoch = (StochMain[0] - StochMain[SlopePeriod]) / SlopePeriod

and lets say count = 20

for ( x=0;x<count;count++){

OriginSlope = (StochMain[0] - StochMain[count]) / count

//for a bullish orign Slope

if (OriginSlope < 0){

return StochMain[count]

}

else if (OriginSlope > 0){

return StochMain[count] }

}

And please i know this is not elegant enough, but what could be wrong with the idea here, trying to get the origin point of a slope in a stochastic oscillator. With the origin point of a slope i can be able to tell if a stochastic crossing is originating from overbought/oversold extreme

Stochastic Oscillator - Oscillators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
The Stochastic Oscillator Technical Indicator compares where a security’s price closed relative to its price range over a given time period. The...
 
Your code
bool StochBuy = StochMain[CheckCandle] > StochSignal[CheckCandle] && 
                StochMain[CheckCandle] <= 19 ? true : false;
         
bool StochSell = StochSignal[CheckCandle] > StochMain[CheckCandle] && 
                 StochSignal[CheckCandle] >= 81 ? true : false;  
Simplified.
bool StochBuy = StochMain[CheckCandle] > StochSignal[CheckCandle] && 
                StochMain[CheckCandle] <= 19;
         
bool StochSell = StochSignal[CheckCandle] > StochMain[CheckCandle] && 
                 StochSignal[CheckCandle] >= 81;
 
Yeah, please my major concern is the SlopeStoch variable. is not giving me the right result @William Roeder
 
The slope depends on the time frame, the zoom of the chart ... It is not an objective criterion, take instead better e.g. the momentum, which is the difference between now and x minutes before.
Reason: