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

Reverse Force Index for Amibroker (AFL)

Rating:
5 / 5 (Votes 2)
Tags:
amibroker, trading system, stop loss

Hi there. Here I do a reverse of the Force index rule. But the main kicker is the trail stop mechanism. So as long as your system is positive, you can kick it up using the trailing mechanism. The trailing stop is from the EMA SMA CROSSOVER found here.
However now the signal is too many.. need to find way to tune down. Any feedback and suggestion is welcome.

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Reveerse Force Index");
SetPositionSize(1000,spsShares);

Period1=Optimize("Period1",17,1,20,1);
Period2=Optimize("Period2",5,2,20,1);
L1=Optimize("L1",-310000,-500000,50000,10000);
L2=Optimize("L2",-410000,-500000,50000,10000);

FI =((Close - Ref(Close, -1)) * V);
FastAvgFI=LinearReg(FI,Period1);
SlowAvgFI=LinearReg(FI,Period2);
FI_Col = IIf( (FI <Ref(FI,-1)), colorRed, colorBrightGreen);
FastAvgFI_Col = IIf(FastAvgFI < 0, colorRed, colorBlue);
SlowAvgFI_Col = IIf(SlowAvgFI < 0, colorRed, colorBlue);

Plot(FI, "Force Index", FI_Col, styleHidden|styleThick);
Plot(FastAvgFI, "FastAvgFI", FastAvgFI_Col, styleLine|styleThick);
Plot(SlowAvgFI, "SlowAvgFI", SlowAvgFI_Col, styleLine|styleThick);
Plot(0,"", colorViolet, styleLine | styleThick );


Buy1=((Cross(0,FastAvgFI))OR (Cross(0,SlowAvgFI)AND FastAvgFI<SlowAvgFI)); //(Cross(SlowAvgFI,L1))AND (FastAvgFI>L2) ;
Sell1= (Cross(SlowAvgFI,L1))AND (FastAvgFI>L2); //((Cross(0,FastAvgFI))OR (Cross(0,SlowAvgFI)AND FastAvgFI<SlowAvgFI));
Buy= Buy1;
Sell= Sell1;
Cover= 0;
Short= 0;
//Long=Flip(Buy,Sell);
//Shrt=Flip(Sell,Buy );

SL=Param("trailing stop %", 0.4, 0.1, 10, 0.1);
StopLevel1 = 1 - SL/100;
StopLevel2 = 1 + SL/100;
trailARRAY =trailARRAYs= Null;
trailstop =tstop= 0;

trailARRAY =trailARRAYs= Null;
trailstop =tstop= 0;
for( i = 1; i < BarCount; i++ )
{

   if( trailstop == 0 AND Buy[ i ] ) 
   { 
      trailstop = High[ i ] * stoplevel1;
   }
   else Buy[ i ] = 0; // remove excess buy signals

   if( trailstop > 0 AND (Low[ i ] < trailstop OR Sell1[i]) )
   {
      Sell[ i ] = 1;
      SellPrice[ i ] = trailstop;
      trailstop = 0;
   }

   if( trailstop > 0 )
   {   
      trailstop = Max( High[ i ] * stoplevel1, trailstop );
      trailARRAY[ i ] = trailstop;
   }
	if( tstop == 0 AND Short[ i ]) 
   { 
      tstop = Low[ i ]*stoplevel2;
   }
   else Short[ i ] = 0; // remove excess buy signals

   if( tstop > 0 AND (High[i]>tstop OR Buy1[i]) )
   {
      Cover[ i ] = 1;
      CoverPrice[ i ] = tstop;
      tstop= 0;
   }

   if( tstop> 0 )
   {   
      tstop= Min( Low[ i ]*stoplevel2, tstop);
      trailARRAYs[ i ] = tstop;
   }
}

PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorRed, 0, High, Offset = -25 );
PlotShapes( IIf( Buy, shapeUpArrow , shapeNone ), colorBrightGreen, 0, Low, Offset = -25 );

Title = Name() +
EncodeColor(colorRed) + " Close " +
EncodeColor(colorRed) + " = " + WriteVal(Close) + ", " +
EncodeColor(colorRed) + "Force Index = " +
EncodeColor(colorRed) + WriteVal(FI);
_SECTION_END();

0 comments

Leave Comment

Please login here to leave a comment.

Back