it is not rocket science. please write AFL for amibroker

#1
I understand that many traders make a conscious choice of NOT using technical indicators and I completely respect that. as a side note, for the few interested in technical indicators, here is what works for me.
step 1

it's simple, and what is left after thousands of trials & errors. short-term chart of WTI (2 MIN.)
bottom indicator window of Williams %R (period of 250)
tells me when market is in positive (+) or negative (-) territory.

step 2

is timing each move. here we focused on the buy side.
indicator window on center is MACD (12, 26, 9).
every time that the MACD line crosses ABOVE the signal line,
we have a buy. (and in this case we focus on 'buy' signals).
William %R must be stay above -20.
and every time the MACD recrosses back under the signal line,
that announces the end of that particular move.vice versa for sell william%R stays below -80 and macd crosses signal line with negative
it is not rocket science. we only have to follow the rules.
be constant. disciplined. and go in when it's time
and go out when it's time.

i think below screen shot explains you lot

buying screen shot



Selling screen shot

 
#3
Code:
_SECTION_BEGIN("Not Rocket Science");
// function for "William's % R"
function PercentR( periods )
{
 return -100 * ( HHV( H, periods ) - C )/( HHV( H, periods ) - LLV( L, periods ) ); 
}


//"Price"
GraphXSpace=5;
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() ); 


//  "William's % R"
pW = PercentR(Param("%WillR",250,10,300,10));
Color01 = IIf(pW > -20, colorBlue,IIf(pW < -80, colorRed, colorLightGrey));
Plot(10,"",Color01,styleOwnScale|styleNoLabel|styleArea,0,500);

//"MACD"
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
m1 = MACD(r1, r2);		 s1 = Signal(r1,r2,r3);
Color02 = IIf(m1 > s1, colorBlue,colorRed);
Plot(20,"",Color02,styleOwnScale|styleNoLabel|styleArea,0,500);

Buy   = pW > -20 AND m1 > s1;		Sell  =  Cross(s1,m1);
Short = pW < -80 AND s1 > m1;		Cover =  Cross(m1,s1);
Buy = ExRem(Buy,Sell);							Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);						Cover = ExRem(Cover,Short);
PlotShapes(Buy+Short*2,colorWhite,0,IIf(Buy,L,H));
PlotShapes(Sell*4+Cover*3,colorWhite,0,IIf(Sell,H,L));
_SECTION_END();
 
Last edited:
#4
very much thank you. but above willaim%R 250 there is buy only. but formula giving sell call . please change that.


See this picture




this the macd formula i am using please use this macd in that formula

Code:
_SECTION_BEGIN("SINI");
r = Param( "SINI period 'R':", 12, 1, 100, 1 );
s = Param( "SINI period 'S':", 26, 1, 100, 1 );
u = Param( "SINI period 'U':", 10, 1, 100, 1 );
sig = Param( "Signal period:", 9, 1, 100, 1 );
 
Mtm = C - Ref ( C, -1 );
AbsMtm = abs ( Mtm );
Num_T = EMA ( EMA( EMA ( Mtm, r ), s ), u );
Den_T = EMA ( EMA( EMA ( AbsMtm, r ), s ), u);
 
SINI = 100 * Nz ( Num_T / Den_T );
TSIL = 100 * Nz ( Num_T / Den_T );
 
//Green TSIL Line=Rising; Red TSIL Line=Falling
col = IIf( TSIL > Ref( TSIL, -1 ), colorLime, colorRed );
Plot( TSIL, "SINI("+r+","+s+","+u+")", col, styleLine | styleThick);
//Green EMA SINI,sig Line=Rising; Red EMA SINI,sig Line=Falling
col = IIf( EMA(SINI,sig) > Ref( EMA(SINI,sig), -1 ), colorBrightGreen, 
 
colorRed );
Plot( EMA(SINI,sig), "", col, styleThick);
Histcol= IIf(SINI>0,colorIndigo,colorWhite) ;
//Plot( SINI, "", histcol, ParamStyle("Histogram style", styleThick |styleHistogram | styleNoLabel, maskHistogram ) );
Plot(0,"",ParamColor( "ColorZero", colorWhite ),styleLine);
 
