Here is a code without GMACD.
By viewing a trade log It is correct.
But a short trade should have been on 12/05/06 but not on the daily TF.
Could you check log and chart and explain why.

Code:
function run(){
  
  set(LOGFILE);
  int MA_Period=80;
  var Deviation=0.1;
  int sMA, upper, down;
  

 
   vars sMA = series(SMA(series(priceClose(20)),MA_Period));
  var upper = sMA[0] * (1+Deviation/100);
   var down = sMA[0] * (1-Deviation/100);
   vars Close = series(priceClose());
    
  TakeProfit = 25*PIP;


if(crossOver(Close,upper)) {
  Stop = down - 10*PIP;
  enterLong();
}
if(crossUnder(Close,down)) {
  Stop = upper + 10*PIP;
  enterShort();
}
}