Reviving this thread. This is still a huge problem for me.

These two scripts give different results. Can anyone explain why? The only difference is the order that adviseLong+enterLong and adviseShort+enterShort appear in the code.

adviseLong first --> Annual +9% +555p
adviseShort first --> Annual +37% +985p

Code:
string selected_asset;

//#define SHORTFIRST

var EntryL;
var EntryS;
var TrailL;
var TrailS;

function run() {
  if (is(INITRUN)) {
    BarPeriod = 127;
    LookBack = 501;
    StartDate = 20130601;
    EndDate = 20131230;
    set(NFA + TICKS + MUTE);    
    set(RULES);
    set(FACTORS);
    set(TESTNOW + PLOTNOW);
    
    if (Train) {
      Hedge = 2;
      Detrend = 1;
    } else {
      Hedge = 4;
      Detrend = 0;
    }
    TradesPerBar = 2;
    Weekend = 1;
    EntryTime = 1;
    ExitTime = 24 * 60 / BarPeriod;
    NumWFOCycles = 3;
  }

  while(selected_asset = loop("AUD/CHF", "CAD/JPY", "EUR/AUD")) {
    asset(selected_asset);

    var atrx = ATR(329);

    EntryL = 1.6;
    EntryS = 1.6;
    TrailL = 1.2;
    TrailS = 1.2;

    var v00 = WillR(102);
    var v01 = CCI(192);
    vars Price = series(price());
    var v02 = HighPass(Price, DominantPeriod(Price, 7));
    
    plot("v00", v00, NEW+LINE, BLUE);
    plot("v01", v01, NEW+LINE, BLUE);
    plot("v02", v02, NEW+LINE, BLUE);

#ifdef SHORTFIRST
    if (adviseShort(PERCEPTRON, 0, v00, v01, v02) > 0) {
      Entry = EntryS * atrx;
      Trail = TrailS * atrx;
      enterShort();
    }
#endif
    if (adviseLong(PERCEPTRON, 0, v00, v01, v02) > 0) {
      Entry = EntryL * atrx;
      Trail = TrailL * atrx;
      enterLong();
    }
#ifndef SHORTFIRST
    if (adviseShort(PERCEPTRON, 0, v00, v01, v02) > 0) {
      Entry = EntryS * atrx;
      Trail = TrailS * atrx;
      enterShort();
    }
#endif
  }
}