// Downloaded From https://www.WiseStockTrader.com
//This function to calculate Fraction Price in Amibroker for Indonesia Stock Exchange Stocks

function FraksiPrice(price) 
{ 
	Fraksi = IIf(Price<200,1,IIf(Price>=200 AND Price <500,2,IIf(Price>=500 AND Price<2000,5,IIf(Price>=2000 AND Price<5000,10,25))));
	Result = Price - (Price%Fraksi);
	return result;
}

function PriceAdj(price,adj) 
{ 
	Fraksi = IIf(Price<200,1,IIf(Price>=200 AND Price <500,2,IIf(Price>=500 AND Price<2000,5,IIf(Price>=2000 AND Price<5000,10,25))));
	Result = Price + (Adj*Fraksi);
	return result;
}


// Example to calculate StopLoss with 2 ticks below MA20
StopLoss = PriceAdj(FraksiPrice(MA(C,20)),-2);