New Afl for just education purpose only

#1
Code:
//  [email protected]//
_SECTION_BEGIN("Trendy");
SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle);
SetBarFillColor( IIf( C > O, colorGreen , IIf( C <= O, colorRed , colorLightGrey  )));

_SECTION_BEGIN("MotherCandle");
Mothc=Ref(H,-1)>H AND Ref(L,-1)<L;
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(L,-1))));
TDL = LineArray(0, y0, (BarCount-1), y0);
//Plot(TDL, "", colorGold,styleDashed|styleNoLabel);
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(H,-1))));
TDH= LineArray(0, y0, (BarCount-1), y0);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)), colorGold,0,H,5);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGold,0,L,-5);
//Plot(TDH, "", colorCustom12,styleDashed|styleNoLabel);
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("Text Shift", -50,-100,100,10);

PlotText("" + WriteVal(TDH,fraction),
SelectedValue(BarIndex()+5)-(numbars/hts),SelectedValue(TDH),colorBlack,colorCustom12);
PlotText("" + WriteVal(TDL,fraction),
SelectedValue(BarIndex()+5)-(numbars/hts),SelectedValue(TDL),colorBlack,colorGold);
_SECTION_END();


CS= ParamToggle(" Style","Candle|Bar",0);
if(CS==1) {
DS=Param( "Dots", 100, 64, 100,64 );
Plot( C, "", IIf( C > O,  colorWhite , IIf( C <= O,colorWhite , colorLightGrey ) ), DS|stylenolabel,0,0,0,0,-1 );
}
Plot( C, "", IIf( C > O,  colorWhite , IIf( C <= O,colorWhite , colorLightGrey ) ), 128, 0, 0, 0, 0,-9 );
//Plot( C, "Close", colorturquoise, styleBar, Null, Null, 0, 1, -10 );

SetChartBkColor(ParamColor("Outer panel color ",colorDarkOliveGreen)); 
SetChartBkGradientFill( ParamColor("BgTop", colordarkgrey),ParamColor("BgBottom", ColorRGB(255,128,255)));


range = Param("Periods", 8, 2, 200, 1 );
Strong = Param("Strong ADX Above", 25, 2, 200, 1 );
Weak = Param("Weak ADX Below", 16, 2, 200, 1 );
 
   
LongCond = Cross(ADX(range), Strong) OR  Buy2 = Cross (ADX(range), Weak)  OR Buy3 = Cross(Weak, ADX(range)) ;
ShortCond = Cross(Strong,ADX(range)) OR  Buy2 = Cross (Weak,ADX(range))  OR Buy3 = Cross(ADX(range), Weak) ;
 
MyColor=    WriteIf ( (ADX(range) > Strong) AND (PDI(range) > MDI(range)), EncodeColor(colorBrightGreen), 
            WriteIf ( (ADX(range) > Weak) AND (PDI(range) > MDI(range)), EncodeColor(colorGreen), 
            WriteIf ( (ADX(range) > Strong) AND (MDI(range) > PDI(range)), EncodeColor(colorRed), 
            WriteIf ( (ADX(range) > Weak) AND (MDI(range) > PDI(range)), EncodeColor(colorOrange), 
            EncodeColor(colorWhite) ))));
 
ADXStatus = WriteIf (ADX(range) > Strong, "Strong ADX Trend", WriteIf (ADX(range) > Weak, "Weak ADX Trend", "Relax" ));
Trend = WriteIf (PDI(range) > MDI(range), EncodeColor(colorBrightGreen) +"UP Trend", EncodeColor(colorRed)+"DOWN Trend");
 
 
 
StrongLong  = ( ( Cross(PDI(range), MDI(range)) AND ADX(range) > Strong)  OR ( Cross(ADX(range), Strong) AND PDI(range)> MDI(range) ) ) ;
StrongShort = ( Cross(MDI(range), PDI(range)) AND ADX(range) > Strong)  OR ( Cross(ADX(range), Strong) AND MDI(range)> PDI(range) );
 
 
 //===================== SAR =======================================
_SECTION_BEGIN("SAR");
acc = Param("Acceleration", 0.02, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.2, 0, 1, 0.001 );
Col = IIf(SAR( acc, accm )>C,colorCustom12,colorCustom11);
Plot(SAR(acc,accm), _DEFAULT_NAME(), col, styleDashed );
Plot(1.5, "",IIf(C>SAR(acc,accm), colorCustom11, colorCustom12), styleArea|styleOwnScale,0,100);
_SECTION_END();




