Simple Coding Help - No Promise.

Hey Maruti Thanks for the help But the problem still persists, even after doing the changes nothing shows up on scanner.

I don't know where I am going wrong!
Try this

Code:
TimeFrameSet(in5Minute);
m = L<=BBandBot(C,200,2) AND Ref(L,-1)>Ref(BBandBot(C,200,2),-1);
n = H>=BBandTop(C,200,2) AND Ref(H,-1)<Ref(BBandTop(C,200,2),-1);
TimeFrameRestore();
Bu = TimeFrameExpand(m,in5Minute) ;
Se = TimeFrameExpand(n,in5Minute) ;
Filter = Bu OR Se;
AddColumn(Close,"close");
AddColumn(IIf(Bu, 66,83), "Signal",formatChar, IIf(Bu, colorBlue,colorRed));
Happy :)
 
Hi,

Can it be coded to skip calculation when data is missing ?

Such as
if (V==0) ;
Break;

Have no clues how can this be achieved.

Please, if any one can help here.

Regards
 
Thank you all for your hard work, Amibrocer code for ndx is different than the metatrader version,
what's the problem ?,
I guess the problem could tema in amibroker. please help me and , do fix it. Thank you

//metatrader code for ocean ndx
.
.
.

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

{
double SumWght = 0, SumDnom = 0, DifAry, DnomAry, FracAry, TimeAry, WgtAry;
for(ii = 1; ii <= NDX_period; ii++)
{
DifAry = MathLog(Close[i+ii-1]) - MathLog(Close[i+ii]);
if(ii == 1) DnomAry = MathAbs(DifAry); else DnomAry += MathAbs(DifAry);
if(DnomAry == 0) FracAry = 0; else FracAry = (MathLog(Close) - MathLog(Close[i+ii])) / DnomAry;
TimeAry = 1 / MathPow(ii, 0.5);
WgtAry = FracAry * TimeAry;
SumWght += WgtAry;
SumDnom += TimeAry;
}
RawNDX = 100 * SumWght / SumDnom;
}
double ExpSmooth = 2, XAvg1, XAvg2, XAvg3;
ExpSmooth = ExpSmooth / (SmLen + 1);
for(i = bars - NDX_period - 1; i >= 0; i--)
{
XAvg1 += ExpSmooth * (RawNDX - XAvg1);
XAvg2 += ExpSmooth * (XAvg1 - XAvg2);
XAvg3 += ExpSmooth * (XAvg2 - XAvg3);
maNDX = 3 * XAvg1 - 3 * XAvg2 + XAvg3;
if(i < bars - NDX_period - 1 - 3*SmLen)
{
if(maNDX > 90) NDX = MathRound(90 + (maNDX - 90) / 2);
else if(maNDX < -90) NDX = MathRound(-90 - (MathAbs(maNDX) - 90) / 2);
else NDX = MathRound(maNDX);
}
}

.
.
.

//amibrocer code for ocean ndx

NDX_period = Param("NDX Period",75,40,375);
NDX_SmLen = round(NDX_Period*20/40);


SumWght = 0;
SumDnom = 0;

for(i = 1; i < NDX_period+1; i++)
{
DifAry = ln(Ref(Close,-i+1)) - ln(Ref(Close,-i));
if(i == 1)
DnomAry = abs(DifAry);
else
DnomAry =DNomAry+ abs(DifAry);
FracAry =IIf(DNomAry==0, 0,(ln(Close) - ln(Ref(Close,-i))) / DnomAry);
TimeAry = 1 / (i^( 0.5));
WghtAry = FracAry * TimeAry;
SumWght =SumWght+ WghtAry;
SumDnom =SumDnom+ TimeAry;
}
RawNDX = 100 * SumWght / SumDnom;

TemaNDX= TEMA(RawNDX,NDX_SmLen);

Plot(TemaNDX,"NDX",colorRed,styleLine);




What is the issue ?
The indicator is plotting

thanks for answer , amii ndicator is plotting but not same as metatrader version because i guess tema function in ami not same as this

