Simple Coding Help - No Promise.

Nehal_s143

Well-Known Member
Dear All
can any one post slow stochastics candle amibroker afl.
pls
try this

Code:
/*Slow Stochastic and Trendlines
for Indicator Builder,
by Dimitris Tsokakis*/
D1=14;
MaxGraph=8;
ST3=StochK(D1);
ST33=StochD(D1);
Graph0=ST3;
Graph1=ST33;
Title=Name()+" - %K="+WriteVal(st3,FORMAT=1.2)+", %D="+
WriteVal(ST33,FORMAT=1.2)+
WriteIf(Cross(st3,st33),"     POSITIVE CROSS"," ")+
WriteIf(Cross(ST33,ST3),"     NEGATIVE CROSS","");
x = Cum(1);
per = 0.1;
s1=st33;
s11=st33;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2  ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x  -endt ) + bS; 
Graph6 = IIf(x>startt-1 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10);
Graph6Style = 1;
Graph6Color = 1;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2  ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x  -endt1 ) + bR; 
Graph7 = IIf(x>startT1-1  AND TRENDLINER>0 AND
TRENDLINER<100,trendlineR,-1e10);
Graph7Style = 1;
Graph7Color = 1;
 

extremist

Well-Known Member
can any one post here fly candles amibroker afl
Your dragon Fly Doji....

Code:
uperwick = H-O ;
lowerwick = C-L ; 
Body = O-C;

DD = uperwick <(0.2* lowerwick) AND body < (0.2* lowerwick) AND C<=o;

PlotShapes(DD*shapesmallcircle, colorgold, 0, Low, -10);
 

Nehal_s143

Well-Known Member
Any one have idea about this candles i m searching this candle
this seems to be below afl without plotting super trend

Code:
_SECTION_BEGIN("Super Trend System");
SetBarsRequired(200,0);
SetChartBkColor(colorLightGrey);
GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k =  Optimize("K",Param("K",2,0.25,5,0.25),0.25,5,0.25);
Per= Optimize("atr",Param("atr",20,3,20,1),3,20,1);
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 ) );
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorBlack, styleCandle | styleNoLabel );
j=Haclose;

//=======================================================================================================================
//=========================Indicator==============================================================================================
f=ATR(15);

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;  
NW[0] = 0;  
NW[BarCount-1] = Null;  


for(i = 1; i < BarCount-1; i++)
{
 if(Trend[i-1] == 1)                
 {
  if(j[i] < NW[i-1])                 
  {
   Trend[i] = -1;                   
   NW[i] = j[i] + Revers[i];        
  }
  else                              
  {
   Trend[i] = 1;
   if((j[i] - Revers[i]) > NW[i-1])
   {
    NW[i] = j[i] - Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  } 
 }
 if(Trend[i-1] == -1)               
 {
  if(j[i] > NW[i-1])                
  {
   Trend[i] = 1;                    
   NW[i] = j[i] - Revers[i];        
  }
  else                              
  {
   Trend[i] = -1;
   if((j[i] + Revers[i]) < NW[i-1]) 
   {
    NW[i] = j[i] + Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  }
 }
}

//===============system================

Plot(NW, "", IIf(Trend == 1, 27, 4), 4);
Buy=NW<HACLOSE;
Sell=NW>HACLOSE;
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy );

Short=Sell;
Cover=Buy;


NMAB= NW<HACLOSE;
NMAS= NW>HACLOSE;
//AlertIf( Buy , "SOUND C://Windows//Media//chimes.wav", "Audio alert", 2 ); 
//AlertIf( Sell , "SOUND C://Windows//Media//alert.wav", "Audio alert", 2 );

NMA_status= WriteIf(NMAB, "BUY MODE", WriteIf(NMAS, "SELL MODE", "NEUTRAL"));
NMAS_Col=IIf(NMAB, colorBrightGreen, IIf(NMAS, colorRed, colorLightGrey));
Filter=1;
AddColumn( NW[BarCount-1], "SAR", 1.2 );
AddColumn( HACLOSE, "HA Close", 1.2 );
AddColumn( C, "Close", 1.2 );
AddTextColumn(NMA_status, "MODE", 1, colorWhite, NMAS_Col);
AddColumn( DateTime(), "Date / Time", formatDateTime ); 
_SECTION_END();
//=================TITLE================================================================================================
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator ) 
(
Title = EncodeColor(colorWhite)+ "SuperTrend System" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+
"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"\n"+ 
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+"  ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+"  ","")+"\n"+EncodeColor(colorWhite));
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);



for(i=BarCount-1;i>1;i--)
{
if(Buy[i] == 1)
{
entry = H[i];
sig = "BUY";
sl = Ref(NW,-1);
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);
 
bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = "SELL";
entry = L[i];
sl = Ref(NW,-1);
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0112);
tar3 = entry - (entry * .0212);
 
 
bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, NW[BarCount-1], Ref(NW, -1));
sl = ssl[BarCount-1];

Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);



messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
 
}

_SECTION_END();



