# Need a Better Moving Average? Try the NMA - page 5

43

"Sorry, ....could you add ocean fast moving average y ocean slow moving average to this indicator ocean natural moving average(make like oscilator). "

Sorry for the inconvenience ... but natural OCN average, there are a few posts ago, and fast and slow OCN average were made with "some" time ago, along with "OCN NMM", "OCN NMS", "OCN NMR ".

Thanks. :):)

65528

Sorry, but I fail to understand : what does fast NMA (and the rest of stuff I made from the ocean pack) have to do with ocean BTX and STX?

If you can provide the math formula how they (BTX and STX) are calculated I will be glad to assist, otherwise it would be just a wild guessing game as of what they are

43

here you have the site(web), width OCEAN, BTX Y stx of ocean.

Ocean Educational Charts

Ocean Studies, Parts 5-8 (Triple STX)

OceanTools Explained 14mi video

Take o look.:)

43

Code:

#property indicator_separate_window

#property indicator_buffers 4

#property indicator_color1 Magenta

#property indicator_color2 Silver

#property indicator_color3 Silver

#property indicator_color4 Silver

#property indicator_level1 35

#property indicator_levelcolor Gray

#property indicator_levelstyle 2

#property indicator_minimum 0

#property indicator_maximum 100

extern int BTX_period = 40;

extern int SmLen = 20;

extern double JMA_Length = 10;

extern int JMA_Phase = 50;

extern int MaxBars = 0;

extern bool Show_SD = true;

extern int SD_len = 20;

extern double SD_up = 1.5;

extern double SD_dn = 1.5;

extern bool Show_SD_up = true;

extern bool Show_SD_dn = true;

extern bool Show_SD_md = true;

double BTX[];

double SD[];

double SD2[];

double SD3[];

double RawBTX[];

double maBTX[];

double fC0Buffer[];

double fA8Buffer[];

double fC8Buffer[];

double list[128], ring1[128], ring2[11], buffer[62];

bool initFlag;

int limitValue, startValue, loopParam, loopCriteria;

int cycleLimit, highLimit, counterA, counterB;

double cycleDelta, lowDValue, highDValue, absValue, paramA, paramB;

double phaseParam, logParam, JMAValue, series, sValue, sqrtParam, lengthDivider;

int s58, s60, s40, s38, s68;

bool initialized;

#import "OBP1Lock32x.dll"

bool LTInitializeFromInix(string);

double LTCalcValx(string, double, double, double, double, string);

#define dll "OBP1Lock32.dll"

#import

double arr6[99], arr7[99], arr8[99], arr9[99], arr10[99], arr11[99];

int init()

{

initialized = LTInitializeFromInix(dll);

if(!initialized) return(0);

if(SmLen < 1) SmLen = 1;

if(BTX_period > 98) BTX_period = 98;

string btxname = "BTX(" + BTX_period + ", " + SmLen + ")";

if(Use_JMA_instead_TEMA) btxname = "BTX_JMA(" + BTX_period + ", " + JMA_Length + ", " + JMA_Phase + ")";

IndicatorShortName(btxname);

IndicatorDigits(2);

IndicatorBuffers(6);

SetIndexBuffer(0, BTX);

SetIndexLabel(0, btxname);

SetIndexBuffer(1, SD);

SetIndexBuffer(2, SD2);

SetIndexBuffer(3, SD3);

if(Show_SD_up) SetIndexLabel(1, "BTX_SD_up(" + SD_len + ")");

else SetIndexLabel(1, "unused");

if(Show_SD_dn) SetIndexLabel(2, "BTX_SD_dn(" + SD_len + ")");

else SetIndexLabel(2, "unused");

if(Show_SD_md) SetIndexLabel(3, "BTX_SD_md(" + SD_len + ")");

else SetIndexLabel(3, "unused");

SetIndexBuffer(4, RawBTX);

SetIndexBuffer(5, maBTX);

ArraySetAsSeries(arr6, true); ArraySetAsSeries(arr7, true); ArraySetAsSeries(arr8, true);

ArraySetAsSeries(arr9, true); ArraySetAsSeries(arr10, true); ArraySetAsSeries(arr11, true);

return(0);

}

43

