Announcement

Collapse
No announcement yet.

Floundering at declaring variables : (

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Floundering at declaring variables : (

    Hi ,

    I have been using the " if hour minute " method to draw a line of the hi of the 1st half hour ( as an example ) for today's 1 minute chart precisely at the start and end of this trading day.

    I am able to use the " RELATIVETOLEFT " method to draw the text of the value on the chart.

    However, I would like to have the text drawn at a constant distance to the right of the current bar.

    I think I need to declare the variable correctly, and have tried the throw it at the wall and see what sticks method, but that didn't work.
    Any directions are greatly appreciated.

    Thank You Once Again,
    Glenn


    function preMain() {
    setPriceStudy(true);
    }

    function main() {

    if(getBarState()==BARSTATE_NEWBAR){

    if ( hour(0) ==10 && minute(0) ==0 ) {
    Hi3 = high( -1, inv(30) ) ;

    drawLineRelative( -29, Hi3, 360, Hi3, PS_SOLID, 2, Color.yellow, 0);
    drawTextRelative( 100, Hi3, Hi3, Color.yellow,null,Text.VCENTER|Text.RELATIVETOLEFT ,"Calibri",14, 0);

    }

    // Would Like to pass variable Hi3 outside of the previous " } "
    // in order to draw text a constant distance to the right of the current bar instead of relative to left

    }
    }

  • #2
    Hi Again,

    Was that a bone headed question, sorry for taking space. Got a good nights rest and tried something that worked, declared the variable but didn't call it null.

    Positioned after pre main, before main, when I used the form var Hi3 = null ; it doesn't work. When just using var Hi3 ; it does. For future reference, when should a var be initially set to null, rather than just being declared.

    Humbley yours,
    Glenn

    Comment


    • #3
      Glenn
      Run a search on the net for "declaring a variable in javascript" and/or "declaring a variable as null in javascript" and you will find plenty of information related to the topic.
      Alex


      Originally posted by fastflyer View Post
      Hi Again,

      Was that a bone headed question, sorry for taking space. Got a good nights rest and tried something that worked, declared the variable but didn't call it null.

      Positioned after pre main, before main, when I used the form var Hi3 = null ; it doesn't work. When just using var Hi3 ; it does. For future reference, when should a var be initially set to null, rather than just being declared.

      Humbley yours,
      Glenn

      Comment


      • #4
        Roger that Alexis,

        yup, i saw something prior to my previous post that mentioned good programming practice and such ... seems i've heard that somewhere else. at any rate, i'll have a look again and maybe find something other than my current viewpoint of, It Just Does, Deal With It !

        Thanks so much for your patience, i'm sure it's very difficult at times like this.

        Glenn

        Comment


        • #5
          Glenn
          You are welcome
          Alex


          Originally posted by fastflyer View Post
          Roger that Alexis,

          yup, i saw something prior to my previous post that mentioned good programming practice and such ... seems i've heard that somewhere else. at any rate, i'll have a look again and maybe find something other than my current viewpoint of, It Just Does, Deal With It !

          Thanks so much for your patience, i'm sure it's very difficult at times like this.

          Glenn

          Comment

          Working...
          X