Simple Coding Help - No Promise.

KelvinHand

Well-Known Member
No idea about the error.Code is working correctly.
Maybe does not work in lower version of Ami.
Need an expert to verify this.
I applied afl of macd thick histogram. I am getting error :
Plot(Hist,"MACD Histogram", BarColor,styleHistogram|styleThick|styleOwnScale,0,Null,0,-10,-50);

The cursor blinks before 50 in afl. message in the bottom getting as: Ln 15, col:92: error 16 too many agruments.
Please tell me anything to be added on afl.
This problem look likely the old version issue. What you can do is remove after styleOwnScale, ... to ); to verify the problem solve. OR look into your your Version 5.4 ??? 5.40 help hint or guide to see acutally how many arguments required.

This kind of problem don't waste time anymore, upgrade straight to the latest version. no one want to solve for you the old version
 

Nehal_s143

Well-Known Member
try this

Code:
a = TEMA(C,200) > MA(C,100) AND C > EMA(C,100) AND MA(C,100) > Ref(MA(C,100),-1) AND TEMA(C,200) > Ref(TEMA(C,200),-1) AND ADX(14) > 30 AND ADX(14) > Ref(ADX(14),-1) AND RSI(100) > 55;
b = TEMA(C,200) < MA(C,100) AND C < EMA(C,100) AND MA(C,100) < Ref(MA(C,100),-1)AND TEMA(C,200) < Ref(TEMA(C,200),-1) AND ADX(14) > 30 AND ADX(14) > Ref(ADX(14),-1) AND RSI(100) < 45;

mycT=IIf(a,colorBlue,
         IIf(b,colorRed,31));

Plot(6, "", mycT, styleOwnScale| styleArea|styleNoLabel,-0.5,100);
this will plot ribbon with blue color when its srtong bullish and red when strong bearish as per your condition






guys i want to replace the text " general " which appears at the top right of the chart ,with the following two conditions

a = TEMA(C,200) > MA(C,100) AND C > EMA(C,100) AND MA(C,100) > Ref(MA(C,100),-1) AND TEMA(C,200) > Ref(TEMA(C,200),-1) AND ADX(14) > 30 AND ADX(14) > Ref(ADX(14),-1) AND RSI(100) > 55;


b = TEMA(C,200) < MA(C,100) AND C < EMA(C,100) AND MA(C,100) < Ref(MA(C,100),-1)AND TEMA(C,200) < Ref(TEMA(C,200),-1) AND ADX(14) > 30 AND ADX(14) > Ref(ADX(14),-1) AND RSI(100) < 45;


these are the two conditions now if condition 'a' met i want to plot 'STRONG UPTREND', and if condition 'b' met i want to plot 'STRONG DOWNTREND'.


i tried a lot but cudnt code it proper ,so ur help required ...here is the code


