Supertrend Oscillator

citrus

Well-Known Member
#11
Hi

If you apply this formula it shows some syntax error in First line. Please Ractify.

Regards
Revised and tested

Code:
_SECTION_BEGIN("ATRtrading");
period	= Param("Period", 13, 1, 240, 1);
mult	= Param("Multiplier", 1.7, 1, 240, 0.1);

f=ATR(period);

VS[0] = Close[0]; 
trend[0] = 0;
HighC[0]=0;
Lowc[0]=0;

for( i = period+1; i < BarCount; i++ ) 
{ 

  vs[i]			= vs[i-1];
  trend[i]	= trend[i-1];
  highC[i]	= HighC[i-1];
  lowc[i]		= lowc[i-1];

	if ((trend[i]>=0) && ( C[i] <VS[i] ))
	{
			trend[i] =-1;
			HighC[i] = C[i];
			lowc[i] = C[i];
	}

	if ((trend[i]<=0) && (C[i] >VS[i]))
	{
			trend[i]=1;
			HighC[i] = C[i];
			lowc[i] = C[i];
	}   

	if (trend[i]==-1) 
	{
		if (C[i]<lowc[i]) lowc[i] = C[i];
     VS[i]= lowc[i]+ (mult*f[i]);
	}


	if (trend[i]==1)  
	{
		if (C[i]>HighC[i]) HighC[i] = C[i];
     VS[i]= HighC[i]-(mult*f[i]);
	}

} 


Buy=Cross(Trend,0);
Sell=Cross(0, Trend);

Plot(Close,"Close",colorBlue,styleCandle);
Plot(VS, "Vol Stop",IIf(trend==1,10,11 ),styleThick);

mkol 	= IIf( Trend==1, 10,  11);
Plot(5, "ribbon", mkol, styleOwnScale|styleArea|styleNoLabel, 0, -5);	// Weekly trend

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low-f, High+f)); 
_SECTION_END();
 
#12
Re: Supertrend Oscillator -Thankyou

Thankyou all for your patient explanations & posting of AFL's

My personal Thanks to Citrus ,Vrathee ,Hitesh --- for patient & detailed explanation of Chandelier stops,& The Lord .

This Forum Is superb
 
#14
Hitesh,
I have incorporated the Chandelier stop & is working fine.Please let me know how to make the line green during buy & red for Sell

Regards

Bimbo
 
#16
I have put the Geoff MUlhall file in dll & put the following formula for Chandelier stops.

It is working

Plot(ChandelierCl(ATR(15),3),"ChandelierCl",colorBrightGreen,styleThick);
Buy = Close > Ref( ChandelierCl(ATR(15),3), -1);
Sell = Close < Ref( ChandelierCl(ATR(15),3), -1);

During buy I want it to be green & red during sell what I have to add there

Regards

Bimbo
 
#17
Hi,
Can anybody make the Chandelier Plot from the "CLOSE" rather than "High" or "LOW"

The afl is below

_SECTION_BEGIN("ATRtrading");
period = Param("Period", 13, 1, 240, 1);
mult = Param("Multiplier", 1.7, 1, 240, 0.1);

f=ATR(period);

VS[0] = Close[0];
trend[0] = 0;
HighC[0]=0;
Lowc[0]=0;

for( i = period+1; i < BarCount; i++ )
{

vs = vs[i-1];
trend = trend[i-1];
highC = HighC[i-1];
lowc = lowc[i-1];

if ((trend>=0) && ( C <VS ))
{
trend =-1;
HighC = C;
lowc = C;
}

if ((trend<=0) && (C >VS))
{
trend=1;
HighC = C;
lowc = C;
}

if (trend==-1)
{
if (C<lowc) lowc = C;
VS= lowc+ (mult*f);
}


if (trend==1)
{
if (C>HighC) HighC = C;
VS= HighC-(mult*f);
}

}


Buy=Cross(Trend,0);
Sell=Cross(0, Trend);

Plot(Close,"Close",colorBlue,styleCandle);
Plot(VS, "Vol Stop",IIf(trend==1,10,11 ),styleThick);

mkol = IIf( Trend==1, 10, 11);
Plot(5, "ribbon", mkol, styleOwnScale|styleArea|styleNoLabel, 0, -5); // Weekly trend

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low-f, High+f));
_SECTION_END();
 
#18
Hello,

I am a newbie on this forum. I have the licence of amibroker but would like someone to help writing down the code with their langage. could you help to do so?

Thanks

florian

versailles, France
 
#19
Hi Florian,
I am not an expert in AFL either.I also am learning to write afls.If I want an afl for a trading system or idea ,I post it in this forum or other forums.

You can likewise do the same.Post ur ideas & trading system in this forum someone may help you
 

Similar threads