Text_float function

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: 1567
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 470 times
Been thanked: 503 times

Text_float function

Postby arnie » 21 Dec 2011

Hi.

I need help regarding the text_float function.
Please see attached image.

The text_float function uses the set_textstyle horizontal and vertical parameters centered on the last bar, which, as seen on the chart, lay half the text on top of previous bars.

My idea is to plot the text to the right of the last bar. I thought creating a second function, changing the text_setstyle parameters, but for some reason I'm receiving an error when trying to compile it - assignment is allowed only for variables or array elements which is a strange error when I copy/paste the code. The only change made was the horizontal parameter from 2 to 0.

What am I doing wrong?

Code: Select all

inputs:
   TextID( numericsimple ),                                                       
                  
   TextBarsBack( numericsimple ),                                                   
                                          
   TextPriceValuePercent( numericsimple ) ;                                 

variables:
   var0( false ),
   var1( 0 ),
   var2( 0 ),
   var3( 0 ) ;

if LastBarOnChart then
   begin
   var0 = Text_Exist( TextID ) ;
   if var0 then
      begin
      var1 = GetAppInfo( aiHighestDispValue ) ;
      var2 = GetAppInfo( aiLowestDispValue ) ;
      var3 = var2 + 0.01 * TextPriceValuePercent *
       ( var1 - var2 ) ;
      Text_SetLocation( TextID, Date[TextBarsBack], Time[TextBarsBack],
       var3 ) ;
      Text_SetStyle( TextID, 0, 2 ) ;                                     
      end
   else
      RaiseRunTimeError( "TextID does not exist." ) ;
   end ;

Text_Float = 1 ;
Attachments
text_float.png
text_float.png (29.47 KiB) Viewed 377 times

User avatar
TJ
Posts: 6520
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: Text_float function

Postby TJ » 21 Dec 2011

arnie wrote:Hi.

I need help regarding the text_float function.
Please see attached image.

The text_float function uses the set_textstyle horizontal and vertical parameters centered on the last bar, which, as seen on the chart, lay half the text on top of previous bars.

My idea is to plot the text to the right of the last bar. I thought creating a second function, changing the text_setstyle parameters, but for some reason I'm receiving an error when trying to compile it - assignment is allowed only for variables or array elements which is a strange error when I copy/paste the code. The only change made was the horizontal parameter from 2 to 0.

What am I doing wrong?

...


the answer is hidden in this line:

>...which is a strange error when I copy/paste the code.

What did you copy to?

User avatar
arnie
Posts: 1567
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 470 times
Been thanked: 503 times

Re: Text_float function

Postby arnie » 22 Dec 2011

TJ wrote:
the answer is hidden in this line:

>...which is a strange error when I copy/paste the code.

What did you copy to?


Hi TJ.

I selected all tex_float function code, copied it and then pasted it all to a new created function, that was it.

Both functions are identical now and I can't compile the new one.

Can't functions recognize pasted codes?

User avatar
TJ
Posts: 6520
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: Text_float function

Postby TJ » 22 Dec 2011

arnie wrote:
TJ wrote:
the answer is hidden in this line:

>...which is a strange error when I copy/paste the code.

What did you copy to?


Hi TJ.

I selected all tex_float function code, copied it and then pasted it all to a new created function, that was it.

Both functions are identical now and I can't compile the new one.

Can't functions recognize pasted codes?

Yes... but WHAT did you copy to?

did you copy the code to a new function called Text_Float?

see this line in the bottom of the code?

Code: Select all

Text_Float = 1 ;


it is saying, return value "1" to the function Text_Float.

but since you have copied the code to a new function with a different name,
the PLE could not find Text_Float, thus giving you the error message.

User avatar
arnie
Posts: 1567
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 470 times
Been thanked: 503 times

Re: Text_float function

Postby arnie » 22 Dec 2011

TJ wrote:see this line in the bottom of the code?

Code: Select all

Text_Float = 1 ;


it is saying, return value "1" to the function Text_Float.

but since you have copied the code to a new function with a different name,
the PLE could not find Text_Float, thus giving you the error message.


Damn......

What can I say... so obvious, but at the same time...

Once again thank you TJ for your precious insight.

Regards,
Fernando


Return to “User Contributed Studies and Indicator Library”