# help with code

Questions about MultiCharts and user contributed studies.
David Caliano
Posts: 34
Joined: 25 Aug 2007
Been thanked: 1 time

### help with code

The Following code works fine(plots high of specified time period)...

Code: Select all

`Inputs:    StartTime( 1415 ),           EndTime( 1715 );Vars:      HighestH( 0 ),           NewHighestH( 0 );           If Time[1] = EndTime thenbegin    HighestH = NewHighestH;   NewHighestH = 0;End;If T >= StartTime and T <= Endtime thenbegin   If H > NewHighestH then NewHighestH = H;   Value1 = TL_New(D, T, L, D, T, H);End;   Plot1( HighestH );`

When I coded the same thing, only for the low this time, it returns "0".

Code: Select all

`Inputs:    StartTime( 1415 ),           EndTime( 1715 );Vars:      LowestL( 0 ),           NewLowestL( 0 );           If Time[1] = EndTime thenbegin    LowestL = NewLowestL;   NewLowestL = 0;End;If T >= StartTime and T <= Endtime thenbegin   If L < NewLowestL then NewLowestL = L;   Value1 = TL_New(D, T, L, D, T, H);End;   Plot1( LowestL );`

I would appreciate greatly if someone could point out what I did wrong.

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

### Re: help with code

the problem is here:
If L < NewLowestL ...

ps. you should use the code tag to wrap the code for easy reading.
I have tagged them for you in your above post.

David Caliano
Posts: 34
Joined: 25 Aug 2007
Been thanked: 1 time

### Re: help with code

Thanks TJ. (I'll know to do that next time.)

I'm sort of at a loss at this point at to why that part is wrong.
Could you tell me what it should be?

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

### Re: help with code

David Caliano wrote:Thanks TJ. (I'll know to do that next time.)

I'm sort of at a loss at this point at to why that part is wrong.
Could you tell me what it should be?

start from the 1st bar of the day...
plug the values into the following:
If L < NewLowestL ...

Low can never be smaller than zero!

David Caliano
Posts: 34
Joined: 25 Aug 2007
Been thanked: 1 time

### Re: help with code

I finally got it to work. Thanks again, TJ.

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

### Re: help with code

You are welcome!

Would be nice if you post the solution,
so that others can learn from it too.

David Caliano
Posts: 34
Joined: 25 Aug 2007
Been thanked: 1 time

### Re: help with code

Instead of "0", I had to set the variables to something other than "0", in this
case "999999". (I had additional help on this from the kind man from MarkPlex.com.)

Code: Select all

`Inputs:    StartTime( 1415 ),           EndTime( 1715 );           Vars:      NewLowestL(999999),           LowestL(999999);                         If Time[1] = EndTime thenbegin    LowestL = NewLowestL;   NewLowestL = 9999999;End;If T >= StartTime and T <= Endtime thenBegin   If L < NewLowestL then NewLowestL = L;   Value1 = TL_New( D, T, L, D, T, H);   End; Plot1( LowestL );            `