function tradeOneNightStand() {
vars Price = series(price());
vars SMAShort = series(SMA(Price, optimize(10,5,20)));
vars SMALong = series(SMA(Price, optimize(40,30,80,5)));
Stop = optimize(100,100,500,10) * PIP;
var BuyStop = HH(10) + 1*PIP;
var SellStop = LL(10) - 1*PIP;
if(between(tow(),42355,50005)) {
if (SMAShort[0] > SMALong[0] && rising(SMAShort) && rising(SMALong) && NumOpenLong == 0 && NumPendingLong == 0) {
Margin = 0.1 * OptimalFLong * Capital * sqrt(1 + ProfitClosed/Capital);
enterLong(0,BuyStop);
}
else if (SMAShort[0] < SMALong[0] && falling(SMAShort) && falling(SMALong) && NumOpenShort == 0 && NumPendingShort == 0) {
Margin = 0.1 * OptimalFShort * Capital * sqrt(1 + ProfitClosed/Capital);
enterShort(0,SellStop);
}
}
if (dow() != 4 && dow() != 5 && dow() != 6) {
exitLong();
exitShort();
}
}