Simple Coding Help - No Promise.

Hi and Thanks coder
can anyone optimize or update this code for amibroker 6 and upper with iir and other new function
Thanks
Adaptive macd
Code:
//A new MACD Indicator KMACD Version V.1.0
// By Karthik Marar - www.karthikmarar.blogspot.com
// Public release for personal use only.
//Please do not commercialize this indicator in its original or modified form
_SECTION_BEGIN("Dominant Period");
   
    SetBarsRequired( 1000, 1000);
    prc = ( High + Low ) / 2;
    Cyclepart = 0.7 ;
    pi=4*atan(1);
    RTD=180/pi;
    DTR=pi/180;
    
    Smooth[0] = Detrender[0] = I1[0] = Q1[0] = jI[0] = jQ[0] = I2[0] = I3[0] = Q3[0] = Q2[0] = Re[0] = Re1[0] =Im[0] = Im1[0] = 0;
    Period[0] = Period1[0] = alpha = cycle = SmoothPeriod[0] = imagpart[0] = realpart[0] = DCPhase[0] = 0;
    for ( i = 6; i < BarCount; i++ )
    {
    Smooth[i] = ( 4 * prc[i] + 3 * prc[i-1] + 2 * prc[i-2] + prc[i-3] ) / 10;
    Cycle[i] = ((1-0.5*alpha[i])^2)*(Smooth[i] - 2*Smooth[i-1] + Smooth[i-2]) + 2*(1-alpha[i])*Cycle[i-1] - ((1-alpha[i])^2)*Cycle[i-2];
    AmpCorr[i] = 0.075 * Period[i-1] + 0.54;
    Detrender[i] = ( 0.0962 * Smooth[i] + 0.5769 * Smooth[i-2] - 0.5769 * Smooth[i-4] - 0.0962 * Smooth[i-6] ) * AmpCorr[i];
    Q1[i] = ( 0.0962 * Detrender[i] + 0.5769 * Detrender[i-2] - 0.5769 * Detrender[i-4] - 0.0962 * Detrender[i-6] ) * AmpCorr[i];
    I1[i] = Detrender[i-3];
    jI[i] = ( 0.0962 * I1[i] + 0.5769 * I1[i-2] - 0.5769 * I1[i-4] - 0.0962 * I1[i-6] ) * AmpCorr[i];
    jQ[i] = ( 0.0962 * Q1[i] + 0.5769 * Q1[i-2] - 0.5769 * Q1[i-4] - 0.0962 * Q1[i-6] ) * AmpCorr[i];
    I2[i] = I1[i] - jQ[i];
    Q2[i] = Q1[i] + jI[i];
    I3[i] = 0.2 * I2[i] + 0.8 * I3[i-1];
    Q3[i] = 0.2 * Q2[i] + 0.8 * Q3[i-1];
    Re[i] = I3[i] * I3[i-1] + Q3[i] * Q3[i-1];
    Im[i] = I3[i] * Q3[i-1] - Q3[i] * I3[i-1];
    Re1[i] = 0.2 * Re[i] + 0.8 * Re1[i-1];
    Im1[i] = 0.2 * Im[i] + 0.8 * Im1[i-1];
    {
    if ( Im1[i] != 0 AND Re1[i] != 0 )    Period1[i] = 360*DTR / atan( Im1[i] / Re1[i] );
    else
    Period1[i] = Period1[i-1];
    }
    {
    if ( Period1[i] > 1.5 * Period1[i-1] )  Period2[i] = 1.5 * Period1[i-1];
    else
    {
    if ( Period1[i] < 0.67 * Period1[i-1] ) Period2[i] = 0.67 * Period1[i-1];
    else
    Period2[i] = Period1[i]; 
    } 
    }
    {
    if ( Period2[i] < 6 )    Period3[i] = 6;
    else
    {
    if ( Period2[i] > 50 )   Period3[i] = 50;
    else
    period3[i]=Period2[i];
    }
    }
    Period[i] = 0.2 * Period3[i] + 0.8 * Period[i-1];
    SmoothPeriod[i] = 0.33 * Period[i] + 0.67 * SmoothPeriod[i-1];
    DCPeriod[i] = int(SmoothPeriod[i]+0.5);
}
SetChartBkColor(colorWhite); 
sp=DCperiod;

_SECTION_END();
slowper = 2/(sp+1);
EMAp =Param("EMA Period",14,5,60,1);
VARma = AMA(C,slowper);
OEMA  = EMA(C,EMAp);
MACDee = OEMA - Varma;
j = MACDee;
SetBarFillColor(IIf(MACDee>0,colorLime,colorRed));
PlotOHLC(0,j,0,j,EncodeColor(colorBlue)+"KMACD - V.1.0"+"("+WriteVal(EMAp,0)+","+WriteVal(dcperiod,0)+")",IIf(MACDee>0,colorLime,colorRed), styleCandle |styleOwnScale) ;
much appreciate for look at this one :thumb: thanks
 
hi all,
below is the afl for bar numbering by pratap. I want to change the font and size in the afl only. currently its taking the common font and size of the chart.
is it possible to have the option in afl only to change font and its size? kindly help
_SECTION_BEGIN("Bar Count");
// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
// mode Text - show the barcount as a number above/below the price bars
// every n bars as set
// mode Histogram- shows the barcount as an histogam. Best used on a different pane
//

showhisto = ParamToggle("Mode", "Text|Histogram", 0) ;
everyn = Param("Show Text Every N bars", 5, 1, 10000, 1) ;
showabove = ParamToggle("Show Pos", "Below|Above", 0) ;
Clrtext = ParamColor("Text Color", colorBlack) ;

nd = Day()!=Ref(Day(),-1) ;

nbar = 1+BarsSince(nd) ;

if (showhisto)
Plot(nbar, "Day Bar Count", colorBlue, styleHistogram) ;
else
{
bi = BarIndex() ;

showtextbar = ((nbar -1) % everyn) == 0 ;
if (showabove)
{
pos = H ;
Offset = 3 ;
}
else
{
pos = L ;
Offset = -3;
}

Visfirst = FirstVisibleValue(bi) ;
Vislast = LastVisibleValue(bi) ;

for (i = Visfirst; i <= Vislast ; i++)
{
if (showtextbar)
{
str = NumToStr(nbar, 1.0) ;
PlotText(str, i, pos+Offset, Clrtext) ;
}
}
// PlotShapes(showtextbar*shapeSmallCircle, colorBlue, 0, H, 12) ;

}
_SECTION_END();
 
@primitivetrader
PlotTextSetFont( ''text'', ''fontname'', pointsize, x, y, color, bkcolor = colorDefault, yoffset = 0 )
thanks a lot. but where to fit this line can you please help.
 
str = NumToStr(nbar, 1.0) ;
PlotTextSetFont( str, "Arial", 18, i, pos+Offset, Clrtext );
PlotText(str, i, pos+Offset, Clrtext) ;


thanks for the help. i am getting the error error 32. syntax error, unexpected is there any semicolen missing at the end of the previous line.

i am having ami 5.7. plz help
 

Similar threads