for(i = bars - NDX_period - 1; i >= 0; i--)
{
XAvg1 += ExpSmooth * (RawNDX - XAvg1);
XAvg2 += ExpSmooth * (XAvg1 - XAvg2);
XAvg3 += ExpSmooth * (XAvg2 - XAvg3);
maNDX = 3 * XAvg1 - 3 * XAvg2 + XAvg3;
if(i < bars - NDX_period - 1 - 3*SmLen)
{
if(maNDX > 90) NDX = MathRound(90 + (maNDX - 90) / 2);
else if(maNDX < -90) NDX = MathRound(-90 - (MathAbs(maNDX) - 90) / 2);
else NDX = MathRound(maNDX);
}
}

.

and i cant write this function , please write this as a function and i call instead of tema function , please help thanks and sorry for bad english because english is not my native language ,
 
thanks for answer , amii ndicator is plotting but not same as metatrader version because i guess tema function in ami not same as this

for(i = bars - NDX_period - 1; i >= 0; i--)
{
XAvg1 += ExpSmooth * (RawNDX - XAvg1);
XAvg2 += ExpSmooth * (XAvg1 - XAvg2);
XAvg3 += ExpSmooth * (XAvg2 - XAvg3);
maNDX = 3 * XAvg1 - 3 * XAvg2 + XAvg3;
if(i < bars - NDX_period - 1 - 3*SmLen)
{
if(maNDX > 90) NDX = MathRound(90 + (maNDX - 90) / 2);
else if(maNDX < -90) NDX = MathRound(-90 - (MathAbs(maNDX) - 90) / 2);
else NDX = MathRound(maNDX);
}
}

.

and i cant write this function , please write this as a function and i call instead of tema function , please help thanks and sorry for bad english because english is not my native language ,


or please write this code as a function , than i use it istead of TEMA

XAvg1 += ExpSmooth * (RawNDX - XAvg1);
XAvg2 += ExpSmooth * (XAvg1 - XAvg2);
XAvg3 += ExpSmooth * (XAvg2 - XAvg3);
maNDX = 3 * XAvg1 - 3 * XAvg2 + XAvg3;
 
TimeFrameSet(in5Minute);
m = L<=BBandBot(C,200,2) AND Ref(L,-1)>Ref(BBandBot(C,200,2),-1);
n = H>=BBandTop(C,200,2) AND Ref(H,-1)<Ref(BBandTop(C,200,2),-1);
TimeFrameRestore();

Bu = m ;
Se = n ;
Buy=Bu;
Sell=Se;
Filter =Buy OR Sell;

AddColumn(DateTime(),"Date/time",formatDateTime);
AddColumn(Bu,"Support Entry",colorBlack,1.2);
AddColumn(Se, "Resistance sell",colorBlack,1.2);

It is working fine in my PC my ami is 5.60;
Please repaist the AFL in formula editor and then pick for the analysis
It should work, there is no any problem.
otherwise go to filter col. in AA window and choose market255 it will work.

Maruti Mane
Try this
www.wises tock trader.com/indicators/2627-bollinger-band-using-std-dev-and-ma(remove spaces in between)
Try this

Code:
TimeFrameSet(in5Minute);
m = L<=BBandBot(C,200,2) AND Ref(L,-1)>Ref(BBandBot(C,200,2),-1);
n = H>=BBandTop(C,200,2) AND Ref(H,-1)<Ref(BBandTop(C,200,2),-1);
TimeFrameRestore();
Bu = TimeFrameExpand(m,in5Minute) ;
Se = TimeFrameExpand(n,in5Minute) ;
Filter = Bu OR Se;
AddColumn(Close,"close");
AddColumn(IIf(Bu, 66,83), "Signal",formatChar, IIf(Bu, colorBlue,colorRed));
Happy :)

Guys Thank You for Helping Out..... You guys are best.

There was nothing wrong with any of our codes.... Real solution is this.

I was supposed to change time frame in setting it is set to daily by default, I changed it to 5 min n things are working fine.
That's it.

