Skip to main content

Moving Average Trading System with optimization and exploration for Amibroker (AFL)

marcheur almost 13 years ago Amibroker (AFL)

  • Rating:
    3 / 5 (Votes 4)
  • Tags:
    trading system, amibroker, exploration

This is a simple code to optimize and backtest price/ moving average crossover Buy-Sell signals after a certain percentage move above or below MA line.

Indicator / Formula

Copy & Paste Friendly
Perc=Optimize("Percentage Tolerance",1,0,4,0.1);
MAP=Optimize("MA Length", 12,12,150,5);

PercentageP=1+(perc/10);
PercentageN=1-(perc/10);
Buy= Cross(C,(MA(C,MAP)*PercentageP));
Sell= Cross((MA(C,MAP)*PercentageN),C);

Plot(C,"Close",colorWhite,64);
Plot(MA(C,MAP),"",colorBlue,1);

Filter=Buy OR Sell; 



AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," Sell Signal ",6.2,1.2,colorOrange); 

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );

0 comments

Leave Comment

Please login here to leave a comment.