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

10 Day Moving Average System for Amibroker (AFL)

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

This is a simple system coded by legend Ed Pottasch on my request. Please test on at least five years’ data before using.

// Long Set up: Close above 10 Day (default) Simple Moving average (default)
// Long Entry: Close above the previous candle (which is above 10 Day SMA)
// Long Exit: Short Entry
// Short Set up: Close below 10 Day Simple Moving average
// Short Entry: Close below the previous candle (which is above 10 Day SMA)
// Short Exit: Long Entry

Similar Indicators / Formulas

Visual BackTest
Submitted by sethmo about 11 years ago
Nirvana XeL MOD 1.5a
Submitted by xel over 12 years ago
TD Setup
Submitted by ferpa over 11 years ago
Komunitas Modified
Submitted by tm832 about 14 years ago
NMA-swing-trading-system-NMA I.T v-3
Submitted by cnbondre over 14 years ago
TTS system V 4
Submitted by jaipal7786 almost 12 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("10 DMA system");
// Long Set up:  Close above 10 Day (default) Simple Moving average  (default)  
// Long Entry:  Close above the previous candle (which is above 10 Day SMA) 
// Long Exit: Short Entry     
// Short Set up:  Close below 10 Day Simple Moving average  
// Short Entry:  Close below the previous candle (which is above 10 Day SMA) 
// Short Exit:  Long Entry     

//SetTradeDelays(0,0,0,0);
//SetOption("CommissionMode",3);
//SetOption("CommissionAmount",2.01);
//SetOption("FuturesMode",True);
//NumContracts=1;
//PositionSize=NumContracts*MarginDeposit;
//SetOption("MaxOpenPositions",4);

procedure exit_proc(Buy,BuyPrice,Short,ShortPrice)
{
global BuyAdjusted;
global BuyPriceAdjusted;
global ShortAdjusted;
global ShortPriceAdjusted;
global SellAdjusted;
global SellPriceAdjusted;
global CoverAdjusted;
global CoverPriceAdjusted;
global LongStopTrail;
global ShortStopTrail;

BuyAdjusted=0;
BuyPriceAdjusted=0;
ShortAdjusted=0;
ShortPriceAdjusted=0;
SellAdjusted=0;
SellPriceAdjusted=0;
CoverAdjusted=0;
CoverPriceAdjusted=0;
LongStopTrail=Null;
ShortStopTrail=Null;
delay=1;

for(i=1;i<BarCount;i++) 
{
	if(Buy[i]) 
	{
		BuyAdjusted[i]=1;
		BuyPriceAdjusted[i]=BuyPrice[i];	
		for(j=i+delay;j<BarCount;j++) 
		{
			if(Short[j])
			{
				SellAdjusted[j]=1;
				SellPriceAdjusted[j]=C[j];
				i=j-1;
				break;
			}
			else if(j==BarCount-1) 
			{
				i=BarCount;
				break;				
			}			
		}
	}
	else if(Short[i]) 
	{
		ShortAdjusted[i]=1;
		ShortPriceAdjusted[i]=ShortPrice[i];	
		for(j=i+delay;j<BarCount;j++) 
		{
			if(Buy[j])
			{
				CoverAdjusted[j]=1;
				CoverPriceAdjusted[j]=C[j];
				i=j-1;
				break;
			}
			else if(j==BarCount-1) 
			{
				i=BarCount;
				break;				
			}				
		}
	}

}

}
per=Optimize("per",10,2,100,1);
sma=MA(C,per);

triggerLong=ValueWhen(Cross(C,sma),H);
Buy=Cross(C,triggerLong);BuyPrice=Close;
triggerShort=ValueWhen(Cross(sma,C),L);
Short=Cross(triggerShort,C);ShortPrice=C;

exit_proc(Buy,BuyPrice,Short,ShortPrice);
Buy=BuyAdjusted;
BuyPrice=BuyPriceAdjusted;
Short=ShortAdjusted;
ShortPrice=ShortPriceAdjusted;
Sell=SellAdjusted;
SellPrice=SellPriceAdjusted;
Cover=CoverAdjusted;
CoverPrice=CoverPriceAdjusted;

SetChartOptions(0,chartShowDates);
SetBarFillColor(IIf(C>O,ColorRGB(0,75,0),IIf(C<=O,ColorRGB(75,0,0),colorLightGrey)));
Plot(C,"\nPrice",IIf(C>O,ColorRGB(0,255,0),IIf(C<=O,ColorRGB(255,0,0),colorLightGrey)),64,0,0,0,0);
Plot(sma,"\nSMA",colorBlue,1);
Plot(triggerLong,"",colorGreen,styleDashed);
Plot(triggerShort,"",colorRed,styleDashed);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorDarkGreen,0,L,-15);
PlotShapes(IIf(Buy,shapeSmallCircle,shapeNone),colorWhite,0,BuyPrice,0);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);
PlotShapes(IIf(Sell,shapeSmallCircle,shapeNone),colorWhite,0,SellPrice,0);
PlotShapes(IIf(Short,shapeSmallDownTriangle,shapeNone),colorRed,0,H,IIf(Short AND Sell,-30,-15));
PlotShapes(IIf(Short,shapeSmallCircle,shapeNone),colorWhite,0,ShortPrice,0);
PlotShapes(IIf(Cover,shapeSmallUpTriangle,shapeNone),colorDarkGreen,0,L,IIf(Cover AND Buy,-30,-15));
PlotShapes(IIf(Cover,shapeSmallCircle,shapeNone),colorWhite,0,CoverPrice,0);
_SECTION_END();

4 comments

1. niklravi

hi
let me know where is the stoploss? to place

niklravi

2. jrajnikant

Please correct this line
Short Entry: Close below the previous candle (which is above 10 Day SMA)
as Short Entry: Close below the previous candle (which is below 10 Day SMA)

3. sonyhiren11

@niklravi, no stoploss here. you reverse the position at signal but wait for the candle to close.

@jrajnikant. Dont know how to edit. Admin please guide or do the needful.

Thanks

4. niklravi

hi
if u never mind send some trade charts to my mail id ravinikl@yahoo.com

regards
ravi
qatar

Leave Comment

Please login here to leave a comment.

Back