Hi folks,
I'm trying to code a scalp method that's a quite simple, buy when price's cross up the EMA of 23 periods, the sell signal is given on profit target or stop loss by ApplyStop, but i don't want to trade all day, just to get a static amount and then stop the method until next day.
I'm trying to use a StaticVar to sum the gains but it seems to don't be working, here's the AFL:
Any ideias?
I'm trying to code a scalp method that's a quite simple, buy when price's cross up the EMA of 23 periods, the sell signal is given on profit target or stop loss by ApplyStop, but i don't want to trade all day, just to get a static amount and then stop the method until next day.
I'm trying to use a StaticVar to sum the gains but it seems to don't be working, here's the AFL:
Code:
SetOption("ActivateStopsImmediately", False);
SetOption("ReverseSignalForcesExit",False);
SetOption("FuturesMode", True);
Short = Cover = 0;
BuyPrice= Close;
PositionSize= MarginDeposit = 1;
MaxGain = StaticVarGet ("MaxGain");
MaxGain= Iif (
Day() != Ref(Day(),-1),
0,
Maxgain
);
Buy = Iif (
MaxGain < 130,
Cross(Close, EMA(Close,23)),
0
);
ApplyStop(0,1,70,1,False0);
ApplyStop(0,2,270,1,False,0);
Sell = 0;
TradeGain = MaxGain + ValueWhen(Sell,SellPrice,1);
MaxGain = TradeGain;
StaticVarSet ("MaxGain", MaxGain);