int start()

{

if(!initialized) return(0);

int limit, i, ii, counted_bars = IndicatorCounted()-1, bars;

if(MaxBars > 0) { bars = MaxBars; if(counted_bars > bars) counted_bars = bars - 2; } else bars = Bars;

if(Use_JMA_instead_TEMA) { if(bars <= BTX_period + JMA_Length) return(0); }

else { if(bars <= BTX_period + 3*SmLen) return(0); }

if(counted_bars < 0) counted_bars = 0;

if(counted_bars > BTX_period) limit = bars - counted_bars;

else limit = bars - BTX_period - 1;

for(i = limit; i >= 0; i--)

{

double var2 = 0, var3 = 0;

ArrayInitialize(arr6, 0); ArrayInitialize(arr7, 0); ArrayInitialize(arr8, 0);

ArrayInitialize(arr9, 0); ArrayInitialize(arr10, 0); ArrayInitialize(arr11, 0);

arr6[0] = LTCalcValx(dll, Close, 0.5, High, Low, "eBBcmGJhfe");

for(ii = 1; ii <= BTX_period; ii++)

{

arr6 = LTCalcValx(dll, Close, Close, 0.5, Close, "FpmqUGJh");

arr7 = LTCalcValx(dll, arr6, arr6, Close, 0.5, "rmEsGMDfF");

arr8 = LTCalcValx(dll, arr8, (arr7), arr8, arr7, "smUDecGMJYh");

if(arr8 == 0) arr9 = 0;

else arr9 = LTCalcValx(dll, arr6[0], arr6, arr8, arr7, "rUGMecDJYBBXU");

arr10 = 1 / LTCalcValx(dll, 0.5, ii, arr9, -MathAbs(arr9), "UhWGceMBBJn");

arr11 = LTCalcValx(dll, arr9, arr10, arr9, arr8, "F3ecmGBBMqec");

var2 = LTCalcValx(dll, var2, arr11, arr11, var2, "ceGMhftTds");

var3 = LTCalcValx(dll, var3, arr10, var2, var3, "jTGceMBBh");

}

RawBTX = LTCalcValx(dll, var2, var3, 100, 0.5, "mUDF0AA8GMUXBBq");

}

{

double ExpSmooth = 2, XAvg1, XAvg2, XAvg3;

ExpSmooth = ExpSmooth / (SmLen + 1);

for(i = bars - BTX_period - 1; i >= 0; i--)

{

XAvg1 += ExpSmooth * (RawBTX - XAvg1);

XAvg2 += ExpSmooth * (XAvg1 - XAvg2);

XAvg3 += ExpSmooth * (XAvg2 - XAvg3);

maBTX = 3 * XAvg1 - 3 * XAvg2 + XAvg3;

if(i < bars - BTX_period - 1 - 3*SmLen)

BTX = NormalizeDouble(maBTX, 2);

}

}

else

{

ArrayResize(fC0Buffer, bars - BTX_period); ArraySetAsSeries(fC0Buffer, true); ArrayInitialize(fC0Buffer, 0);

ArrayResize(fA8Buffer, bars - BTX_period); ArraySetAsSeries(fA8Buffer, true); ArrayInitialize(fA8Buffer, 0);

ArrayResize(fC8Buffer, bars - BTX_period); ArraySetAsSeries(fC8Buffer, true); ArrayInitialize(fC8Buffer, 0);

ArrayInitialize(list, 0);

initFlag = false;

limitValue = 0; startValue = 0; loopParam = 0; loopCriteria = 0;

cycleLimit = 0; highLimit = 0; counterA = 0; counterB = 0;

cycleDelta = 0; lowDValue = 0; highDValue = 0; absValue = 0; paramA = 0; paramB = 0;

phaseParam = 0; logParam = 0; JMAValue = 0; series = 0; sValue = 0; sqrtParam = 0; lengthDivider = 0;

s58 = 0; s60 = 0; s40 = 0; s38 = 0; s68 = 0;

ArrayInitialize(ring2, 0);

ArrayInitialize(ring1, 0);

ArrayInitialize(buffer, 0);

double lengthParam;

limitValue = 63;

startValue = 64;

for(i = 0; i <= limitValue; i++) list = -1000000;

for(i = startValue; i <= 127; i++) list = 1000000;

initFlag = true;

if(JMA_Length < 1.0000000002) lengthParam = 0.0000000001;

else lengthParam = (JMA_Length - 1) / 2.0;

if(JMA_Phase < -100) phaseParam = 0.5;

else if(JMA_Phase > 100) phaseParam = 2.5;

else phaseParam = JMA_Phase / 100.0 + 1.5;

logParam = MathLog(MathSqrt(lengthParam)) / MathLog(2.0);

if(logParam + 2.0 < 0) logParam = 0;

else logParam = logParam + 2.0;

sqrtParam = MathSqrt(lengthParam) * logParam;

lengthParam = lengthParam * 0.9;

lengthDivider = lengthParam / (lengthParam + 2.0);

for(i = bars - BTX_period - 1; i >= 0; i--)

{

jma(RawBTX, maBTX, i);

if(i < bars - BTX_period - 1 - JMA_Length)

BTX = NormalizeDouble(maBTX, 2);

}

}

int limitx;

if(!Use_JMA_instead_TEMA) limitx = bars - BTX_period - 1 - 3*SmLen;

else limitx = bars - BTX_period - 1 - JMA_Length;

if(Show_SD)

for(i = limit; i >= 0; i--)

if(i < limitx - SD_len)

{

if(Show_SD_up) SD = iBandsOnArray(BTX, 0, SD_len, SD_up, 0, MODE_UPPER, i);

if(Show_SD_dn) SD2 = iBandsOnArray(BTX, 0, SD_len, SD_dn, 0, MODE_LOWER, i);

if(Show_SD_md) SD3 = (iBandsOnArray(BTX, 0, SD_len, SD_up, 0, MODE_UPPER, i)+

iBandsOnArray(BTX, 0, SD_len, SD_dn, 0, MODE_LOWER, i)) / 2;

}

return(0);

}

