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

Postby David Caliano » 08 Aug 2010

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 then
begin
HighestH = NewHighestH;
NewHighestH = 0;
End;

If T >= StartTime and T <= Endtime then
begin
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 then
begin
LowestL = NewLowestL;
NewLowestL = 0;
End;

If T >= StartTime and T <= Endtime then
begin
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.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: help with code

Postby TJ » 08 Aug 2010

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

Postby David Caliano » 08 Aug 2010

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?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: help with code

Postby TJ » 08 Aug 2010

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

Postby David Caliano » 09 Aug 2010

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

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: help with code

Postby TJ » 09 Aug 2010

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

Postby David Caliano » 09 Aug 2010

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 then
begin
LowestL = NewLowestL;
NewLowestL = 9999999;
End;


If T >= StartTime and T <= Endtime then
Begin
If L < NewLowestL then NewLowestL = L;
Value1 = TL_New( D, T, L, D, T, H);

End;

Plot1( LowestL );


Return to “MultiCharts”