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

oz trail for Amibroker (AFL)

Copy & Paste Friendly
procedure exit_proc(Buy,BuyPrice,TrailLevel,StopLevel)
{
global BuyHelpArray;
global BuyPriceHelpArray;
global SellHelpArray;
global SellPriceHelpArray;
global LongStopTrailArray;
global FlagStorageArray;

BuyHelpArray=0;
BuyPriceHelpArray=0;
SellHelpArray=0;
SellPriceHelpArray=0;
LongStopTrailArray=Null;
FlagStorageArray=0;

delay=1;
slip=TickSize*0;

for(i=1;i<BarCount;i++) 
{
	if(Buy[i]) 
	{
		BuyHelpArray[i]=1;
		BuyPriceHelpArray[i]=BuyPrice[i]+slip;	
		LongStopTrailArray[i]=BuyPriceHelpArray[i]-BuyPriceHelpArray[i]/100*StopLevel;
		LongStopTrailArray[i-1]=LongStopTrailArray[i];
		FlagStorageArray[i]=1;
		
		for(j=i+delay;j<BarCount;j++) 
		{	
			LongStopTrailArray[j]=Max(H[j-1]-H[j-1]/100*TrailLevel,LongStopTrailArray[j-1]);
			if(LongStopTrailArray[j]<=LongStopTrailArray[i]) FlagStorageArray[j]=1;
			else FlagStorageArray[j]=2;
			
			if(FlagStorageArray[j]==1 AND L[j]<LongStopTrailArray[j])
			{
				SellHelpArray[j]=1;
				SellPriceHelpArray[j]=LongStopTrailArray[j]-slip;
				i=j;
				break;	
			}
			else if(FlagStorageArray[j]==2 AND C[j-1]<LongStopTrailArray[j-1])
			{
				SellHelpArray[j]=1;
				SellPriceHelpArray[j]=O[j]-slip;
				i=j;
				break;
			}
			else if(j==BarCount-1) 
			{
				i=BarCount;
				break;				
			}
		}
	}
}
}

//SetBarsRequired(sbrAll,0);
TrailLevel=Param("Trail stop %",20,5,20,1);
StopLevel=Param("Stop loss %",5,5,20,1);

Buy=Cross(EMA(Close,10),EMA(Close,25));
Buy=Ref(Buy,-1);BuyPrice=Open;

exit_proc(Buy,BuyPrice,TrailLevel,StopLevel);
Buy=BuyHelpArray;
BuyPrice=BuyPriceHelpArray;
Sell=SellHelpArray;
SellPrice=SellPriceHelpArray;

GraphXSpace=5;SetChartBkColor(ColorRGB(0,0,0));SetChartOptions(0,chartShowDates);
SetBarFillColor(IIf(C>O,colorGreen,IIf(C<=O,colorRed,colorLightGrey)));
Plot(C,"Price",IIf(C>O,colorDarkGreen,IIf(C<=O,colorDarkRed,colorLightGrey)),64,0,0,0,0);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorDarkGreen,0,L,-15);
PlotShapes(IIf(Buy,shapeSmallCircle,shapeNone),colorLightBlue,0,BuyPrice,0);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);
PlotShapes(IIf(Sell,shapeSmallCircle,shapeNone),colorYellow,0,SellPrice,0);
Plot(LongStopTrailArray,"",IIf(FlagStorageArray==1,colorRed,colorBlue),1);
Back