Attached is a screen shot with an example. I need to optimize an input, call it Nsessions, that looks at the highest Session High and Lowest Session Low for a given period, IE up to the maximum allowed by the native OHLC / HighS LowS array, which is 50 sessions if I am not mistaken. I need this for Data2 as a filter for a Data1 entry. I'll start with the basics of how to accomplish this and figure out the Data2 issue later.
Here is what I have come up with so far, using a 'for' statement, HH,LL are numeric variables, nsess is an input to test up to 20 sessions:
Code: Select all
inputs: nsess ( 15 );
var: hh ( 0 ), ll ( 0 );
hh = -99999999999; ll = 99999999999;
if nSess>1 then begin
for value90 = 1 to nSess begin
hh = maxlist(hh,HighS(value90));
ll = minlist(ll,LowS(value90));
end;
end
else if nSess=1 then begin
hh = highS(1);
ll = LowS(1);
end;
buy("LE") next bar hh stop;
sellshort("SE") next bar ll stop;