Page 1 of 1

help with the first 30 minutes trade

Posted: 29 Nov 2009
by arnie
I'm trying to do something simple, to plot the first 30 minutes range of a trading day.

At the beginning, things were quite simple, I would need to indicate each new trading day and within, each 30 minute range.

So, after doing that, why is the high and low being plotted for the entire trading day and not only for the selected 30 minute range?

What am I missing?

Regards,
Fernando


Code: Select all

Inputs:
startTime (930),
endTime (1000);

variables:
stTime (false),
sessHi (-999999),
sessLo (+999999),
sessOp (0),
hiValue (0),
loValue (0);

if Date <> Date[1] then begin
if time > startTime and time < endTime then begin
stTime = true;
sessHi = -999999;
sessLo = +999999;
end;
sessOp = Open;
end;


if stTime then begin
if High > SessHi then
SessHi = High;
if Low < SessLo then
SessLo = Low;
hiValue = SessHi;
loValue = SessLo;
end;


if hiValue <> 0 then
plot1(hiValue,"Session High");
if loValue <> 0 then
plot2(loValue,"Session Low");
if sessOp <> 0 then
plot3(sessOp,"Session Open");

Re: help with the first 30 minutes trade

Posted: 29 Nov 2009
by TJ
...
So, after doing that, why is the high and low being plotted for the entire trading day and not only for the selected 30 minute range?
...[/code]

because you did not tell MC to stop plotting...

Re: help with the first 30 minutes trade

Posted: 01 Dec 2009
by arnie
because you did not tell MC to stop plotting...
Hi TJ.

As far as I can see, problem solved, though, if you're able to detect (with your expert eyes :wink: ) something that could cause some trouble, please let me know.

Thanks.

Regards,
Fernando


Code: Select all

Inputs:
startTime (930),
endTime (1000);

variables:
stTime (false),
sessOpen (false),
sessHi (-999999),
sessLo (+999999),
sessOp (0),
hiValue (0),
loValue (0);

if date <> date[1] then begin
sessHi = -999999;
sessLo = +999999;
stTime = false;
sessOpen = false;

end;

if time > startTime and time < endTime then begin
if stTime = false then
stTime = true;

if time < endTime then begin
if High > SessHi then
SessHi = High;
if Low < SessLo then
SessLo = Low;
hiValue = SessHi;
loValue = SessLo;

if sessOpen = false then begin
sessOpen = true;
sessOp = open;
end;

end;
end;

if hiValue <> 0 then
plot1(hiValue,"Session High");
if loValue <> 0 then
plot2(loValue,"Session Low");
if sessOp <> 0 then
plot3(sessOp,"Session Open");

Re: help with the first 30 minutes trade

Posted: 01 Dec 2009
by TJ
Hi TJ.

As far as I can see, problem solved, though, if you're able to detect (with your expert eyes :wink: ) something that could cause some trouble, please let me know.

Thanks.

Regards,
Fernando

I haven't test run your code...

one suggestion:

When writing codes... think in terms of

IF
THEN

ELSE


most bugs happen because people have not thought through the ELSE element.