Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Positional Tread for Amibroker (AFL)

Rating:
3 / 5 (Votes 5)
Tags:
trading system, amibroker, timeframe

i had posted this study at Wise stocktreaders with some different condition…

http://www.wisestocktrader.com/indicators/3033-buy-sell-signals-with-6-tgt

i found there is many s/l when trend changes or tread changes….!

so, tried to resolves much more s/l tread….

In Hope, Positional treader would love this study….!

Similar Indicators / Formulas

Intraday / Positional Signals
Submitted by Divyesh over 11 years ago
5 day high low system
Submitted by anandmoorti over 11 years ago
Multiple Trend
Submitted by ecredic over 11 years ago
Candlestick with buy sell
Submitted by lab1234u over 12 years ago
Three-Bar Inside Bar Pattern
Submitted by EliStern about 13 years ago
EMA System Ribbon
Submitted by yo123 about 13 years ago

Indicator / Formula

Copy & Paste Friendly
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));
GfxSetBkMode(0); 
GfxSetOverlayMode(1);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);

SetTradeDelays(1,1,1,1);
 
 
_SECTION_BEGIN("Trade triangle-traderzone"); 
TimeFrameSet(in15Minute);
HMAA = Param("H-MA1", 12, 2, 30, 1, 10 );
H2 = MA(C, HMAA );
Hc=C;
TimeFrameRestore();
Hp=TimeFrameExpand(H2,in15Minute,expandFirst);
hc=TimeFrameExpand(hc,in15Minute,expandFirst);
//Plot(C,"",IIf(Hc>Hp,colorBrightGreen,colorDarkRed),64);
 
TimeFrameSet(in15Minute);
DMAA = Param("D-MA",250, 2, 500, 1, 10 );
DP = MA(C, DMAA );
Dc=C;
TimeFrameRestore();
dp=TimeFrameExpand(DP,in15Minute,expandFirst);
dc=TimeFrameExpand(Dc,in15Minute,expandFirst);
 
Plot( Hp,"HMA",IIf(hp>dp,colorLime,colorRed),styleLine);
Plot(dp ,"DMA",colorWhite,styleLine);

Buy=Cross(Hp,dp);
Sell=Cross(dp,Hp);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-100);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-110);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-105); 
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=100);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=110);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-105);
_SECTION_BEGIN("L.T.P.");
cx = Param( "cxposn", 1000, 0, 1250, 1 );
cy = Param( "cyposn", 25, 0, 500, 1 );
GfxSelectFont( "Candara", 18, 98, False );
GfxSetBkColor( colorBlack );
GfxSetTextColor( colorWhite );
GfxTextOut( "L.T.P.  " + C + " ", cx, cy );
_SECTION_END();

_SECTION_BEGIN("Title");

DODay = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily); 
DLoDay = TimeFrameGetPrice("L", inDaily); 

Title = EncodeColor(colorWhite)+"* Long Buy Sell Signals *  "+EncodeColor(colorWhite)+ Name() + ", " + Interval(2) + ", " + Date() + 
EncodeColor(colorWhite)   +  "\nO " + EncodeColor(colorWhite) + O + 

 ",   H :  "   + H + 
 ",   L  :  " + L + 
 ",   C  :  "  + C +
EncodeColor(colorWhite)+ "\n Day-Open : " +DODay + "  Day-High : " +DHiDay + "  Day-Low : " + DLoDay +
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+"  ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+"  ","")+"\n"+EncodeColor(colorYellow)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy  , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","");