_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
HaClose = (O + H + L + C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorBrightGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

_SECTION_END();


_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("Mid MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 45, 2, 300, 1 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("Long MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 100, 2, 400, 1 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("BBands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Color = ColorBlend( Color, GetChartBkColor(), 0.5 );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale;;
Plot( bbt = BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( bbb = BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, GetChartBkColor(), 0.7 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();

_SECTION_BEGIN("Volume");
Color = ParamColor("Color", ColorRGB( 128, 128, 192 ) );
Plot( Volume, _DEFAULT_NAME(), ColorBlend( Color, GetChartBkColor(), 0.5 ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram ), 2 );
_SECTION_END();

_SECTION_BEGIN("Price Interpretation");
movshort = ParamField("Short Time MA", 8 );
movmed = ParamField("Mid Time MA", 9 );
movlong = ParamField("Long Time MA", 10 );
btop = ParamField("BBTop", 11 );
bbot = ParamField("BBBottom", 12 );
if( Status("action") == actionCommentary )
{
width = btop - bbot;
lslop = LinRegSlope( C, 30 ) + 100;
lslo = LLV( lslop, 90 );
lshi = HHV( lslop, 90 );
lswidth = lshi - lslo;
trend = 100*( lslop - lslo )/lswidth;

mawidth = MA( width, 100 );
relwidth = 100*(width - mawidth)/mawidth;

_N( tname = Name()+"("+FullName()+")" );

printf("Price and moving averages:\n");
printf( tname + " has closed " + WriteIf( C > movshort, "above" , "below" ) + " its Short time moving average. ");

printf("\nShort time moving average is currently " + WriteIf( movshort > movmed, "above", "below") + " mid-time, AND " + WriteIf( movshort > movlong, "above", "below" ) + " long time moving averages.");

printf("\nThe relationship between price and moving averages is: "+
WriteIf( C > movshort AND movshort > movmed, "bullish",
WriteIf( C < movshort AND movshort < movmed, "bearish", "neutral" ) ) + " in short-term, and "+
WriteIf( movshort > movmed AND movmed > movlong , "bullish",
WriteIf( movshort < movmed AND movmed < movlong, "bearish", "neutral" ) ) + " in mid-long term. ");

printf("\n\nBollinger Bands:\n");
printf(tname+ " has closed " +
WriteIf( C < bbot, "below the lower band by " +
WriteVal( 100 *( bbot-C )/ width, 1.1 ) + "%%. " +
WriteIf( trend < 30, " This combined with the steep downtrend can suggest that the downward trend in prices has a good chance of continuing. However, a short-term pull-back inside the bands is likely.",
WriteIf( trend > 30 AND trend < 70, "Although prices have broken the lower band and a downside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +

WriteIf( C > btop, "above the upper band by " +
WriteVal( 100 *( C- btop )/ width, 1.1 ) + "%%. " +
WriteIf( trend > 70, " This combined with the steep uptrend suggests that the upward trend in prices has a good chance of continuing. However, a short-term pull-back inside the bands is likely.",
WriteIf( trend > 30 AND trend < 70, "Although prices have broken the upper band and a upside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +

WriteIf( C < btop AND ( ( btop - C ) / width ) < 0.5,
"below upper band by " +
WriteVal( 100 *( btop - C )/ width, 1.1 ) + "%%. ",
WriteIf( C < btop AND C > bbot , "above bottom band by " +
WriteVal( 100 *( C - bbot )/ width, 1.1 ) + "%%. ", "" ) ));

printf("\n"+
WriteIf( ( trend > 30 AND trend < 70 AND ( C > btop OR C < bbot ) ) AND abs(relwidth) > 40,
"This picture becomes somewhat unclear due to the fact that Bollinger Bands are currently",
"Bollinger Bands are " )+
WriteVal( abs( relwidth ), 1.1 ) + "%% " +
WriteIf( relwidth > 0, "wider" , "narrower" ) +
" than normal.");

printf("\n");

printf(
WriteIf( abs( relwidth ) < 40, "The current width of the bands (alone) does not suggest anything conclusive about the future volatility or movement of prices.","")+
WriteIf( relwidth < -40, "The narrow width of the bands suggests low volatility as compared to " + tname + "'s normal range. Therefore, the probability of volatility increasing with a sharp price move has increased for the near-term. "+
"The bands have been in this narrow range for " + WriteVal(BarsSince(Cross(-40,relwidth)),1.0) + " bars. The probability of a significant price move increases the longer the bands remain in this narrow range." ,"")+
WriteIf( relwidth > 40, "The large width of the bands suggest high volatility as compared to " + tname + "'s normal range. Therefore, the probability of volatility decreasing and prices entering (or remaining in) a trading range has increased for the near-term. "+
"The bands have been in this wide range for " + WriteVal(BarsSince(Cross(relwidth,40)),1.0) + " bars.The probability of prices consolidating into a less volatile trading range increases the longer the bands remain in this wide range." ,""));

printf("\n\nThis commentary is not a recommendation to buy or sell. Use at your own risk.");
}



_SECTION_END();

////////////////////

/////////////////

_SECTION_BEGIN( "TEMA" );

Len = Param( "Period", 200, 50, 200, 1 );

Av = TEMA( C, Len );

upema = Av > Ref( Av, -1 ) AND Ref( Av, -1 ) > Ref( Av, -2 ) AND C > Av;

downema = Av < Ref( Av, -1 ) AND Ref( Av, -1 ) < Ref( Av, -2 ) AND C < Av;

Color = IIf( upema , colorGreen, IIf( downema, colorRed, colorBlue ) );

Plot( Av, "TEMA", Color, ParamStyle( "Style", styleThick, maskAll ) );

_SECTION_END();

/////////////////



Buy = TEMA(C,200) > MA(C,100) AND C > EMA(C,100) AND MA(C,100) > Ref(MA(C,100),-1) AND TEMA(C,200) > Ref(TEMA(C,200),-1) AND ADX(14) > 30 AND ADX(14) > Ref(ADX(14),-1) AND RSI(100) > 55;

Sell = TEMA(C,200) < MA(C,100) AND C < EMA(C,100) AND MA(C,100) < Ref(MA(C,100),-1)AND TEMA(C,200) < Ref(TEMA(C,200),-1) AND ADX(14) > 30 AND ADX(14) > Ref(ADX(14),-1) AND RSI(100) < 45;






Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );


x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);


dist = 2.5*ATR(10);
dist1 = 0.7*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy )
{
PlotText( "\n Heavy Fire Up Ahead " , i, L[ i ]-dist, colorBlack, colorGreen );

}
if( Sell )
{
PlotText( " Heavy Down Fall Ahead " , i, H[ i ]+dist1, colorBlack, colorRed );
}
}

////////////////////


x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);



C11=ParamColor("up panel",colorBlack );
C12=ParamColor("dn panel",colorBlack );
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",8,1,30,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode( 0 );
GfxSelectFont("Tahoma", 12, 500, False, False, 0);
GfxSetTextColor(colorCustom12);
GfxSetTextAlign( 6 );
GfxSelectFont("Tahoma", 15, 600, False, False, 0);
GfxSetTextColor(colorWhite);
GfxSetTextAlign( 6 );

GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorBrightGreen);

GfxSelectFont("Tahoma", 12, 400, False, False, 0);
GfxSetTextColor(colorRed);




pricechange=(C-Ref(C,-1))*100/Ref(C,-1);
changeponit=C-Ref(C,-1);
Vlp=Param("Volume lookback period",15,10,300,10);
Vrg=MA(V,Vlp);
St = StDev(Vrg,Vlp);
Vp3 = Vrg + 3*st;
Vp2 = Vrg + 2*st;;
Vp1 = Vrg + 1*st;;
Vn1 = Vrg -1*st;
Vn2 = Vrg -2*st;

x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);

GfxGradientRect( 1, 1, 1400, 40, colorViolet, colorBlack);
GfxSetBkMode(0);
GfxSelectFont( "Georgia", 18, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( "General ", x+600, y+10 );
GfxSelectFont( "Tahoma", 16, 800, False );
GfxSetTextColor( colorGold );
GfxTextOut( Name(), x+100, y+10 );
GfxSelectFont( "Century Gothic", 15, 100, False );
GfxSetTextColor( colorGold );
GfxTextOut( Date(), x+1000, y+10 );
GfxSelectFont( "Comic Sans MS", 15, 500, False );
GfxSetTextColor( colorYellow );
GfxTextOut( Interval(2), x+275, y+10 );
//------------------------------------------------------------ H, L, O, C----------------------

//////////////////////////



DayH = TimeFrameGetPrice("H", in1Minute, 0);
DayL = TimeFrameGetPrice("L", in1Minute, 0);
DayC = TimeFrameGetPrice("C", in1Minute, 0);
DayO = TimeFrameGetPrice("O", in1Minute, 0);
pDayC = TimeFrameGetPrice("C", in1Minute, -1);

FS=Param("Font Size",15,11,100,1);
GfxSelectFont("Comic Sans M", FS , 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( colorBlack );
Hor=Param("Horizontal Position",820,1,1200,1);
Ver=Param("Vertical Position",1,1,830,1);
GfxTextOut(""+C, Hor, Ver);
GfxSetTextColor( colorGrey50 );
GfxTextOut("PC:"+pDayC,700, Ver);
GfxSetTextColor( colorBlue );
GfxTextOut("C:"+DayC, 600, Ver);
GfxSetTextColor(colorRed );
GfxTextOut("L:"+DayL,500, Ver);
GfxSetTextColor(colorBrightGreen );
GfxTextOut("H:"+DayH,400, Ver);
GfxSetTextColor( colorLightBlue );
GfxTextOut("O:"+DayO,300, Ver);


/////////////////////////////////////////
thank you,
amit.
 

bunti_k23

Well-Known Member
thank you nehal:D:thumb::thumb::thumb:
 
only today validity signals

Require AFL for below condition -

Buy above 300 simple moving average with only today date validity...

Advance Deevali wishes..
 

bunti_k23

Well-Known Member
Re: only today validity signals

Require AFL for below condition -

Buy above 300 simple moving average with only today date validity...

Advance Deevali wishes..
:lol: ru serious....300ma if u consider 1min candle then after 300min it will start to show ma line:lol:
 
hello to all . the following is an afl for nr4 and nr7 .

i request following modifications


a) instead of nr4 in the above afl i need nr21 . so can any one insert the param option to select according to one's choice of narrow range. so it may be nr4 ,nr7 or nr21 or whatever may be the trader's choice

b) Also can an option be also introduced in parameters to plot on chart what one wants to see eg nr7 only or nr7 +id (inside day.bar) similarly nr 21 only or nr21+id only .

my whole purpose is to make charts look uncluttered !

best regards



PHP:
_SECTION_BEGIN("NR7");

/*********** NR7 System for Chart and Exploration ***********************/

R = H - L;
NR7 = False;
NR4 = False;
m7 = m4 = idm7 = idm4 = idm = 0;

for(i = 7; i < BarCount; i++)
{
if( R[i] < R[i - 1] AND R[i] < R[i -2] AND R[i] < R[i - 3] AND R[i] < R[i - 4] AND R[i] < R[i - 5] AND R[i] < R[i - 6]) 
{
NR7[i] = True;
m7[i] = 1;
}
}

for(i = 4; i < BarCount; i++)
{
if((R[i] < R[i - 1] AND R[i] < R[i -2] AND R[i] < R[i - 3] ) AND NOT NR7[i])
{
NR4[i] = True;
m4[i] = 1;
}
}
IDNR7 = Inside() * NR7;
IDNR4 = Inside() * NR4;
ID = Inside();
idm7 = IIf(IDNR7, 1, 0);
idm4 = IIf(IDNR4, 1, 0);
idm = IIf(id, 1, 0);

for(i = 1; i < BarCount; i++)
{
if(IDNR7[i] == IDNR7[i - 1]) idm7[i] = idm7[i] + idm7[i - 1];
if(IDNR4[i] == IDNR4[i - 1]) idm4[i] = idm4[i] + idm4[i - 1];
if(NR7[i] == NR7[i - 1]) m7[i] = m7[i] + m7[i - 1];
if(NR4[i] == NR4[i - 1]) m4[i] = m4[i] + m4[i - 1];
if(ID[i] == ID[i - 1]) idm[i] = idm[i] + idm[i - 1];
}

MarkerIDNR7 = MarkerIDNR4 = shapeStar ;

Marker7 = shapeDigit7;
NR7Color = colorBrightGreen;

Marker4 = shapeDigit4;
NR4Color = colorLightOrange;

MarkerID = shapeHollowCircle;
IDColor = colorYellow;

IDNR7Color = colorBrightGreen;
IDNR4Color = colorLightOrange;

MarkerDist = L * 0.995;
IDNRDist = H * 1.03;

if(Status("action") == actionIndicator)
{
_N(Title = StrFormat("{{NAME}}, {{DATE}} ({{INTERVAL}}): {{VALUES}}") + ", Range=" + Prec(R + 0.00001, 2) + "," 
+ WriteIf(IDNR7, EncodeColor(colorBrightGreen) + WriteIf(idm7 > 1, StrLeft(NumToStr(idm7), 4), "") + " IDNR7 ", "")
+ WriteIf(IDNR4, EncodeColor(colorLightOrange) + WriteIf(idm4 > 1, StrLeft(NumToStr(idm4), 4), "") + " IDNR4 ", "") 
+ WriteIf(NR7 AND NOT ID, EncodeColor(colorBrightGreen) + WriteIf(m7 > 1, StrLeft(NumToStr(m7), 4), "") + " NR7 ", "")
+ WriteIf(NR4 AND NOT ID, EncodeColor(colorLightOrange) + WriteIf(m4 > 1, StrLeft(NumToStr(m4), 4), "") + " NR4 ", "")
+ WriteIf(ID AND NOT NR7 AND NOT NR4, EncodeColor(colorTurquoise) + WriteIf(idm > 1, StrLeft(NumToStr(idm), 4), "") + " Inside Day ", ""));

PlotOHLC(O, H, L, C, "Close", colorLightGrey, styleBar);
PlotShapes(IIf(IDNR7, MarkerIDNR7, shapeNone), IDNR7Color, 0, IDNRDist);
PlotShapes(IIf(IDNR4 AND NOT IDNR7, MarkerIDNR4, shapeNone), IDNR4Color, 0, IDNRDist);
PlotShapes(IIf(NR7 AND NOT ID, Marker7, shapeNone), NR7Color, 0, MarkerDist);
PlotShapes(IIf(NR4 AND NOT NR7 AND NOT ID, Marker4, shapeNone), NR4Color, 0, MarkerDist);
PlotShapes(IIf(ID AND NOT NR7 AND NOT NR4, MarkerID, shapeNone), IDColor, 0, IDNRDist);
}

if(Status("action") == actionExplore)
{
Filter = (m7 > 0) OR (m4 > 0) OR (idm > 0);

SetOption("NoDefaultColumns", True);

AddColumn(DateTime(), "DATE", formatDateTime, colorDefault, colorDefault, 96);
AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 120);
AddColumn(R, "Range", 6.2, colorDefault, colorDefault, 84);
AddColumn(IIf(idm, 48 + idm, 32), "INSIDE", formatChar, colorYellow, IIf(idm, colorLightBlue, colorDefault));
AddColumn(IIf(m4, 48 + m4, 32), "NR4", formatChar, colorYellow, IIf(m4, colorBlue, colorDefault));
AddColumn(IIf(m7, 48 + m7, 32), "NR7", formatChar, colorYellow, IIf(m7, colorGreen, colorDefault));
}

/************************** END OF AFL CODE *****************************/

_SECTION_END();
 

Similar threads