HX=Ref(H,-1);
LX=Ref(L,-1);
TicksOffset= Param("TicksOffset",0.0001,0.0001,0.50,0.0001);
y0=LastValue(HX)+TicksOffset; 
y1=LastValue(LX)-TicksOffset; 
Offset = 2;
for(i=BarCount-2;i>1;i--)
{
bars = i;
i = 0;
}
Plot(LineArray(bars-Offset, y0, BarCount, y0,1), "", colorDarkRed, styleLine|styleLine|styleNoLabel, Null, Null, Offset);
Plot(LineArray(bars-Offset, y1, BarCount, y1,1), "", colorDarkRed, styleLine|styleLine|styleNoLabel, Null, Null, Offset);
for (i=bars; i <BarCount;i++)
{
if (C[i]>y0)
color[i]=colorBlue;
else
color[i] = Null;
PlotText(""+Y0, BarCount+1,Y0,Null,color[i]);
AlertIf( C[i]>y0, "SOUND C:\\Windows\\Media\\ringout.wav", "Audio alert", 1 );
}
for (i=bars; i <BarCount;i++)
{
if (C[i]<y1)
color[i]=colorRed;
else
color[i] = Null;
PlotText(""+Y1, BarCount+1,Y1,Null,color[i]);
AlertIf( C[i]<y1, "SOUND C:\\Windows\\Media\\ringout.wav", "Audio alert", 1 );
}
 _SECTION_BEGIN("Title");


TimeFrameSet(inDaily);
TOP_ = Open;
PDH_ = Ref(High,-1);
PDL_ = Ref(Low,-1);
PDO_ = Ref(Open,-1);
PDC_ = Ref(Close,-1);
PDM_ = (PDH_+PDL_)/2;
TimeFrameRestore();

isAll = True;
isRth = TimeNum() >= 095500 AND TimeNum() <= 103000;
isdRth = TimeNum() >= 095500 AND TimeNum() <= 235900;

aRthL = IIf(isRth, L, 1000000);
aRthH = IIf(isdRth, H, Null);
aRthLd = IIf(isdRth, L, 1000000);

TOP = TimeFrameExpand(TOP_,inDaily,expandFirst);
PDH = TimeFrameExpand(PDH_,inDaily,expandFirst);
PDL = TimeFrameExpand(PDL_,inDaily,expandFirst);
PDO = TimeFrameExpand(PDO_,inDaily,expandFirst);
PDC = TimeFrameExpand(PDC_,inDaily,expandFirst);
PDM = TimeFrameExpand(PDM_,inDaily,expandFirst);

FHL = TimeFrameCompress( aRthL, inDaily, compressLow );
FHL = TimeFrameExpand( FHL, inDaily, expandFirst );
DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
DDayO = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily);
DLoDay = TimeFrameGetPrice("L", inDaily);
gfr = TimeFrameGetPrice("C", inDaily, -1);//close

//pivot calc//

_SECTION_BEGIN("Pivot calc");
pd = Param("Periods",13,5,144,1); 
pds = 2*pd-1;//     (Adjustment for Wilders MA) 
aa = Close-Ref(Close,-1); 
uu = EMA(Max(0,aa),pds); 
dd=  EMA((Max(0,0-aa)),pds); 

rf = IIf(C>2,1000,10000); 

c1 = Param("Upper Level",70,50,90,1); 
qq1 =100/(100-c1)-1; 
ff1 = qq1*dd-uu; 
ff2 = ff1/qq1; 
f1 = Max(ff1,ff2); 
UL = Close + f1*(pds-1)/2; 
UL = IIf(UL>C,floor(UL*rf),ceil(UL*rf))/rf; 

c2 = Param("Equilibrium",50,50,50,0);  
qq2 =100/(100-c2)-1;// [=1] 
ff = dd-uu; 
MM = Close + ff*(pds-1)/2; 
MM = IIf(MM>C,floor(MM*rf),ceil(MM*rf))/rf; 

c3 = Param("Lower Level",30,10,50,1); 
qq3 =100/(100-c3)-1; 
ff1 = qq3*dd-uu; 
ff2 = ff1/qq3; 
f3 = Min(ff1,ff2); 
LL = Close + f3*(pds-1)/2; 
LL = IIf(LL>C,floor(LL*rf),ceil(LL*rf))/rf; 

band = Param("band width",4,0,15,0.25);
mmu = MM+band;
mmd = MM-band;


X=Cross( C,LL);
Y=Cross(UL,C);