65528

That is not tradestation code but a metatrader code using a hacked OBP1Lock32x.dll and has nothing with calculation formula. I asked a calculation formula not a hacked code (I hope that I do not have to remind that calculation formula is not the same thing as hacked code)

All the best

corinali:

Code:

#property indicator_separate_window

#property indicator_buffers 4

#property indicator_color1 Magenta

#property indicator_color2 Silver

#property indicator_color3 Silver

#property indicator_color4 Silver

#property indicator_level1 35

#property indicator_levelcolor Gray

#property indicator_levelstyle 2

#property indicator_minimum 0

#property indicator_maximum 100

extern int BTX_period = 40;

extern int SmLen = 20;

extern double JMA_Length = 10;

extern int JMA_Phase = 50;

extern int MaxBars = 0;

extern bool Show_SD = true;

extern int SD_len = 20;

extern double SD_up = 1.5;

extern double SD_dn = 1.5;

extern bool Show_SD_up = true;

extern bool Show_SD_dn = true;

extern bool Show_SD_md = true;

double BTX[];

double SD[];

double SD2[];

double SD3[];

double RawBTX[];

double maBTX[];

double fC0Buffer[];

double fA8Buffer[];

double fC8Buffer[];

double list[128], ring1[128], ring2[11], buffer[62];

bool initFlag;

int limitValue, startValue, loopParam, loopCriteria;

int cycleLimit, highLimit, counterA, counterB;

double cycleDelta, lowDValue, highDValue, absValue, paramA, paramB;

double phaseParam, logParam, JMAValue, series, sValue, sqrtParam, lengthDivider;

int s58, s60, s40, s38, s68;

bool initialized;

#import "OBP1Lock32x.dll"

bool LTInitializeFromInix(string);

double LTCalcValx(string, double, double, double, double, string);

#define dll "OBP1Lock32.dll"

#import

double arr6[99], arr7[99], arr8[99], arr9[99], arr10[99], arr11[99];

int init()

