Simple Coding Help - No Promise.

Why making it so complicated if the earth was made with ease and for ease of use?

Code:
x = MA( C, 2 );
y = x;
for ( i = 1; i < 10; i++ )
{
    y = MA( y, 2 );
    y += x;
}

SwingTrd1 = 100 * (Close - (y / 10)) / (HHV(C, 10) - LLV(C, 10));
SwingTrd2=EMA(SwingTrd1,30);
SwingTrd3=EMA(SwingTrd2,30);
RMO= EMA(SwingTrd1,81);

Buy=Cross(SwingTrd2,SwingTrd3);
Sell=Cross(SwingTrd3,SwingTrd2);

Bull_Trend=EMA(SwingTrd1,81)>0;
Bear_Trend=EMA(SwingTrd1,81)<0;
Ribbon_kol=IIf(Bull_Trend,colorGreen, IIf(Bear_Trend,colorRed, colorBlack));
Plot(4, "ribbon", Ribbon_kol, styleOwnScale|styleArea|styleNoLabel, -0.5,100);
trash!

You can't hide yourself with new name!

Once again, the focus on this thread and this site is not about programming elegance or programming superiority. I sincerely hope that you get this concept !!!

Rahul Mohinder wrote his indicator for Metastock which did not have the "for" loop. So those who had written the AFL (it was not done by me) continued to use expanded version of oscillator.

I do also happen to have the for loop variant on my machine but it is more complicated for devadas to verify its correctness.
 
trash!

You can't hide yourself with new name!

Once again, the focus on this thread and this site is not about programming elegance or programming superiority. I sincerely hope that you get this concept !!!

Rahul Mohinder wrote his indicator for Metastock which did not have the "for" loop. So those who had written the AFL (it was not done by me) continued to use expanded version of oscillator.

I do also happen to have the for loop variant on my machine but it is more complicated for devadas to verify its correctness.
Excuse me but why a rude answer with accusing other members who just wanna post an improving version to others making life easier? Don't know what fights you have running with other members and I'm not interested by any means. And why is it about Metastock if that code is written in AFL? The goal always should be to improve things. Also I don't see why a shorter version would be more complicated than a version containing less braces. Further I don't see why you would think of other members being less capable in understanding a code? If I were devadas I would feel offended by such prejudging sentence of yours. I guess someone is taking a non personal subject too personal on multiple levels. The question of my previous post has been a rhetorical question btw.
 
I am trying to generate code for automatic buy and sell.. Facing a typical problem... If the buy and sell are on the same bar - sell is not being generated... eg. If price crosses My trigger level and does my financial target on same bar, system generates a bar arrow on cross of trigger but does not generate a sell arrow when price+tgt is achieved in same bar... It does work If the target gets achieved in any of the subsequent bars... Can anybody help/guide?
 
Folks

Continuing on the holy grail quest of KRA ....

discovered yet another Indicator/Oscillator that claims to show the trend without any lag (in other words, lag is compensated for). Testing and expert opinion welcome...

First Clue was present in TJ itself here

Digging further revealed this site

Code is

Code:
r = Param( "TSI period Length:", 25, 1, 100, 1 );
s = Param( "TSI period Smoothing:", 13, 1, 100, 1 );
sig = Param( "TSI Signal Length:", 7, 1, 100, 1 );
 
Mtm = C - Ref ( C, -1 );
AbsMtm = abs(Mtm);

numT = EMA ( EMA ( Mtm, r ), s );
DenT = EMA ( EMA ( AbsMtm, r ), s );

TSI = 100 * Nz ( numT / DenT );
Plot( TSI, "TSI("+r+","+s+")", colorRed, styleLine);
Plot(EMA(TSI,sig), "", colorLightBlue, styleLine);
Plot(0,"", colorBlack, styleDashed);
 

Riskyman

Well-Known Member
Hey guys,

I need a small favor. I have this heiken ashi afl which I use sometimes. Problem with is that i have to manually look for change in candle color from green to red & vice versa. When i run a scan using the exploration, it doesnt show any scripts that have just changed color. Can anybody modify this code so that when i run a scan using it, it should shortlist only those scrips that have changed color. For ex if im using a 30 min time frame i want to be able to shortlist all scrips that have changed color from green to red or red to green. Thanks a lot