P.s. : @Happy_Singh thank's for making the scan look more presentable.
 

KelvinHand

Well-Known Member
please help me guys and solve my prolom , thanks
you are giving a partial MT code, not the full working version for the expert to try out.
MT4 is not simply to just see your code and convert just like that.
So not one want to waste the precious time to figure out.
 
Last edited:
Hello Friends

I am starting this thread for helping anyone who requires small changes in AFLs or AFL coding done for small / simple requirements that can be clearly defined.

What does not go is conversion . . . from Amibroker to anything else . . . or from anything else to Amibroker . . .

Debugging requested for copy/paste AFLs, Please don't post huge AFLs with zillions of lines of code for debugging

I will not be available for any conversions and I am not interested in debugging some-one else's copy/pasted work and lastly . . .
Not interested in hacking/craking any ones work . . .

Only if have a clearly definable task to be coded I maybe able to help . . . No Promises but will try within my limitations . . .


As an example, recently one of our friends wanted a motivational message to be included in his Charts,
I enjoyed doing that, as i could easily empathize with why he wanted that . . .


Cheers

:) Happy
Hi,
Could you please help me in converting this code into amibroker afl. thanks and appreciate your help.

-Krishna
//+------------------------------------------------------------------+
//| SuperWoodiesCCI.mq4 |
//| duckfu |
//| http://www.dopeness.org |
//+------------------------------------------------------------------+
#property copyright "duckfu"
#property link "http://www.dopeness.org"

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 White // CCI Colour (note the superfluous vowel, cheers mates ;)
#property indicator_color2 Yellow // TCCI Colour
#property indicator_color3 LimeGreen // Long Trend Histogram Colour
#property indicator_color4 Red // Short Trend Histogram Colour
#property indicator_color5 Blue // No Trend Histogram Colour
//---- input parameters
extern int CCI_Period=50;
extern int TCCI_Period=0;
//---- buffers
double ExtCCIBuffer[];
double ExtTCCIBuffer[];
double ExtLongHistBuffer[];
double ExtShortHistBuffer[];
double ExtFlatHistBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init(){
//---- indicators
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0,ExtCCIBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtTCCIBuffer);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexBuffer(2,ExtLongHistBuffer);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexBuffer(3,ExtShortHistBuffer);
SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexBuffer(4,ExtFlatHistBuffer);
ArrayInitialize(ExtCCIBuffer,0);
ArrayInitialize(ExtTCCIBuffer,0);
ArrayInitialize(ExtLongHistBuffer,0);
ArrayInitialize(ExtShortHistBuffer,0);
ArrayInitialize(ExtFlatHistBuffer,0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit(){
//---- TODO: add your code here

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start(){
int i,j,limit,counted_bars=IndicatorCounted();
int uptrending=0,downtrending=0;
//---- TODO: add your code here
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- main loop
for(i=0; i<limit; i++){
ExtCCIBuffer=iCCI(NULL,0,CCI_Period,PRICE_TYPICAL,i);
ExtTCCIBuffer=iCCI(NULL,0,TCCI_Period,PRICE_TYPICAL,i);
ExtFlatHistBuffer=ExtCCIBuffer;
}

for(i=0;i<limit;i++){
for(j=0;j<6;j++){
if(ExtCCIBuffer[i+j] > 0){
uptrending++;
} else if(ExtCCIBuffer[i+j] < 0){
uptrending=0;
}
}

if(uptrending>5){
ExtLongHistBuffer=ExtCCIBuffer;
ExtShortHistBuffer=0;
ExtFlatHistBuffer=0;
}
}

for(i=0;i<limit;i++){
for(j=0;j<6;j++){
if(ExtCCIBuffer[i+j] < 0){
downtrending++;
} else if(ExtCCIBuffer[i+j] > 0){
downtrending=0;
}
}

if(downtrending>5){
ExtShortHistBuffer=ExtCCIBuffer;
ExtLongHistBuffer=0;
ExtFlatHistBuffer=0;
}
}
return(0);


}
//+------------------------------------------------------------------+
 
Last edited:

Similar threads