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!
User avatar
arnie
Posts: 1581
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 472 times
Been thanked: 508 times

help with the first 30 minutes trade

Postby arnie » 29 Nov 2009

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

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: help with the first 30 minutes trade

Postby TJ » 29 Nov 2009

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

User avatar
arnie
Posts: 1581
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 472 times
Been thanked: 508 times

Re: help with the first 30 minutes trade

Postby arnie » 01 Dec 2009

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

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: help with the first 30 minutes trade

Postby TJ » 01 Dec 2009

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.


Return to “User Contributed Studies and Indicator Library”