# help with the first 30 minutes trade

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
arnie
Posts: 1590
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 479 times
Been thanked: 509 times

### help with the first 30 minutes trade

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");`

TJ
Posts: 6873
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 984 times
Been thanked: 1976 times

### Re: help with the first 30 minutes trade

...
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...

arnie
Posts: 1590
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 479 times
Been thanked: 509 times

### Re: help with the first 30 minutes trade

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 ) 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");`

TJ
Posts: 6873
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 984 times
Been thanked: 1976 times

### Re: help with the first 30 minutes trade

Hi TJ.

As far as I can see, problem solved, though, if you're able to detect (with your expert eyes ) 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.