Buy1= X ;
Sell1= Y ;

TimeFrameSet( in15Minute*2 ); 
DH=Ref(H,-1); 
DL=Ref(L,-1);
DC=Ref(C,-1);


pd = ( DH+ DL + DC )/3;
sd1 = (2*pd)-DH;
sd2 = pd -(DH - DL);
sd3 = Sd1 - (DH-DL); 
rd1 = (2*pd)-DL;
rd2 = pd +(DH -DL);
rd3 = rd1 +(DH-DL);

TimeFrameRestore();

_SECTION_END();


Title = EncodeColor(colorCustom14)+" * VIJAY * "+ Interval(2) +EncodeColor(ColorRGB(200,180,250)) + Date() +
EncodeColor(colorLime) +
" *                     Previous Close : " + EncodeColor(colorBrightGreen) + gfr +EncodeColor(colorCustom12)+
"              ToDay Open : " +DDayO + EncodeColor(colorRed)+ "            Previous DayLow=   "+WriteVal(PDL,1)+ ",\n"+ EncodeColor(colorTurquoise) +"Previous DayHigh="+WriteVal(PDH,1)+ EncodeColor(coloryellow)+", Today High=  "+ DHiDay+ 
"  , ||  Todays Low= "+DLoDay + "\n" +EncodeColor(colorcustom10) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+
"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"\n"+ EncodeColor(colorLime)


+EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Rs."
 +EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % )"
 
 
 +"\n"+EncodeColor(colorGrey50)+"--------------------------------------"
 +EncodeColor(colorTurquoise)+ 
 " 
 | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1)
 +EncodeColor(colorTurquoise)+ " | OpenInterest : " + WriteIf(OI>= Ref(OI, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+WriteVal(OI,1)
 
 +"\n"+EncodeColor(colorGrey50)+"--------------------------------------"
  
+"\n"+EncodeColor(colorGrey50)+"--------------------------------------"
+ EncodeColor(colorYellow) + "\nADX(" +range +") Value:#" + WriteVal(ADX(range))
+ EncodeColor(colorYellow) + "\nADX Status      :# " +MyColor  + ADXStatus
+ EncodeColor(colorYellow) + "\nTrend Status   :# "  + Trend
+"\n"+EncodeColor(colorGrey50)+"--------------------------------------"

+ EncodeColor(colorBrightGreen)+  "    
 UP TGT   : "+ EncodeColor(colorWhite)+UL + EncodeColor(coloryellow)+   "\n Pivot : "+ EncodeColor(colorWhite)+pd+ EncodeColor(coloryellow)+   "     MIDPOINT : "+ EncodeColor(colorWhite)+MM
 + EncodeColor(colorRed)+    "
 BOT TGT  : "+ EncodeColor(colorWhite)+LL
;
 
_SECTION_END();

_SECTION_BEGIN(Title);

GfxSetOverlayMode( mode = 0 );
GfxSelectPen( colorBlack, 1 );
GfxSelectSolidBrush( colorLightYellow );
GfxRoundRect( 200, 55, 300, 180, 15, 15 );
GfxSetBkMode(1);
GfxSelectFont( "Arial", 10, 700, False );
GfxSetTextColor( colorBrown );
GfxSetTextAlign(0);
GfxTextOut( WriteIf(RD3, "R3:  "+(RD3 ),""), 210, 60);
GfxTextOut( WriteIf(RD2, "R2:  "+(RD2 ),""), 210, 80);
GfxTextOut( WriteIf(RD1, "R2:  "+(RD1 ),""), 210, 100);
GfxTextOut( WriteIf(SD1, "S1:  "+(SD1 ),""), 210, 120);
GfxTextOut( WriteIf(SD2, "S2:  "+(SD2 ),""), 210, 140);
GfxTextOut( WriteIf(SD3, "S3:  "+(SD3 ),""), 210, 160);
_SECTION_END();

cx=Param("cxposn",900,0,500,1);
cy=Param("cyposn",0,0,500,1);
GfxSetBkColor(ColorRGB(200,50,100));
GfxSelectFont( "tohomabold ",24,30, False);
GfxSetTextColor( colorYellow);
GfxSetTextColor( ColorHSB( 100, 10, 400) );
GfxTextOut("LTP."+C+" ", cx, cy );



Buy= Cross(EMA( C, 20 ), EMA( C, 50 ));
Sell= Cross(EMA( C, 50 ), EMA( C, 20 ));

dist = 2*ATR(10);
dist1 = 3*ATR(10);
Size1 = param("FontSize5", 10);
size=10;
ofs = 10;
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] )
{
PlotText( "\nBuy:" + L[ i ] + "\nT= " + (L[i]*1.005) + "\nSL= " + (L[i]*0.9975), i, L[ i ]-dist[i], colorGreen, colorWhite );
PlotTextSetFont( "", "Arial", size, i, L[i], ColorRGB(33,144,255), colorDefault, -ofs );
AlertIF( Buy, "SOUND E:/WINDOWS/Media/notify.wav", "Audio alert", 2 );

}
if( Sell[i] )
{
PlotText( "\nSell:" + H[ i ] + "\nT= " + (H[i]*0.995) + "\nSL= " + (H[i]*1.0025), i, H[ i ]+dist1[i], colorRed, colorWhite );
PlotTextSetFont( "", "Arial", size, i, H[i], ColorRGB(33,144,255), colorDefault, -ofs );
AlertIF( Buy, "SOUND E:/WINDOWS/Media/notify.wav", "Audio alert", 2 );
}
}
PlotShapes(IIf(Sell==1, shapehollowstar, shapeNone), coloryellow, 0,High, Offset=75);
PlotShapes(IIf(Sell==1, shapedownarrow, shapeNone), colorRed, 0,High, Offset=-55);
PlotShapes(IIf(Sell==1, shapeHollowSquare, shapeNone), colorRed, 0,High, Offset=35);
PlotShapes(IIf(Buy==1, shapehollowstar, shapeNone), coloryellow, 0,Low, Offset=-75);
PlotShapes(IIf(Buy==1, shapeUparrow, shapeNone), colorGreen, 0,Low, Offset=-55);
PlotShapes(IIf(buy==1, shapeHollowSquare, shapeNone), colorgreen, 0,low, Offset=-35);

