Hello to the group. 
I am trying to work out the best way of returning a value to "Buy" AND 
"BuyPrice" from inside a (for,if) loop. My original system had only one buy 
condition and a loop containing several different exit conditions, fixed profit 
target, stoploss, if top of range hit, etc...
I have now included several Buy conditions, based on rangebands above and below 
a moving average. See hypothetical code sample below...

band2 = MA(C,7) - 10;
band1 = MA(C,7) - 20;

cond1 = Ref(c,-1)>band1 AND Ref(C,-1)<band2 AND O>band1 AND O<band2;
cond2 = Ref(c,-1)>band2 AND Ref(C,-1)<MA(C,7) AND O>band2 AND O<MA(C,7);

If cond1==1 AND L<band1, Buy=1; BuyPrice=band1; // Set P.T + S.L.
If cond2==1 AND L<Band2, Buy=1; BuyPrice=band2; // Set P.T + S.L.
Etc......

I do not want to use IIf or SigScaleIn
Dont worry about p.t. and s.l. I will write the exit conditions later. 

Any help or relevant code samples are very much appreciated.
Chris.

Reply via email to