Strange behavior from a variable in TL definition

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1273
Joined: 23 Nov 2010
Has thanked: 721 times
Been thanked: 222 times

Strange behavior from a variable in TL definition

Postby arjfca » 19 Jun 2012

Hello

I'm very confuse with a problem where a variable does not behave as it should

A function is use to read back a number in a string.

The printed value is:
text 1.26645 number: 1.26645

This value is strored in a variable called HighVal

Code: Select all

   
HighVal = Strtonum(rightstr(splitstring(StringHigh,9),7));
print ("text ", Splitstring(StringHigh,cd), " number: ", strtonum(Splitstring(StringHigh,cd)):5:5);
      
LowVal = StrToNum(Splitstring(StringLow,cd))*1;
         
Value1 = tl_setbegin(LineHigh[cd] , dateD,timeD,HighVal);
Value1 = TL_SetEnd(LineHigh[cd] , dateD,timeD,highval);
        


The same value, HighVal is use in a Trend Line definition. This should produce an horizontal line since both Begin and End Value is the same

Result is not horizontal

If I hard code or define the same variable with the number, then the trendline is horizontal

Look at the 3 snap pictures, I did show the code use in them. The result is seen by the trend line being not horizontal

Hope I'm clear enough

Martin
Attachments
TrendLine_3.gif
TrendLine_3.gif (10 KiB) Viewed 136 times
TrendLine_2.gif
TrendLine_2.gif (9.28 KiB) Viewed 138 times
TrendLine_1.gif
TrendLine_1.gif (9.53 KiB) Viewed 148 times

User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Strange behavior from a variable in TL definition

Postby TJ » 19 Jun 2012

arjfca wrote:Hello

I'm very confuse with a problem where a variable does not behave as it should

A function is use to read back a number in a string.

The printed value is:
text 1.26645 number: 1.26645

This value is strored in a variable called HighVal

Code: Select all

   
HighVal = Strtonum(rightstr(splitstring(StringHigh,9),7));
print ("text ", Splitstring(StringHigh,cd), " number: ", strtonum(Splitstring(StringHigh,cd)):5:5);
      
LowVal = StrToNum(Splitstring(StringLow,cd))*1;
         
Value1 = tl_setbegin(LineHigh[cd] , dateD,timeD,HighVal);
Value1 = TL_SetEnd(LineHigh[cd] , dateD,timeD,highval);
        


The same value, HighVal is use in a Trend Line definition. This should produce an horizontal line since both Begin and End Value is the same

Result is not horizontal

If I hard code or define the same variable with the number, then the trendline is horizontal

Look at the 3 snap pictures, I did show the code use in them. The result is seen by the trend line being not horizontal

Hope I'm clear enough

Martin


try this

Code: Select all

   
HighVal = Strtonum(rightstr(splitstring(StringHigh,9),7));
print ("text ", Splitstring(StringHigh,cd), " number: ", strtonum(Splitstring(StringHigh,cd)):5:5);
      
LowVal = StrToNum(Splitstring(StringLow,cd))*1;
         
Value1 = TL_SetEnd(LineHigh[cd] , dateD,timeD,highval);
Value1 = tl_setbegin(LineHigh[cd] , dateD,timeD,HighVal);

        

arjfca
Posts: 1273
Joined: 23 Nov 2010
Has thanked: 721 times
Been thanked: 222 times

Re: Strange behavior from a variable in TL definition

Postby arjfca » 19 Jun 2012

TJ wrote:
arjfca wrote:Hello

I'm very confuse with a problem where a variable does not behave as it should

A function is use to read back a number in a string.

The printed value is:
text 1.26645 number: 1.26645

This value is strored in a variable called HighVal

Code: Select all

   
HighVal = Strtonum(rightstr(splitstring(StringHigh,9),7));
print ("text ", Splitstring(StringHigh,cd), " number: ", strtonum(Splitstring(StringHigh,cd)):5:5);
      
LowVal = StrToNum(Splitstring(StringLow,cd))*1;
         
Value1 = tl_setbegin(LineHigh[cd] , dateD,timeD,HighVal);
Value1 = TL_SetEnd(LineHigh[cd] , dateD,timeD,highval);
        


The same value, HighVal is use in a Trend Line definition. This should produce an horizontal line since both Begin and End Value is the same

Result is not horizontal

If I hard code or define the same variable with the number, then the trendline is horizontal

Look at the 3 snap pictures, I did show the code use in them. The result is seen by the trend line being not horizontal

Hope I'm clear enough

Martin


try this

Code: Select all

   
HighVal = Strtonum(rightstr(splitstring(StringHigh,9),7));
print ("text ", Splitstring(StringHigh,cd), " number: ", strtonum(Splitstring(StringHigh,cd)):5:5);
      
LowVal = StrToNum(Splitstring(StringLow,cd))*1;
         
Value1 = TL_SetEnd(LineHigh[cd] , dateD,timeD,highval);
Value1 = tl_setbegin(LineHigh[cd] , dateD,timeD,HighVal);

        


TJ, your a real genius. Yes, it work

Is it written somewhere that the End as to be define before the begin?

Martin :)


Return to “MultiCharts”