Plot( EMA( C,20), "20 EMA Close",ParamColor("EMA 20 Color", colorGreen ),styleNoRescale);
Plot( EMA( C,50), "50 EMA Close",ParamColor("EMA 50 Color", colorRed ),styleNoRescale); 
_SECTION_END();

 
//============================ End Indicator Code ========================================================================================================





_SECTION_BEGIN("ERO ATR BUY SELL");
 
ero = Param("ATR multiple", 2.8, 0.5, 10, 0.1 )*Param("ATR period", 10, 3, 50 );  
ero_col=ParamColor( "Color", colorCycle );
 
r=HHV(H,ero);
s=LLV(L,ero);
ab=IIf(H>Ref(r,-1),1,IIf(L<Ref(s,-1),-1,0));
ac=ValueWhen(ab!=0,ab,1);
sl=IIf(ac==1,s,r);
 
Plot(sl, _DEFAULT_NAME(), ero_col, styleStaircase); // or styleaArea
 
Buy=Cross(H,sl);
Sell=Cross(sl,L);
PlotShapes(IIf(Buy, shapehollowcircle, shapeNone),colorpaleturquoise, 0, L, Offset=-55);
PlotShapes(IIf(Buy, shapehollowCircle, shapeNone),colorLime, 0,L, Offset=-65);                      
PlotShapes(IIf(Buy, shapeUptriangle, shapenone),colorcustom6, 0,L, Offset=-75); 
PlotShapes(IIf(Sell, shapehollowcircle, shapeNone),colorRed, 0, H, Offset=55);
PlotShapes(IIf(Sell, shapehollowcircle, shapeNone),colorOrange, 0,H, Offset=65);                      
PlotShapes(IIf(Sell, shapedowntriangle, shapeNone),colorcustom5, 0,H, Offset=-75);

dist = 3*ATR(10);
dist1 = 3*ATR(10);
for( i = 0; i < BarCount; i++ ) 
{ 
 if( Buy[i] ) 
 {
  PlotText( "\nCov@:" + C[ i ], i, C[ i ]-dist[i], colorGreen, colorwhite );
 }
 if( Sell[i] )
 {
  PlotText( "Sht@:" + C[ i ], i, C[ i ]+dist1[i], colorRed, colorwhite ); 
 }
 
}


_SECTION_END();






/////circle/////
_SECTION_BEGIN("Graphics");
GrpPrm=Param("Graphic Space",10,-10,10);
GraphXSpace=GrpPrm;
_SECTION_END();




//#include <T3.AFL>;


_SECTION_BEGIN("PFE");


