Intraday trading system-best scalping indicator now available

KelvinHand

Well-Known Member
#11
Kelvin Hand

The reason I said this was that you will notice that majority of such threads which require conversion are just hanging around without any resolution.

Amit
Why worry about that ?
Does it means it is no use ?
No. It serve as information.

For this example, By looking into the matched BuySellMagic.mq4, we know it is a BBand Stop Method.
We do had the BBStop AFL, so we do not require to re-invent the wheel.

Also the downloaded indicator02.ex4 is protected by latest encryption, because BuySellMagic.mq4 is matched, we save the time to find de-compilation.

Because the BuySellMagic.mq4 is pointed out, that means it is a reference design for the expert to follow.
 
#15
Very Good.
Share the AFL here.
Let the everyone here think about the changes
// Raft Channel two Std Dev w Zig
// adaptation by reinsley
// Linear Regression Line with 2 Standard Deviation Channels Plotted from Last Zig's Swing
// zig HiLo

SetChartOptions( 0, chartShowArrows | chartShowDates );

_SECTION_BEGIN( "Zig Hi Lo" );
// ZIG hilo version by Joris Schuller
// from ZigZag Hi Lo.afl : simplified version
pltzig = ParamToggle( "Plot ZigHL ", "Off|On", 1 );
change = Param( "ZigZag-HL %", 0.47, 0.01, 3, 0.01 );
za2 = 0;