{

initialized = LTInitializeFromInix(dll);

if(!initialized) return(0);

if(SmLen < 1) SmLen = 1;

if(BTX_period > 98) BTX_period = 98;

string btxname = "BTX(" + BTX_period + ", " + SmLen + ")";

if(Use_JMA_instead_TEMA) btxname = "BTX_JMA(" + BTX_period + ", " + JMA_Length + ", " + JMA_Phase + ")";

IndicatorShortName(btxname);

IndicatorDigits(2);

IndicatorBuffers(6);

SetIndexBuffer(0, BTX);

SetIndexLabel(0, btxname);

SetIndexBuffer(1, SD);

SetIndexBuffer(2, SD2);

SetIndexBuffer(3, SD3);

if(Show_SD_up) SetIndexLabel(1, "BTX_SD_up(" + SD_len + ")");

else SetIndexLabel(1, "unused");

if(Show_SD_dn) SetIndexLabel(2, "BTX_SD_dn(" + SD_len + ")");

else SetIndexLabel(2, "unused");

if(Show_SD_md) SetIndexLabel(3, "BTX_SD_md(" + SD_len + ")");

else SetIndexLabel(3, "unused");

SetIndexBuffer(4, RawBTX);

SetIndexBuffer(5, maBTX);

ArraySetAsSeries(arr6, true); ArraySetAsSeries(arr7, true); ArraySetAsSeries(arr8, true);

ArraySetAsSeries(arr9, true); ArraySetAsSeries(arr10, true); ArraySetAsSeries(arr11, true);

return(0);

}
43

double jma(double& input[], double& output[], int shift)

