This is the code and below is an attachment of mt4 chart indicating the recent trades executed by the same script, Note that the recent trades were not triggered by a cross of the SMAs but something else im not sure of. Kindly assist me perfect this.....
function run()
{


StartDate = 2005;
BarPeriod = 60;
Lots = 30;
MaxLong = 1;
MaxShort = 1;
//EntryTime =

vars Close = series(priceClose());
vars SMAFast = series(SMA(Close, 5));
vars SMASlow = series(SMA(Close, 15));


if(crossOver(SMAFast, SMASlow))
enterLong();

else if(crossUnder(SMAFast, SMASlow))
enterShort();

Stop = 5 * ATR(100);
Trail = 4*ATR(100);

for(open_trades)
if(TradeIsOpen && !TradeIsPool && TradeProfit > 0) {
TradeTrailLock = 0.80; // 80% profit (minus trade costs)
if(TradeIsShort)
TradeTrailLimit = max(TradeTrailLimit,TradePriceClose);
else
TradeTrailLimit = min(TradeTrailLimit,TradePriceClose);
}



}