_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
//Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
//Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("Heiken Ashi Smoothed");
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),ParamColor("BgBottom", colorBlack),ParamColor("Titleblock",colorLightGrey ));
SetChartOptions(0,chartShowArrows|chartShowDates);
GraphXSpace=5;
p=Param("Period",6,2,30,1);
Om=MA(O,p);
hm=MA(H,p);
lm=MA(L,p);
Cm=MA(C,p);
HACLOSE=(Om+Hm+Lm+Cm)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
HaLow = Min( Lm, Min( HaClose, HaOpen ) );
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorWhite, styleCandle | styleNoLabel );
_SECTION_END();
Line=ParamToggle("Show Line chart also","Hide|Show",0);
if(Line==1) {
Plot(C,"Close",colorWhite,styleLine);
}


a=LinearReg(HaClose, 5 ) ;
b=LinearReg( HaClose, 5 ) ;

Plot( IIf(HaHigh>HaOpen,a,b), _DEFAULT_NAME(), colorRed, ParamStyle("Style") );

Plot( LinearReg( HaOpen, 5 ), _DEFAULT_NAME(), colorWhite, ParamStyle("Style") );


_SECTION_BEGIN("MA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();



_SECTION_BEGIN("Magnified Market Price");
//by Vidyasagar, [email protected]//
FS=Param("Font Size",30,30,100,1);
GfxSelectFont("Arial", FS, 900, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorYellow) );
//Hor=Param("Horizontal Position",800,800,800,800);

Hor=Param("Horizontal Position",500,500,200,20);




Ver=Param("Vertical Position",50,50,250,50);
GfxTextOut(""+C,Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
_SECTION_END();




_SECTION_BEGIN("Price Line");

PriceLineColor=ParamColor("PriceLineColor",ColorRGB(82,82,82));
PriceLevel = ParamField("PriceField", field = 3 );

Daysback = Param("Bars Back",100,10,500,1);
FirstBar = BarCount - DaysBack;
YY = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null);

Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll));


side = Param("side",1,0,1000,1);

dist = 0;

for( i = 0; i < BarCount; i++ )
{
if(i+side== BarCount) PlotText( "\n " + PriceLevel[ i ], i, YY[ i ]-dist, colorLightBlue );
}


_SECTION_END();


/*
_SECTION_BEGIN("Linear Regression");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( LinearReg( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("Linear Regression1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( LinearReg( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

*/





_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

//Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
//(Title = StrFormat(" - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C ));

(Title = StrFormat("{{DATE}} O %g, H %g, L %g,
C %g (%.1f%%) ", O, H, L, C ) )
//+"\n"+EncodeColor(colorPink)+"-----------------------------------------"
//+"\n"+EncodeColor(colorOrange)+"The Sultan Foundation v 13.01 Int"
//+"\n"+EncodeColor(colorLightOrange)+"by Sultanji "
//+"\n"+EncodeColor(colorPink)+"-----------------------------------------"


//+"\n"+EncodeColor(colorOrange)+"If bright green candle BUY and If red candle SELL"
//+"\n"+EncodeColor(colorLightOrange)+"by Sultanji "
;

_SECTION_END();
 

casoni

Well-Known Member
Hey guys,

I need a small favor. I have this heiken ashi afl which I use sometimes. Problem with is that i have to manually look for change in candle color from green to red & vice versa. When i run a scan using the exploration, it doesnt show any scripts that have just changed color. Can anybody modify this code so that when i run a scan using it, it should shortlist only those scrips that have changed color. For ex if im using a 30 min time frame i want to be able to shortlist all scrips that have changed color from green to red or red to green. Thanks a lot
Replace following lines... this will scan and plot arrows when your conditions are true [ green - red candle ]

a=LinearReg(HaClose, 5 ) ;
b=LinearReg(HaOpen, 5 ) ;

Plot(A, _DEFAULT_NAME(), colorRed, ParamStyle("Style") );
Plot(B, _DEFAULT_NAME(), colorWhite, ParamStyle("Style") );

Buy=Cross(A,B);
Sell=Cross(B,A);

PlotShapes(Buy*1,5,0,HaLow,-15);
PlotShapes(SELL*2,4,0,HaHigh,-15);
 

Similar threads