How to set a limit gain for a day in a setup?

#1
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:

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);
Any ideias?
 
#2
Uoah, this should be hard...

In a more simply explanation, what I need it's get the SellPrice array when ApplyStop acts on gain or loss, its someway to do that Pro's ?

Thanks.
 

Similar threads