Yx1 = Status("pxchartleft") ;  // left side of chart
Yy1 = Status("pxcharttop"); // top side of chart
Yx2 = Status("pxchartright"); // right side of chart
Yy2 = Status("pxchartbottom"); // bottom side ofthe chart
Yx3 = Status("pxchartwidth"); // boarder type size
Yy3 = Status("pxchartwidth"); // boarder type size

pds=10; 
x=sqrt((ROC(C,9)*ROC(C,9))+100);
y=Sum(sqrt((ROC(C,1)* ROC(C,1))+1),pds);
z=(x/y);
pfe=EMA(IIf(C>Ref(C,-9),z,-z)*100,5);

rsidn=pfe <-10 AND pfe<Ref(pfe,-1);
rsiup=pfe >10 AND pfe>Ref(pfe,-1);



 rsiresult1 = WriteIf( rsiup,"cu", "");
 rsiresult2 = WriteIf( rsidn,"cd", "");




 RequestTimedRefresh( 0 );
 GfxSelectFont( "Tahoma", 12, 120 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorWhite );

 if ( rsiresult1 =="cu")
 {
 GfxSelectSolidBrush( ColorRGB(0,90,0) ); 

 }
 else

 if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( ColorRGB(90,0,0)); 

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); 

 }

 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );


 Gfxroundrect( Yx1*30,Yy1*120,Yx2*0.149,Yy2*0.940,Yx3*0.015,Yy3*0.015  );
 
 _SECTION_END();
 
_SECTION_BEGIN("trending ribbon");

//BT=ParamColor("BT", colorRed );

TimeFrameSet (inDaily);
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();
UTM3=IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLightGrey ));

TimeFrameRestore();

UpA=uptrend;
DownB=downtrend;


Trend1 = WriteIf( UpA,"Up1", "");
Trend2 = WriteIf( DownB,"Down1", "");


RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( Trend1 =="Up1")
{
GfxSelectSolidBrush( ColorRGB(0,70,0) ); 

}
else

if ( Trend2 =="Down1")

{
GfxSelectSolidBrush( ColorRGB(70,0,0)); 

}
else

if ( Trend2 =="")

{
GfxSelectSolidBrush( colorPaleBlue ); 

}


GfxSelectPen( colorBlack, 0 ); // broader color 

GfxRoundRect( Yx1*39,Yy1*120,Yx2*0.149,Yy2*0.955,Yx3*0.015,Yy3*0.015 );
 //GfxCircle( 100,500,70 );
 _SECTION_END();


_SECTION_BEGIN("STC");

_SECTION_BEGIN("Schaff Trend Cycle");
/*
Ported directly from original STC Tradestation code
results differ from other Amibroker versions that are not based directly on original EasyLanguage code
http://mediaserver.fxstreet.com/Reports/99afdb5f-d41d-4a2c-802c-f5d787df886c/ebfbf387-4b27-4a0f-848c-039f4ab77c00.pdf
*/
MA1=23;
MA2=50;
TCLen=10;
MA1=Param("ShortMACDLen",23,5,36);
MA2=Param("LOngMACDLen",50,10,100);
TCLen=Param("TCLen(StochPeriod)",10,5,20);
Factor=.5;
//Calculate a MACD Line
XMac = MACD(MA1,MA2) ; // MACD in Amibroker always uses Close for MACD calculation

//1st Stochastic: Calculate Stochastic of a MACD
Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;

//Frac1=1; // prime Frac1 to a default of 1
//Frac1 = IIf(Value2 > 0, ((XMac - Value1) / Value2) * 100, Ref(FRAC1,-1));
// have to "prime" first value so that reference to "i-1" does not result in subscript out of range
// since MACD for both periods is not defined until MA2 period, 0 seems to be mathematically correct priming value
frac1=0;
for (i = 1; i < BarCount; i++) {
if (Value2[i] > 0) {
	frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100;
	}
else {
	frac1[i]= frac1[i-1];
	}
}

//Smoothed calculation for %FastD of MACD

PF[0]=frac1[0]; 
PF[1]=frac1[1];
for (i = 2; i < BarCount; i++) {
	PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1]));
}


//2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, above.
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;

//%FastK of PF
/*
Frac2=1;
Frac2 = IIf(Value4 > 0, ((PF - Value3) / Value4) * 100, Ref(FRAC2,-1));
*/

frac2[0]=0;
for (i = 1; i < BarCount; i++) {
	if (Value4[i] > 0 ) {
		frac2[i]=((PF[i] - Value3[i])/Value4[i])*100;
	}
	else {
		frac2[i]=frac2[i-1];
	}
}

