find stocks that perform better than bank interest rate

#1
hi friends
Looking to code an afl that shows stocks that fare better than investment in bank fixed deposit.

banks give 8% interest in a year.
if the stock appreciates more than 8% then it is worth investing in the stock.


regards
here is a stoploss code based on 8%.
we begin here.
doubts
compute 8% rise from which starting point? reasonable & fair starting point must.
how do you compare stock appreciation on chart.

HTML:
//Formula Name: Stops on percentages 
//Author/Uploader: Chris -  


// code from http://www.amibroker.com/kb/2007/03/24/how-to-plot-a-trailing-stop-in-the-price-chart/
// I added the short side and some options. Just drag and drop onto a price chart

_SECTION_BEGIN("Long Short % Stop");
//---long var
Stoplong = 1 - Param("stop % Long", 8, 0.1, 20, 0.1)/100;
Plong = ParamField("Price Field Long");
Longcol= ParamColor( "Color Long Stop", colorCycle );
Buy = 1;//Change for your long signal eg Short=Cross(ma(c,10),ma(c,20));


Sell = 0;
traillongARRAY = Null;
trailstoplong = 0;

//----short var


StopLevel = 1 - Param("Stop Short %", 8, 0.1, 20, 0.1)/100;
P = ParamField("Price Field Short");
Shortcol=ParamColor( "Color Short Stop", colorCycle );
Short =1; // Change for your short signal eg Short=Cross(ma(c,20),ma(c,10));
Cover = 0;
trailARRAY = Null;
trailstop = 0;

//---calculate
for( i = 2; i < BarCount; i++ )
{
//---long
   if( trailstoplong == 0 AND Buy[ i ] ) 
   { 
      trailstoplong =Plong[ i ] * Stoplong;
   }
   else Buy[ i ] = 0; // remove excess buy signals

   if( trailstoplong > 0 AND Plong[ i ] < trailstoplong )
   {
      Sell[ i ] = 1;
      SellPrice[ i ] = trailstoplong;
      trailstoplong = 0;
   }

   if( trailstoplong > 0 )
   {   
      trailstoplong = Max( Plong[ i ] * Stoplong, trailstoplong );
      traillongARRAY[ i ] = trailstoplong;
   }


//---short


   if( trailstop == 0 AND Short[ i ] ) 
   { 
    
trailstop = P[ i ] / StopLevel;// set intinal % stop then trailing stop takes over

   }
   else Short[ i ] = 0; // remove excess short signals

   if( trailstop > 0 AND P[ i ] > trailstop )
   {
      Cover[ i ] = 1;
      CoverPrice[ i ] = trailstop;
      trailstop = 0;
   }

   if( trailstop > 0 )
   {   
      trailstop = Min(P[ i ]/ stoplevel, trailstop );
      trailARRAY[ i ] = trailstop;
   }

}

// ----display results

Plot( traillongARRAY," 8%Stop Long",Longcol );
Plot( trailARRAY,"8%Stop Short", shortcol );

//PlotShapes(Short*shapeUpArrow,ParamColor( "Arrow Short Color", colorCycle),0,Low);
//PlotShapes(Cover*shapeDownArrow,ParamColor( "Arrow Cover Color", colorCycle),0,High);
//PlotShapes(Buy*shapeUpArrow,ParamColor( "Arrow Buy Color", colorCycle),0,Low);
//PlotShapes(Sell*shapeDownArrow,ParamColor( "Arrow Sell Color", colorCycle),0,High);

//Plot( Close,"Price",colorBlack,styleBar);

Plot(C," ",IIf(C>Open,colorBrightGreen,colorRed),128+4);
 
Last edited:

whisky

Well-Known Member
#3
Good start
 
#4
here is a simple afl.
HTML:
Plot(C," ",IIf(C>Open,colorBrightGreen,colorRed),128+4);
TOTAL8 =LLV(L,252)*1.08 ;

Plot(TOTAL8,"TOTAL252D LOW 8PCT",colorRed,8+16);
it plots 8% increase on 252day low price.
if stock can beat these red dots then it is a good stock

 
Last edited:
#5
u mean TATAMOTORS lol
relax just teasing
 

Similar threads