_SECTION_BEGIN("Background text");
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Candara", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( "By", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (103,103,103));
GfxTextOut( "Sai Stock Broking 09825340778", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
_SECTION_END();
SetChartBkColor(colorBlack);
Factor=Param("Factor",3,1,10,1);
Pd=Param("ATR Periods",10,1,100,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;

for (i = 1; i <BarCount; i++) {
      TrendUp[i] = Null;
      TrendDown[i] = Null;
     
      trend[i]=1;
   
      
      if (Close[i]>Up[i-1]) {
         trend[i]=1;
         if (trend[i-1] == -1) changeOfTrend = 1;
         
      }
      else if (Close[i]<Dn[i-1]) {
         trend[i]=-1;
         if (trend[i-1] == 1) changeOfTrend = 1;
      }
      else if (trend[i-1]==1) {
         trend[i]=1;
         changeOfTrend = 0;       
      }
      else if (trend[i-1]==-1) {
         trend[i]=-1;
         changeOfTrend = 0;
      }

      if (trend[i]<0 && trend[i-1]>0) {
         flag=1;
      }
      else {
         flag=0;
      }
      
      if (trend[i]>0 && trend[i-1]<0) {
         flagh=1;
      }
      else {
         flagh=0;
      }
      
      if (trend[i]>0 && Dn[i]<Dn[i-1]){
         Dn[i]=Dn[i-1];
		}
      
      if (trend[i]<0 && Up[i]>Up[i-1])
        { Up[i]=Up[i-1];
		}
      
      if (flag==1)
       {  Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);;
        } 
      if (flagh==1)
        { Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
         }
      if (trend[i]==1) {
         TrendUp[i]=Dn[i];
         if (changeOfTrend == 1) {
            TrendUp[i-1] = TrendDown[i-1];
            changeOfTrend = 0;
         }
      }
      else if (trend[i]==-1) {
         TrendDown[i]=Up[i];
         if (changeOfTrend == 1) {
            TrendDown[i-1] = TrendUp[i-1];
            changeOfTrend = 0;
         }
      }
   } 

TrendSL=IIf(trend==1,TrendUp,TrendDown);

for(i=BarCount-1;i>1;i--)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = "BUY";
sl = TrendSL[i];
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0099);
tar3 = entry + (entry * .0149);
tar4 = entry + (entry * .0210);
tar5 = entry + (entry * .0269);
tar6 = entry + (entry * .0325);
bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = "SELL";
entry = C[i];
sl = TrendSL[i];
tar1 = entry - (entry * .0050);
tar2 = entry - (entry * .0099);
tar3 = entry - (entry * .0149);
tar4 = entry - (entry * .0210);
tar5 = entry - (entry * .0269);
tar6 = entry - (entry * .0325);

 
 
bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1));
sl = ssl[BarCount-1];
 

Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar4, BarCount, tar4,1), "", Clr, styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar5, BarCount, tar5,1), "", Clr, styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar6, BarCount, tar6,1), "", Clr, styleLine, Null, Null, Offset);



//Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);
Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorGreen, styleLine|styleLine, Null, Null, Offset);
 
for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount+1,entry,Null,colorBlue);
PlotText("T1@"+tar1,BarCount+3,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount+3,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount+3,tar3,Null,Clr);PlotText ("T4@"+tar4,BarCount+3,tar4,Null,Clr);PlotText ("T5@"+tar5,BarCount+3,tar5,Null,Clr);PlotText ("T6@"+tar6,BarCount+3,tar6,Null,Clr);



 
}
 
messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
 
if ( sig =="BUY")
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;
 
y = pxHeight;
 
GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y - 98, x2, y , 7, 7 ) ;
GfxTextOut( ( "                                                     * Sai Stock  * Long Buy Sell Signals *"),13,y-100);
GfxTextOut( (" "),27,y-100);
GfxTextOut( ("                                                       Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-80) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="                                BUY",sig + "                     @ ",sig + "                                      @") + " : " + entry), 13, y-60);
//GfxTextOut( ("                                               Trailing SL : " + TrendSL + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-40);
/*GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);*/
GfxTextOut( ("                                            Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-22);;
 
}

_SECTION_END();


/*Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
PlotShapes(shapeHollowUpArrow * Buy,colorBrightGreen,0,L, Offset=-45);
PlotShapes(shapeHollowDownArrow * Sell,colorRed,0,H, Offset=-45);
AlertIf( Sell, "SOUND C:\\Windows\\Media\\chord.wav", "Audio alert", 2 );
AlertIf( Buy, "SOUND C:\\Windows\\Media\\chord.wav", "Audio alert", 2 );

_SECTION_BEGIN("L.T.P.");
cx = Param( "cxposn", 1000, 0, 1250, 1 );
cy = Param( "cyposn", 25, 0, 500, 1 );
GfxSelectFont( "Candara", 18, 98, False );
GfxSetTextColor( colorWhite );
GfxTextOut( "L.T.P.  " + C + " ", cx, cy );
_SECTION_END();

24 comments

1. anandnst

Lots of errors found in this formula.. cant plot it.

2. Divyesh

Dear Anandnst, there must be any other problem because this is modified formula which had been posted here and working properlly with my Amibroker and even with Admin’s Amibroker….!!!

3. anup82

yes error in 5.40 check it

4. shariful

No error in my older ami 5.30, click copy+paste friendly, then copy +paste, might work if no other problem in Ami.

5. Rakesh Kumar

No Error in Ami 5.30 working fine.

6. persee

you must put this 2 lines

flag=flagh=bars=tar1=tar2=tar3=tar4=tar5=tar6=entry=0;
sig="";

after this lien

changeOfTrend=0;

7. Divyesh

Thnx persee…!

i am not a coder or afl laungage expert, but just a mixecer and trying to innovate something batter without knowledge of programming or AFL, so i dont know your suggestion how works. after copy paste your code i dint find any change….!

if you know the AFL and can do work please mail me on vadukardivyesh@yahoo.com

i have many things in my mind but i cant write on papper….!!
even i have some good MT4 codes for intraday but cant write in AFL….

this request is not only for persee, but any experts can help me….

Thnx.

Divyesh

8. Divyesh

@ Anup82, Please use the procedure what shariful says….

9. sampathsaran

It is working
Credit goes to Mr.persee (WiseStockTrader.com Member )

10. Mayur

Mr.persee sir kindly mail my email milu.trivedi@gmail.com

11. kv_maligi

Hi,

This kind of AFL, having multiple targets & not having buy/sell strength won’t work. why? Psyche creates havoc and You end up booking small profits & giving big losses to market.

Be careful

Thanks
Viswanath

12. navin
hi,

i have so many problem in afl
if somebody no problem then send your correct AFl me at navinpatel4u@yahoo.com thanking for your cooperation…….navin

13. waelalamoudi

hi Divyesh
it’s error my ami is 5.50

14. anup82

yes now work all is well in above afl 106 line after copy past below 2 line
107-flag=flagh=bars=tar1=tar2=tar3=tar4=tar5=tar6=entry=0;
108-sig="";
cradit gose to persee & Divyesh now worked 5.40 thanks to all

15. Divyesh

Yess Anup82, So kindness of persee sir……

he is so kind as i m not coder or AFL expert…..! so he helped us….!

thank you once again persee sir…..

16. Divyesh

@ waelalamoudi,
Sir will you please copy paste the two line which persee sir had wrote….?
this will solve your problem….
thank you

17. sjagadish4u

very nice. what is the most suitable timeframe especially for banknifty

18. Divyesh

@sjagdish4u,

Sir, 15 min is ideal time frame as per my knowledge…

we can do more one thing is we can reduce our position at 3rd and 6th tgt……

19. tigernifty

Dear Divyesh, if you have some time, try to write Positional Tread AFL to EXPLORATION.. it is usefull for find the stock easily u know..
thank you..

20. sjagadish4u

thanks

21. kirthi1987

error has been sloved but afl is not opening properly pls slove the problem

22. Divyesh

@tigernifty,

Dear friend, as i wrote in my presentation, i am not a coder or AFL laungage expert.
i m just trying to do something without knowledge of AFL laungage.
thank God without knowledge, doing something.
even i am making request to everyone at this site, if there is fault in formula plase solve the problem as persee sir had done…..!

we are hear to help eachother. the basic aim of this site…!

m i right Mr.Admin…?

so please Mr. tigernifty, i dint understand what you are asking for…..!

if you will do it it will for everyone…..!

thax.

23. Divyesh

@kirthi1987,
Will you please go through the process which had been discussed above…..?
that will solve every problem…..
thnx….

24. kirthi1987

thanq u

Leave Comment

Please login here to leave a comment.

Back