function ChandelierCl(AtrARRAY, AtrMult) {
	// Skip empty values
	i = 0;
	do {
		result[i] = Null;
		i++;
	} 
	while( i < BarCount AND (IsNull(O[i]) OR IsNull(H[i]) OR IsNull(L[i]) OR IsNull(C[i]) ) ); 
	First = i;

if (i < BarCount - 1) {
	HHC[First]    = C[First];
	LLC[First]    = C[First];

	if (C[First + 1] > HHC[First]) {
		HHC[First + 1] = C[First + 1];
		LLC[First + 1] = LLC[First];
		result[First] = C[First] - AtrMult * AtrARRAY[First];
		iTrade = "LT";
	}
	else {
		if (C[First + 1] < LLC[First]) {
			HHC[First = 1] = HHC[First];
			LLC[First + 1] = LLC[First + 1];
			result[First] = C[First] + AtrMult * AtrARRAY[First];
			iTrade = "ST";
		}
		else {
			HHC[First + 1] = C[First + 1];
			LLC[First + 1] = C[First + 1];
			result[First] = C[First] - AtrMult * AtrARRAY[First];
			iTrade = "LT";
		}
	}

	for( i = First; i < BarCount; i++ ) {
		if (iTrade == "LT") {
			if (C[i] >= result[i-1]) {        // Long Trade is continuing
				if (C[i] > C[i-1]) {
					HHC[i] = C[i];
				}
				else { 
					HHC[i] = HHC[i-1];
				}
				result[i] = HHC[i] - AtrMult * AtrARRAY[i];
				if (result[i] < result[i-1]) {
					result[i] = result[i-1];
				}
			}
			else {                            // Long trade Exit triggered
				iTrade = "ST";
				LLC[i] = C[i];
				result[i] = C[i] + AtrMult * AtrARRAY[i];
			}
		}
		else {                               // Short trade
			if (C[i] <= result[i-1]) {
				if (C[i] <= C[i-1]) {        // Short Trade is continuing
					LLC[i] = C[i];
				}
				else {
					LLC[i] = LLC[i-1];
				}
				result[i] = LLC[i] + AtrMult * AtrARRAY[i];
				if (result[i] > result[i-1]) {
					result[i] = result[i-1];
				}
			}
			else {                           //Short Trade Exit is triggered
				iTrade = "LT";
				HHC[i]  = C[i];
				result[i] = C[i] - AtrMult * AtrARRAY[i];
			}
		}
	}
}
return result;
}

function ChandelierHL(AtrARRAY, AtrMult) {
	// Skip empty values
	i = 0;
	do {
		result[i] = Null;
		i++;
	} 
	while( i < BarCount AND (IsNull(O[i]) OR IsNull(H[i]) OR IsNull(L[i]) OR IsNull(C[i]) ) ); 
	First = i;

if (i < BarCount - 1) {
	HHC[First]    = H[First];
	LLC[First]    = L[First];

	if (H[First + 1] > HHC[First]) {
		HHC[First + 1] = H[First + 1];
		LLC[First + 1] = LLC[First];
		result[First] = H[First] - AtrMult * AtrARRAY[First];
		iTrade = "LT";
	}
	else {
		if (L[First + 1] < LLC[First]) {
			HHC[First = 1] = HHC[First];
			LLC[First + 1] = LLC[First + 1];
			result[First] = L[First] + AtrMult * AtrARRAY[First];
			iTrade = "ST";
		}
		else {
			HHC[First + 1] = C[First + 1];
			LLC[First + 1] = C[First + 1];
			result[First] = H[First] - AtrMult * AtrARRAY[First];
			iTrade = "LT";
		}
	}

	for( i = First; i < BarCount; i++ ) {
		if (iTrade == "LT") {
			if (C[i] >= result[i-1]) {        // Long Trade is continuing
				if (H[i] > H[i-1]) {
					HHC[i] = H[i];
				}
				else { 
					HHC[i] = HHC[i-1];
				}
				result[i] = HHC[i] - AtrMult * AtrARRAY[i];
				if (result[i] < result[i-1]) {
					result[i] = result[i-1];
				}
			}
			else {                            // Long trade Exit triggered
				iTrade = "ST";
				LLC[i] = L[i];
				result[i] = L[i] + AtrMult * AtrARRAY[i];
			}
		}
		else {                               // Short trade
			if (C[i] <= result[i-1]) {
				if (L[i] <= L[i-1]) {        // Short Trade is continuing
					LLC[i] = L[i];
				}
				else {
					LLC[i] = LLC[i-1];
				}
				result[i] = LLC[i] + AtrMult * AtrARRAY[i];
				if (result[i] > result[i-1]) {
					result[i] = result[i-1];
				}
			}
			else {                           //Short Trade Exit is triggered
				iTrade = "LT";
				HHC[i]  = H[i];
				result[i] = H[i] - AtrMult * AtrARRAY[i];
			}
		}
	}
}
return result;
}

_SECTION_BEGIN("entry-exit");
EntrySignal = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ); 
ExitSignal = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) ); 
Color = IIf( EntrySignal, colorGreen, IIf( ExitSignal, colorRed, colorYellow )); 
TrailStop = HHV( C - 2 * ATR(10), 15 ); 
ProfitTaker = EMA( H, 13 ) + 2 * ATR(10); 
Plot( 2, "", Color, styleArea | styleOwnScale | styleNoLabel, -0.1, 50 );
_SECTION_END();
 

Similar threads