//Smoothed calculation for %FastD of PF
PFF[0]=frac2[0];
PFF[1]=frac2[1];
for (i = 2; i < BarCount; i++) {
	PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1]));
}

 //HT=ParamColor("HT", colorRed );

 rsidn=pff <2;
 rsiup=pff >98;


 rsiresult1 = WriteIf( rsiup,"cu", "");
 rsiresult2 = WriteIf( rsidn,"cd", "");




 RequestTimedRefresh( 0 );
 GfxSelectFont( "Tahoma", 12, 120 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorWhite );

 if ( rsiresult1 =="cu")
 {
 GfxSelectSolidBrush( ColorRGB(0,120,0) ); 

 }
 else

 if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( ColorRGB(120,0,0)); 

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); 

 }

 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );


 Gfxroundrect( Yx1*25.95,Yy1*120,Yx2*0.132,Yy2*0.930,Yx3*0.015,Yy3*0.015);
 _SECTION_END();



_SECTION_BEGIN("Schaff Trend Cycle");
/*
Ported directly from original STC Tradestation code
results differ from other Amibroker versions that are not based directly on original EasyLanguage code
http://mediaserver.fxstreet.com/Reports/99afdb5f-d41d-4a2c-802c-f5d787df886c/ebfbf387-4b27-4a0f-848c-039f4ab77c00.pdf
*/
MA1=23;
MA2=50;
TCLen=10;
MA1=Param("ShortMACDLen",23,5,36);
MA2=Param("LOngMACDLen",50,10,100);
TCLen=Param("TCLen(StochPeriod)",10,5,20);
Factor=.5;
//Calculate a MACD Line
XMac = MACD(MA1,MA2) ; // MACD in Amibroker always uses Close for MACD calculation

//1st Stochastic: Calculate Stochastic of a MACD
Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;

//Frac1=1; // prime Frac1 to a default of 1
//Frac1 = IIf(Value2 > 0, ((XMac - Value1) / Value2) * 100, Ref(FRAC1,-1));
// have to "prime" first value so that reference to "i-1" does not result in subscript out of range
// since MACD for both periods is not defined until MA2 period, 0 seems to be mathematically correct priming value
frac1=0;
for (i = 1; i < BarCount; i++) {
if (Value2[i] > 0) {
	frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100;
	}
else {
	frac1[i]= frac1[i-1];
	}
}

//Smoothed calculation for %FastD of MACD

PF[0]=frac1[0]; 
PF[1]=frac1[1];
for (i = 2; i < BarCount; i++) {
	PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1]));
}


//2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, above.
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;

//%FastK of PF
/*
Frac2=1;
Frac2 = IIf(Value4 > 0, ((PF - Value3) / Value4) * 100, Ref(FRAC2,-1));
*/

frac2[0]=0;
for (i = 1; i < BarCount; i++) {
	if (Value4[i] > 0 ) {
		frac2[i]=((PF[i] - Value3[i])/Value4[i])*100;
	}
	else {
		frac2[i]=frac2[i-1];
	}
}