{

series = input[shift];

if(loopParam < 61)

{

loopParam++;

buffer[loopParam] = series;

}

if(loopParam > 30)

{

if(initFlag)

{

initFlag = false;

int diffFlag = 0;

for(int i = 1; i <= 29; i++)

if(buffer != buffer) diffFlag = 1;

highLimit = diffFlag * 30;

if(highLimit == 0) paramB = series;

else paramB = buffer[1];

paramA = paramB;

if(highLimit > 29) highLimit = 29;

}

else

highLimit = 0;

for(i = highLimit; i >= 0; i--)

{

if(i == 0) sValue = series; else sValue = buffer [31 - i];

if(MathAbs(sValue - paramA) > MathAbs(sValue - paramB)) absValue = MathAbs(sValue - paramA); else absValue = MathAbs(sValue - paramB);

double dValue = absValue + 0.0000000001;

if(counterA <= 1) counterA = 127; else counterA--;

if(counterB <= 1) counterB = 10; else counterB--;

if(cycleLimit < 128) cycleLimit++;

cycleDelta += (dValue - ring2[counterB]);

ring2[counterB] = dValue;

if(cycleLimit > 10) highDValue = cycleDelta / 10.0; else highDValue = cycleDelta / cycleLimit;

if(cycleLimit > 127)

{

dValue = ring1[counterA];

ring1[counterA] = highDValue;

s68 = 64; s58 = s68;

while(s68 > 1)

{

if(list[s58] < dValue)

{

s68 = s68 / 2.0;

s58 += s68;

}

else if(list[s58] == dValue)

s68 = 1;

else

{

s68 = s68 / 2.0;

s58 -= s68;

}

}

}

else

{

ring1[counterA] = highDValue;

if((limitValue + startValue) > 127)

{

startValue--;

s58 = startValue;

}

else

{

limitValue++;

s58 = limitValue;

}

if(limitValue > 96) s38 = 96; else s38 = limitValue;

if(startValue < 32) s40 = 32; else s40 = startValue;

}

s68 = 64;

s60 = s68;

while(s68 > 1)

{

if(list[s60] >= highDValue)

{

if(list[s60 - 1] <= highDValue)

s68 = 1;

else

{

s68 = s68 / 2.0;

s60 -= s68;

}

}

else

{

s68 = s68 / 2.0;

s60 += s68;

}

if((s60 == 127) && (highDValue > list[127])) s60 = 128;

}

if(cycleLimit > 127)

{

if(s58 >= s60)

{

if(((s38 + 1) > s60) && ((s40 - 1) < s60))

lowDValue += highDValue;

else if((s40 > s60) && ((s40 - 1) < s58))

lowDValue += list[s40 - 1];

}

else if(s40 >= s60)

{

if(((s38 + 1) s58))

lowDValue += list[s38 + 1];

}

else if((s38 + 2) > s60)

lowDValue += highDValue;

else if(((s38 + 1) s58))

lowDValue += list[s38 + 1];

if(s58 > s60)

{

if(((s40 - 1) s58))

lowDValue -= list[s58];

else if((s38 s60))

lowDValue -= list[s38];

}

else

{

if(((s38 + 1) > s58) && ((s40 - 1) < s58))

lowDValue -= list[s58];

else if((s40 > s58) && (s40 < s60))

lowDValue -= list[s40];

}

}

if(s58 <= s60)

{

if(s58 >= s60) list[s60] = highDValue;

else

{

for(int j = s58 + 1; j <= (s60 - 1); j++)

list[j - 1] = list[j];

list[s60 - 1] = highDValue;

}

}

else

{

for(j = s58 - 1; j >= s60; j--)

list[j + 1] = list[j];

list[s60] = highDValue;

}

if(cycleLimit <= 127)

{

lowDValue = 0;

for(j = s40; j <= s38; j++)

lowDValue += list[j];

}

if((loopCriteria + 1) > 31) loopCriteria = 31; else loopCriteria++;

double JMATempValue, sqrtDivider = sqrtParam / (sqrtParam + 1.0);

if(loopCriteria <= 30)

{

if(sValue - paramA > 0) paramA = sValue; else paramA = sValue - (sValue - paramA) * sqrtDivider;

if(sValue - paramB < 0) paramB = sValue; else paramB = sValue - (sValue - paramB) * sqrtDivider;

JMATempValue = series;

if(loopCriteria == 30)

{

fC0Buffer[shift] = series;

int intPart;

if(MathCeil(sqrtParam) >= 1) intPart = MathCeil(sqrtParam); else intPart = 1;

int leftInt = IntPortion(intPart);

if(MathFloor(sqrtParam) >= 1) intPart = MathFloor(sqrtParam); else intPart = 1;

int rightPart = IntPortion (intPart);

if(leftInt == rightPart) dValue = 1.0;

else dValue = (sqrtParam - rightPart) / (leftInt - rightPart);

if(rightPart <= 29) int upShift = rightPart; else upShift = 29;

if(leftInt <= 29) int dnShift = leftInt; else dnShift = 29;

fA8Buffer[shift] = (series - buffer[loopParam - upShift]) * (1 - dValue) / rightPart + (series - buffer[loopParam - dnShift]) * dValue / leftInt;

}

}

else

{

double powerValue, squareValue;

dValue = lowDValue / (s38 - s40 + 1);

if(0.5 <= logParam - 2.0) powerValue = logParam - 2.0;

else powerValue = 0.5;

if(logParam >= MathPow(absValue/dValue, powerValue)) dValue = MathPow(absValue/dValue, powerValue); else dValue = logParam;

if(dValue < 1) dValue = 1;

powerValue = MathPow(sqrtDivider, MathSqrt (dValue));

if(sValue - paramA > 0) paramA = sValue; else paramA = sValue - (sValue - paramA) * powerValue;

if(sValue - paramB < 0) paramB = sValue; else paramB = sValue - (sValue - paramB) * powerValue;

}

}

if(loopCriteria > 30)

{

JMATempValue = output[shift + 1];

powerValue = MathPow(lengthDivider, dValue);

squareValue = MathPow(powerValue, 2);

fC0Buffer[shift] = (1 - powerValue) * series + powerValue * fC0Buffer[shift + 1];

fC8Buffer[shift] = (series - fC0Buffer[shift]) * (1 - lengthDivider) + lengthDivider * fC8Buffer[shift + 1];

fA8Buffer[shift] = (phaseParam * fC8Buffer[shift] + fC0Buffer[shift] - JMATempValue) *

(powerValue * (-2.0) + squareValue + 1) + squareValue * fA8Buffer[shift + 1];

JMATempValue += fA8Buffer[shift];

}

JMAValue = JMATempValue;

}

if(loopParam <= 30) JMAValue = 0;

output[shift] = JMAValue;

}

int IntPortion(double param)

{

if (param > 0) return (MathFloor (param));

if (param < 0) return (MathCeil (param));

return (0);

}

43

ocn BTX

I have to put in 3 parts, could you make for Metatrader 4.

65528