Hi,

I need to calculate the stochastic formula on a array, this array is not a indicator buffered array. This is my code:

double

SmallestBuffer[],

LargestBuffer[],

COTIndex[];

int

COTIndexPeriod=13, //similar to Stochastic %K period

position=0;

ArrayResize(SmallestBuffer, ArraySize(Commercial));

ArrayResize(LargestBuffer, ArraySize(Commercial));

ArrayResize(COTIndex, ArraySize(Commercial));

for (i= ArraySize(Commercial)-COTIndexPeriod; i >= 0; i--)

{

position = ArrayMinimum(Commercial, COTIndexPeriod, i+COTIndexPeriod-1);

SmallestBuffer[i] = Commercial[position];

//Print("Smallest: ", SmallestBuffer[i], " Index: ", i);

}

for (i= ArraySize(Commercial)-COTIndexPeriod; i >= 0; i--)

{

position = ArrayMaximum(Commercial, COTIndexPeriod, i+COTIndexPeriod-1);

LargestBuffer[i] = Commercial[position];

//Print("Largest: ", LargestBuffer[i], " Index: ", i);

}

for (i= ArraySize(Commercial)-COTIndexPeriod; i >= 0; i--)

//for (i= ArraySize(Commercial)-1; i > 0; i--)

{

double top = Commercial[i]-SmallestBuffer[i];

double bottom = LargestBuffer[i]-SmallestBuffer[i];

if(bottom == 0.0) //prevent divide by zero errors

{ bottom=100.0; }

COTIndex[i] = (top/bottom)*100;

Print("COTIndex: ", COTIndex[i], " Index: ", i);

ExtMapBuffer1[i] = COTIndex[i]; //graph it

}

So the goal is to have the Stochastic value stored in the COTIndex[i] array. However, the calculated values are in incorrect. Does anyone have a Stochastic-On-Array (iStochOnArray) implementation? or maybe does anyone see where the logical problem is on my code? I'm stuck and would greatly appreciate any help!

Thank you

Mike

I need to calculate the stochastic formula on a array, this array is not a indicator buffered array. This is my code:

double

SmallestBuffer[],

LargestBuffer[],

COTIndex[];

int

COTIndexPeriod=13, //similar to Stochastic %K period

position=0;

ArrayResize(SmallestBuffer, ArraySize(Commercial));

ArrayResize(LargestBuffer, ArraySize(Commercial));

ArrayResize(COTIndex, ArraySize(Commercial));

for (i= ArraySize(Commercial)-COTIndexPeriod; i >= 0; i--)

{

position = ArrayMinimum(Commercial, COTIndexPeriod, i+COTIndexPeriod-1);

SmallestBuffer[i] = Commercial[position];

//Print("Smallest: ", SmallestBuffer[i], " Index: ", i);

}

for (i= ArraySize(Commercial)-COTIndexPeriod; i >= 0; i--)

{

position = ArrayMaximum(Commercial, COTIndexPeriod, i+COTIndexPeriod-1);

LargestBuffer[i] = Commercial[position];

//Print("Largest: ", LargestBuffer[i], " Index: ", i);

}

for (i= ArraySize(Commercial)-COTIndexPeriod; i >= 0; i--)

//for (i= ArraySize(Commercial)-1; i > 0; i--)

{

double top = Commercial[i]-SmallestBuffer[i];

double bottom = LargestBuffer[i]-SmallestBuffer[i];

if(bottom == 0.0) //prevent divide by zero errors

{ bottom=100.0; }

COTIndex[i] = (top/bottom)*100;

Print("COTIndex: ", COTIndex[i], " Index: ", i);

ExtMapBuffer1[i] = COTIndex[i]; //graph it

}

So the goal is to have the Stochastic value stored in the COTIndex[i] array. However, the calculated values are in incorrect. Does anyone have a Stochastic-On-Array (iStochOnArray) implementation? or maybe does anyone see where the logical problem is on my code? I'm stuck and would greatly appreciate any help!

Thank you

Mike