//Smoothed calculation for %FastD of PF
PFF[0]=frac2[0];
PFF[1]=frac2[1];
for (i = 2; i < BarCount; i++) {
	PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1]));
}

 //HT=ParamColor("HT", colorRed );

 rsidn=pff <2;
 rsiup=pff >98;


 rsiresult1 = WriteIf( rsiup,"cu", "");
 rsiresult2 = WriteIf( rsidn,"cd", "");




 RequestTimedRefresh( 0 );
 GfxSelectFont( "Tahoma", 12, 120 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorWhite );

 if ( rsiresult1 =="cu")
 {
 GfxSelectSolidBrush( ColorRGB(0,120,0) ); 

 }
 else

 if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( ColorRGB(120,0,0)); 

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); 

 }

 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );


 Gfxroundrect( Yx1*21.95,Yy1*120,Yx2*0.114,Yy2*0.920,Yx3*0.015,Yy3*0.015 );
 _SECTION_END();


 _SECTION_BEGIN("rsi");

 //HT=ParamColor("HT", colorRed );

 rsidn=RSI(7) <30;
 rsiup=RSI(7) >70;


 rsiresult1 = WriteIf( rsiup,"cu", "");
 rsiresult2 = WriteIf( rsidn,"cd", "");




 RequestTimedRefresh( 0 );
 GfxSelectFont( "Tahoma", 12, 120 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorWhite );

 if ( rsiresult1 =="cu")
 {
 GfxSelectSolidBrush( ColorRGB(0,150,0) ); 

 }
 else

 if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( ColorRGB(150,0,0)); 

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); 

 }

 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );


 Gfxroundrect( Yx1*17.95,Yy1*120,Yx2*0.095,Yy2*0.905,Yx3*0.015,Yy3*0.015  );
 _SECTION_END();

 _SECTION_BEGIN("Rays");

 //FT=ParamColor("FT", colorRed );

 Pp1=3;
 Pp2=2;

 CS33=HHV(LLV(High,Pp1)-ATR(Pp2),4); 
 CR33=HHV(LLV(High,Pp1)-ATR(Pp2),5);

 AtrupTrendCond1 = Close> CS33 ;
 AtrdnTrendCond1 =CS33>Close ;


 ATRup = WriteIf(AtrupTrendCond1,"atrup", "");
 ATRdown= WriteIf( AtrdnTrendCond1,"atrdn", "");

 if ( ATRup =="atrup")
 {
 GfxSelectSolidBrush( ColorRGB(0,180,0) ); 

 }
 else

 if (ATRdown =="atrdn")

 {
 GfxSelectSolidBrush( ColorRGB(180,0,0)); 

 }

 else

 if ( ATRdown =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); 

 }

 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );

 GfxSelectPen( colorBlue, 1 ); // broader color 
 Gfxroundrect( Yx1*13.95,Yy1*120,Yx2*0.078,Yy2*0.895,Yx3*0.015,Yy3*0.015  );

 _SECTION_END();


 _SECTION_BEGIN("Exit_Beast-3");

 //GT=ParamColor("GT", colorRed );

 EntrylookbackPeriod=10;
 EntryATRperiod=1.9;
 EntrySig = C > ( LLV( Low, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) );
 ExitSig = C < ( HHV( High, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) );


 RequestTimedRefresh( 0 );
 GfxSelectFont( "Tahoma", 12, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorWhite );

 EntryB = WriteIf( EntrySig,"eu", "");
 ExitB = WriteIf( ExitSig,"ed", "");

 if ( EntryB =="eu")
 {
 GfxSelectSolidBrush( ColorRGB(0,210,0) ); //

 }
 else

 if ( ExitB =="ed")

 {
 GfxSelectSolidBrush( ColorRGB(210,0,0)); //

 }

 else

 if ( ExitB =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); 

 }

 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );

 GfxSelectPen( colorBlue, 1 ); // broader color 
 Gfxroundrect(Yx1*09.95,Yy1*120,Yx2*0.060,Yy2*0.885,Yx3*0.015,Yy3*0.015 );// changing the value of x,y,rad x-70, y-90, rad-24

 _SECTION_END();

 _SECTION_BEGIN("CCI9-2");

 //HT=ParamColor("HT", colorRed );

 ccidn=CCI(8) < 0;
 cciup=CCI(9) > 0;


 ccresult1 = WriteIf( cciup,"cu", "");
 ccresult2 = WriteIf( ccidn,"cd", "");




 RequestTimedRefresh( 0 );
 GfxSelectFont( "Tahoma", 12, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorWhite );

 if ( ccresult1 =="cu")
 {
 GfxSelectSolidBrush( ColorRGB(0,240,0) ); 

 }
 else

 if ( ccresult2 =="cd")

 {
 GfxSelectSolidBrush( ColorRGB(240,0,0)); 

 }

 else

 if ( ccresult2 =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); 

 }

 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );

 GfxSelectPen( colorBlue, 1 ); // broader color 
 Gfxroundrect( Yx1*05.95,Yy1*120,Yx2*0.044,Yy2*0.875,Yx3*0.015,Yy3*0.015 );




 _SECTION_END();




 _SECTION_BEGIN("%BB7-1");

 //IT=ParamColor("IT", colorRed );
 p=7;
 x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100;
 bbdown= x < 40;
 bbup= x > 40;

 bbresult1 = WriteIf( bbup,"bu", "");
 bbresult2 = WriteIf( bbdown,"bd", "");
 bbresult3 = WriteIf( C,"bearishrevers", "");



 RequestTimedRefresh( 0 );
 GfxSelectFont( "Tahoma", 12, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorWhite );

 if ( bbresult1 =="bu")
 {
 GfxSelectSolidBrush( ColorRGB(62,255,62) ); 

 }
 else

 if ( bbresult2 =="bd")

 {
 GfxSelectSolidBrush( ColorRGB(255,62,62) ); 

 }

 else

 if ( bbresult2 =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); 

 }

 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );

 GfxSelectPen( colorBlue, 1 ); // broader color 
 Gfxroundrect(Yx1*01.95,Yy1*120,Yx2*0.026,Yy2*0.867,Yx3*0.015,Yy3*0.015  );


 _SECTION_END();