Title = EncodeColor( 4 ) + _DEFAULT_NAME() + "; " + EncodeColor( 1 ) + StrFormat( "{{NAME}} - {{INTERVAL}}; {{DATE}}; \nO=%g, \nH=%g, \nL=%g, \nC=%g (%.1f%%){{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
pk = PeakBars( H, change ) == 0;
tr = TroughBars( L, change ) == 0;
pkbars = PeakBars( H, change );
trbars = TroughBars( L, change );
zHi = Zig( H, change );
zLo = Zig( L, change );
HLAvg = ( zHi + zLo ) / 2;
zp2 = IIf( pk, zHi, IIf( tr, zLo, IIf( pkbars <= trbars, L, H ) ) );//Modified zp to reduce occasional erroneous Pk/Tr connections at very small ZigPerc values
za2 = Zig( zp2, change );

if ( pltzig == 1 )
{
Plot( za2, "\nZig HiLo", 11, 5 | styleNoLabel );//Zig H-L Modified
}

_SECTION_END();

// 123 Pattern
// shapedigit display

_SECTION_BEGIN( "123 Pattern" );

procedure PlotShapeAt( x, y, shape, shift )
{
PlotShapes( IIf( BarIndex() == x, shape, 0 ), colorWhite, 0, y, shift );
}

bi = BarIndex();
sbi = SelectedValue( bi );
upshift = Param( "upshift ", 30, 1, 100, 1 );

if ( SelectedValue( PeakBars( za2 , Change ) < TroughBars( za2 , Change ) ) )
{
pt3 = PeakBars( za2 , Change, 1 ) == 0 ;
pt2 = TroughBars( za2 , Change, 1 ) == 0 ;
ydigit1 = H;
ydigit2 = L;
ydigit3 = H;
}
else
{
pt3 = TroughBars( za2 , change, 1 ) == 0 ;
pt2 = PeakBars( za2 , change, 1 ) == 0 ;
ydigit1 = L;
ydigit2 = H;
ydigit3 = L;
upshift = -upshift;
}

bpt1 = SelectedValue( ValueWhen( pt3, bi ) ); // x axis

bpt2 = SelectedValue( ValueWhen( pt2, bi ) );
bpt3 = SelectedValue( ValueWhen( pt3, bi , 2 ) );

pltdigit = ParamToggle( "Plot 123 Digit ", "Off|On", 1 );

if ( pltdigit == 1 )
{
PlotShapeAt( bpt1, ydigit3 , shapeDigit3, upshift );
PlotShapeAt( bpt2, ydigit2 , shapeDigit2, -upshift );
PlotShapeAt( bpt3, ydigit1 , shapeDigit1, upshift );
}

_SECTION_END();

Plot( C, "", colorWhite, styleThick + styleCandle );

_SECTION_BEGIN( "Xspace" );
xspace = Param( "GraphXSpace ", 10, 1, 20, 1 );
GraphXSpace = xspace;
_SECTION_END();


//The following is written by Patrick Hargus, with critical hints from Marcin Gorzynski, Amibroker.com

LastSwingBars = bi - SelectedValue(ValueWhen( pt3, bi ));

P = ParamField( "Price field", -1 );
Daysback = LastValue( LastSwingBars ) + 1 ;//Param( "Period for Liner Regression Line", 21, 1, 240, 1 );
shift = Param( "Look back period", 0, 0, 240, 1 );
// =============================== Math Formula ================================================== ===========

x = Cum( 1 );
lastx = LastValue( x ) - shift;
aa = LastValue( Ref( LinRegIntercept( p, Daysback ), -shift ) );
bb = LastValue( Ref( LinRegSlope( p, Daysback ), -shift ) );
y = Aa + bb * ( x - ( Lastx - DaysBack + 1 ) );


// ==================Plot the Linear Regression Line ================================================== ========


LRColor = ParamColor( "LR Color", colorCycle );
LRStyle = ParamStyle( "LR Style" );

LRLine = IIf( x > ( lastx - Daysback ) AND BarIndex() < Lastx, y, Null );
pltMidReg = ParamToggle( "Plot Mid Reg Line ", "Off|On", 1 );

if ( pltMidReg == 1 )
{
Plot( LRLine , "\nLinReg", LRCOLOR, LRSTYLE ); // styleDots );
}

// ========================== Plot 1st SD Channel ================================================== =============


// ========================== Plot 2d SD Channel ================================================== =============


_SECTION_BEGIN("Price1");
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("SAR");
acc = Param("Acceleration", 0.02, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.2, 0, 1, 0.001 );
Plot( SAR( acc, accm ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style", styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ) );
_SECTION_END();

_SECTION_BEGIN("BandStop");
/* Done by Rajandran R */
/* Author of www.marketcalls.in */
// BBands_Stop_v1.mq4 by [email protected]
// translation in Amibroker AFL, E.M.Pottasch, 2011

// Modified By KelvinHand

Length=Param("Length",20, 2); // Bollinger Bands Period
Deviation=Param("Deviation",2);
// Deviation was 2
MoneyRisk=Param("Money Risk", 1);

LineStyle=ParamToggle("Display line mode", "No|Yes", 1); // Display line mode: 0-no,1-yes
cUpTrendLine = ParamColor("UpTrendLine", ColorRGB(65,105,225));
cDnTrendLine = ParamColor("DownTrendLine", colorRed);





// Offset Factor
TurnedUp=Nz(StaticVarGet("TurnedUp"));
TurnedDown=Nz(StaticVarGet("TurnedDown"));
SoundON = ParamToggle("Sound","Off|On",1);


procedure CalcTrend_proc(bbtop,bbbot,Length,MoneyRisk,SoundON,TurnedUp,TurnedDown)
{
global UpTrendLine;
global DownTrendLine;
global smax;
global smin;

UpTrendLine=Null;
DownTrendLine=Null;
smax=Null;
smin=Null;
trend=0;


for (i=Length+1; i<BarCount; i++)
{
smax=bbtop;
smin=bbbot;
if (C>smax[i-1]) trend=1;
if (C<smin[i-1]) trend=-1;
if(trend>0 && smin<smin[i-1]) smin=smin[i-1];
if(trend<0 && smax>smax[i-1]) smax=smax[i-1];
bsmax=smax+0.5*(MoneyRisk-1)*(smax-smin);
bsmin=smin-0.5*(MoneyRisk-1)*(smax-smin);
if(trend>0 && bsmin<bsmin[i-1]) bsmin=bsmin[i-1];
if(trend<0 && bsmax>bsmax[i-1]) bsmax=bsmax[i-1];
if (trend>0)
{
UpTrendLine=bsmin;
if (SoundON==True && !TurnedUp && i==BarCount-1 && IsEmpty(UpTrendLine[i-1]))
{
Say("Bollinger Bands going Up");
TurnedUp=StaticVarSet("TurnedUp",1);
TurnedDown=StaticVarSet("TurnedDown",0);

}
}

if (trend<0)
{
DownTrendLine=bsmax;
if (SoundON==True && !TurnedDown && i==BarCount-1 && IsEmpty(DownTrendLine[i-1]))
{
Say("Bollinger Bands going Down");
TurnedUp=StaticVarSet("TurnedUp",0);
TurnedDown=StaticVarSet("TurnedDown",1);
}
} //if (trend<0)
} //for
} //procedure

bbtop=BBandTop(C,Length,Deviation);
bbbot=BBandBot(C,Length,Deviation);

CalcTrend_proc(bbtop,bbbot,Length,MoneyRisk,SoundON,TurnedUp,TurnedDown);
UpTrendSigNal=UpTrendLine AND IsEmpty(Ref(UpTrendLine,-1));
DownTrendSigNal=DownTrendLine AND IsEmpty(Ref(DownTrendLine,-1));

DisplayStyle = styleNoLabel|styleDots|styleNoTitle;
if(LineStyle == 0) DisplayStyle |= styleNoLine;


Plot(UpTrendLine,"UPTRENDLINE",cUpTrendLine,DisplayStyle);
Plot(DownTrendLine,"DOWNTRENDLINE",cDnTrendLine,DisplayStyle) ;

PlotShapes(IIf(UpTrendSignal,shapeCircle,shapeNone),cUpTrendLine,0,bbbot,0);
PlotShapes(IIf(DownTrendSignal,shapeCircle,shapeNone),cDnTrendLine,0,bbtop,0);
_SECTION_END();
 

KelvinHand

Well-Known Member
#16
BuySellMagic Ver 1.0

Here is the rough design.
Somebody interested, please complete the displayAlert() and the rest.



PHP:
_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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("SAR");
acc = Param("Acceleration", 0.02, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.2, 0, 1, 0.001 );
Plot( SAR( acc, accm ), _DEFAULT_NAME(), ParamColor( "Color", colorGrey40 ), ParamStyle("Style", styleDots | styleNoLine,maskAll ) );
_SECTION_END();

_SECTION_BEGIN("BuySellMagic");
//-- Created by KelvinHand 



SignalPeriod=Param("Signal Period",12, 3); 
ArrowPeriod=Param("Arrow Period",2, 0.1);

MoneyRisk=1;

LineStyle=ParamToggle("Display line mode", "No|Yes", 1); // Display line mode: 0-no,1-yes
cUpTSL = ParamColor("TSL Up", ColorRGB(0,191,225));
cDnTSL = ParamColor("TSL Down", colorRed);


// Offset Factor
TurnedUp=False;
TurnedDown=False; 
SoundON = ParamToggle("Sound","Off|On",1);


procedure displayAlert(TradeSig, TP, SL, EP)
{

   if (EP != 0.0) 
   {
      Title = Title + 
       strEP = "\n - Entry Price = " + NumToStr(EP);
   }

   if (SL != 0.0) 
   {
      Title = Title + 
       strSL = "\n - StopLoss = " + NumToStr(SL);
   }

   if (TP != 0.0) 
   {
      Title = Title + 
       strTP = "\n - Take Profit = " + NumToStr(TP);
   } 
   
// 

}


TSL_Up=Null;
TSL_Dn=Null;
trend=0;


smax=BBandTop(C,SignalPeriod,ArrowPeriod);
smin=BBandBot(C,SignalPeriod,ArrowPeriod);


for (i=SignalPeriod+1; i<BarCount; i++)
{
	if (C[i]>smax[i-1]) trend=1;
	if (C[i]<smin[i-1]) trend=-1;

	if(trend>0 && smin[i]<smin[i-1]) smin[i]=smin[i-1];
	if(trend<0 && smax[i]>smax[i-1]) smax[i]=smax[i-1];
	bsmax[i]=smax[i]+0.5*(MoneyRisk-1)*(smax[i]-smin[i]);
	bsmin[i]=smin[i]-0.5*(MoneyRisk-1)*(smax[i]-smin[i]);

	if(trend>0 && bsmin[i]<bsmin[i-1]) bsmin[i]=bsmin[i-1];
	if(trend<0 && bsmax[i]>bsmax[i-1]) bsmax[i]=bsmax[i-1];
	if (trend[i]>0)
	{

		TSL_Up[i]=bsmin[i];
		if (SoundON==True && !TurnedUp && i==BarCount-1 && IsEmpty(TSL_Up[i-1]))
		{

       Say("Bollinger Bands going Up");
			TurnedUp=True;
			TurnedDown=False;


       ISL = L[i];
       if (L[i-1]<ISL) ISL=L[i-1];
       if (L[i-2]<ISL) ISL=L[i-2];
 		  if (L[i-3]<ISL) ISL=L[i-3];
       EP = C[i-1];
 
       displayAlert("Buy", 0, ISL, EP);
 
		}
	}

	if (trend[i]<0)
	{
		TSL_Dn[i]=bsmax[i];
		if (SoundON==True && !TurnedDown && i==BarCount-1 && IsEmpty(TSL_Dn[i-1]))
		{
			Say("Bollinger Bands going Down");
			TurnedUp=False;
			TurnedDown=True;

       ISL = H[i];
       if (H[i-1]>ISL) ISL=H[i-1];
       if (H[i-2]>ISL) ISL=H[i-2];
       if (H[i-3]>ISL) ISL=H[i-3];
       EP = C[i-1];
 
       displayAlert("Sell", 0, ISL, EP);
 
		}
	} //if (trend<0)
} //for

TSL_SigArrowUp=TSL_Up AND IsEmpty(Ref(TSL_Up,-1));
TSL_SigArrowDn=TSL_Dn AND IsEmpty(Ref(TSL_Dn,-1));

DisplayStyle = styleNoLabel|styleDots|styleNoTitle;
if(LineStyle == 0) DisplayStyle |= styleNoLine;


Plot(TSL_Up,"TSL_UP",cUpTSL,DisplayStyle);
Plot(TSL_Dn,"TSL_DOWN",cDnTSL,DisplayStyle) ;

PlotShapes(IIf(TSL_SigArrowUp,shapeUpArrow,shapeNone ),colorLime,0,smin);
PlotShapes(IIf(TSL_SigArrowDn,shapeDownArrow,shapeNone),colorRed,0,smax);
_SECTION_END();
 
Last edited:
#17
I did backtest a few times on this AFL.

I find it quite impressive.

But/Sell when dots appear and exit when SAR starts in reverse direction.

Thanks,
Aman