//Title = "SINI";
_SECTION_END();
 
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
//FORMULA
Cuptop1= C>BBandTop( C,20,1 ) ;
top1up= BBandTop( C,20,1 )>=Ref(BBandTop( C,20,1 ),-1) ;
top2up= BBandTop( C,20,2 )>=Ref(BBandTop( C,20,2 ),-1) ;
MACDup= MACD()>Signal() ;
Hist= MACD()-Signal() ;
Histup= Hist>Ref(Hist,-1) ;
stochup= StochK()>StochD() ;
stoch80= StochK()<80 ;
MFIup= MFI()>EMA(MFI(),5) AND MFI()>20 ;
ma21up= MA(C,21)>=Ref(MA(C,21),-1) ;
ma55up= MA(C,55)>=Ref(MA(C,55),-1) ;
EMA89up= EMA(C,89)>=Ref(EMA(C,89),-1) ;
Cupma21= C>MA(C,21) ;
Cupma55= C>MA(C,55) ;
cupema89= C>EMA(C,89) ;
Vup50= V>50000 ;
CCIup0= CCI()>0 ;
Cupo= C>O ;
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
mybuy= TSIL > Ref( TSIL, -1 ) AND EMA(SINI,sig) > Ref( EMA(SINI,sig), -1 
 
) AND TSIL>EMA(SINI,sig) AND
macdup AND ema89up AND mfiup ;
mysell= TSIL < Ref( TSIL, -1 ) AND EMA(SINI,sig) < Ref( EMA(SINI,sig), -1 
 
) AND TSIL<EMA(SINI,sig) ;
 
Buy = ExRem(myBuy, mysell);
Sell = ExRem(mysell, myBuy);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
 
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorLime,0);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0);


very much thankyou
 
Last edited:
#5
Hollow down arrow is order to close long position, and not sell (short)
Hollow up arrow is cover and not fresh buy,

if you don't want to show them comment out the last line in the code by adding // before it


//PlotShapes(Sell*4+Cover*3,colorWhite,0,IIf(Sell,H,L));


as for false signals check the parameters on the price pane make sure the parameters on all the different panes match.

will try to post the code combined with ur MACD, meanwhile give it a try yourself . . .

Happy :)
 
#6
CHART IS SHOWING SELL SIGNAL WHEN WILLIAM R IS ABOVE -20. ONLY BUY ABOVE -20 AND SELL BELOW -80 DEPENDS ON MACD. I HOPE YOU UNDERSTAND:thumb::thumb::thumb::thumb:
 
#7
Afternoon Mega,

Thanks for sharing the setup. Have a question is it essential that we stick to 2 minute time frame ?

I am beginner and learning to trade in crude - of-course TJ folks have been of great help, assisting me understand different concepts. Thanks a bunch

I understand that many traders make a conscious choice of NOT using technical indicators and I completely respect that. as a side note, for the few interested in technical indicators, here is what works for me.
step 1

it's simple, and what is left after thousands of trials & errors. short-term chart of WTI (2 MIN.)
bottom indicator window of Williams %R (period of 250)
tells me when market is in positive (+) or negative (-) territory.

step 2

is timing each move. here we focused on the buy side.
indicator window on center is MACD (12, 26, 9).
every time that the MACD line crosses ABOVE the signal line,
we have a buy. (and in this case we focus on 'buy' signals).
William %R must be stay above -20.
and every time the MACD recrosses back under the signal line,
that announces the end of that particular move.vice versa for sell william%R stays below -80 and macd crosses signal line with negative
it is not rocket science. we only have to follow the rules.
be constant. disciplined. and go in when it's time
and go out when it's time.

i think below screen shot explains you lot

buying screen shot



Selling screen shot

 
#9
Will keep an eye on the ever helping Happy Singh's AFL

Hollow down arrow is order to close long position, and not sell (short)
Hollow up arrow is cover and not fresh buy,

if you don't want to show them comment out the last line in the code by adding // before it


//PlotShapes(Sell*4+Cover*3,colorWhite,0,IIf(Sell,H,L));


as for false signals check the parameters on the price pane make sure the parameters on all the different panes match.

will try to post the code combined with ur MACD, meanwhile give it a try yourself . . .

Happy :)
Will do a run and share my success ratio -- thank you :)

yes two minutes:thumb::thumb::thumb:
 
#10
yes two minutes:thumb::thumb::thumb:
Since I am @office during trading times being using zerodha kite so here is the problem at hand. I have time-frame of a minute and three minute and beyond they have not provided 2 TF and it offsets the whole equation sadly. Snapshots would show what I am referring to :mad:

Three TF - No entry as William %R is below -20


One TF - No entry again as it offsets the setup completely
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?