///circle////






_SECTION_BEGIN("MACDHIGHBULLISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);





rsidn=m1>0 AND m1>s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( ColorRGB(0,147,0)); 

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( coloryellow ); 

 }
 RequestTimedRefresh( 0 );
 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );

 GfxSelectPen( colorblue, 1 ); 
// broader color 
GfxSelectPen( colorturquoise, 2 );
 GfxPolygon(100,220,100,220,120,265,80,265);
_SECTION_END();

_SECTION_BEGIN("MACDLOWHBULLISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);





rsidn=m1<0 AND m1>s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( ColorRGB(0,147,0)); 

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( coloryellow ); 

 }
 RequestTimedRefresh( 0 );
 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );

 GfxSelectPen( colorBlue, 1 ); 
// broader color 
GfxSelectPen( colorturquoise, 2 ); 
GfxPolygon(120,310,120,310,120,270,165,290);
_SECTION_END();

_SECTION_BEGIN("MACDLOWHBEARISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);





rsidn=m1>0 AND m1<s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( ColorRGB(225,0,0)); 

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( coloryellow ); 

 }
 RequestTimedRefresh( 0 );
 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );

 GfxSelectPen( colorBlue, 1 ); 
// broader color 
GfxSelectPen( colorturquoise, 2 ); 

 GfxPolygon(80,310,80,310,80,270,35,290) ;
_SECTION_END();

_SECTION_BEGIN("MACDHIGHHBEARISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);





rsidn=m1<0 AND m1<s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( ColorRGB(225,0,0)); 

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( coloryellow ); 

 }
 RequestTimedRefresh( 0 );
 GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );

 GfxSelectPen( colorBlue, 1 ); 
// broader color 
	GfxSelectPen( colorturquoise, 2 ); 
 
GfxPolygon(100,360,100,360,120,315,80,315) ; 

_SECTION_END();


_SECTION_BEGIN("Stochastic %K");

StochsK 				=	ParamToggle("Stochastic %K", "Show|Hide",0);
StochasticLine 	= ParamColor("Stochastic Line", colorGold );
OverSold 			= ParamColor("OverSold", colorRed );
OverBought 		= ParamColor("OverBought", colorGreen );

if (StochsK == 1) {
SetChartOptions(0,0,ChartGrid30 | ChartGrid70  );
r = StochK(14) ;
Plot( r, "StochK", StochasticLine, styleNoRescale|styleOwnScale|styleNoLabel );
PlotOHLC( r,r,50,r, "", IIf( r > 50, OverSold, OverBought ), styleCloud | styleNoRescale|styleOwnScale|styleNoLabel|styleClipMinMax ); 
}

_SECTION_END();

//***********************************************\\Time Left//****************************//
_SECTION_BEGIN("Time Left");
function GetSecondNum()
{
    Time       = Now( 4 );
    Seconds    = int( Time % 100 );
    Minutes    = int( Time / 100 % 100 );
    Hours    = int( Time / 10000 % 100 );
    SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
    return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
SecsLeft    = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo    = TimeFrame - SecsLeft;
Secsleft = SecsToGo % 60 ;
Minleft = int( SecsToGo / 60 );

//(Colourful timing in left upper corner ie 05, 09 & 07)
Hora=Param("Left - Right",785,1,1200,1);
Vera=Param("Up - Down",-60,1,830,1);
GfxSetBkMode( colorWhite ); 
Newperiod = SecNumber % TimeFrame == 0;
if ( NewPeriod )
{
Say( " Next Candle Startz" );//Sound
}
FST=Param("Font Size Time",16,12,100,1); 
GfxSelectFont( "Arial", FST, 700, italic = False, underline = False, True ); 
GfxSetTextColor(ParamColor("Color",colorTan) ); 
GfxTextOut( ""+"" + Minleft + ":"+ "" + Secsleft+"",Hora+30,Vera+65);
//***********************************************\\Time Left//****************************//

i have not traded just go through for 1 min or 5 min timeframe
[/url][/IMG]
 

bunti_k23

Well-Known Member
#3
looking into future:cool:
 

Similar threads