Announcement

Collapse
No announcement yet.

drawlinerelative

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

  • drawlinerelative

    premain function
    setColorPriceBars(true);
    .......
    Can we have a similar function for "drawlineralative(true or false) in premain as well ? that can help me erase the lines on chart by setting the study to false.

    Thank you

  • #2
    Rana
    Just add a Boolean FunctionParameter in preMain called for example showLines and then in your main function precede each instance of a drawLineRelative() command with a if(showLines) conditional statement. When the showLines parameter is set to true the efs will draw the lines else it will not
    See this article in the EFS KnowledgeBase for information regarding the FunctionParameter object and some examples of its usage
    Alex


    Originally posted by Rana View Post
    premain function
    setColorPriceBars(true);
    .......
    Can we have a similar function for "drawlineralative(true or false) in premain as well ? that can help me erase the lines on chart by setting the study to false.

    Thank you

    Comment


    • #3
      function preMain() {
      // setting drawlinerelative parameters off when not wanted

      var fp5 = new FunctionParameter("showLines", FunctionParameter.BOOLEAN);
      fp5.setName("show Lines");
      fp5.setDefault(true); }

      function main(showLines ) {
      ............
      .........

      if ( showLines ==true) && (a>b)
      { drawLineRelative(0, low(),0, low(), PS_SOLID, 2, Color.red, "PL"+rawtime(0) ); }
      }

      This is what I have understood from the thread so far.
      Kindly help me further with this please.

      Rana

      Comment


      • #4
        Rana
        In essence that is what I suggested.
        That said the syntax in the following line of your code sample
        if(showLines ==true) && (a>b)
        is incorrect and should be
        if(showLines ==true && a>b)
        or even
        if(showLines && a>b)
        ie without the need of ==true since the parameter is a Boolean hence only true or false
        Then again you may want to separate those conditions if for example you want to execute multiple commands based on the condition a>b. In that case you would write it as
        if(a>b){
        if(showLines) drawLineRelative(...);
        setBarBgColor(...);
        ...etc;
        }

        Anyhow there are many ways to do any and all of this.
        Alex


        Originally posted by Rana View Post
        function preMain() {
        // setting drawlinerelative parameters off when not wanted

        var fp5 = new FunctionParameter("showLines", FunctionParameter.BOOLEAN);
        fp5.setName("show Lines");
        fp5.setDefault(true); }

        function main(showLines ) {
        ............
        .........

        if ( showLines ==true) && (a>b)
        { drawLineRelative(0, low(),0, low(), PS_SOLID, 2, Color.red, "PL"+rawtime(0) ); }
        }

        This is what I have understood from the thread so far.
        Kindly help me further with this please.

        Rana

        Comment


        • #5
          function preMain() {
          // setting parameters to turn off drawlinerelativewhen not wanted
          var fp5 = new FunctionParameter("showLines", FunctionParameter.BOOLEAN);
          fp5.setName("show Lines");
          fp5.setDefault(false); }

          function main(showLines ) {
          ............
          if ( va < vb && vc < vd ) {
          if (showLines );
          drawLineRelative(....... );
          drawLineRelative(....... );

          }

          I am missing something here. Please help me again with this.

          Thank you

          Comment


          • #6
            Rana
            While JavaScript (as well as some other languages) allows you to execute a single statement without the need to use curly brackets ie
            PHP Code:
            if(this_conditionexecute_this_command;
            //or
            if(this_condition)
                
            execute_this_command
            if you need to execute more than one statement based on the same condition then you need to include them all in curly brackets ie
            PHP Code:
            if(this_condition){
                
            execute_this_command;
                
            execute_this_other_command;
                
            etc;

            or [for completeness of information] if for some specific reason you do not want to use curly brackets then you need to use a comma after each statement and a semi-colon only after the last one (note that some will argue - and perhaps correctly so - that this is not good coding practice as it may lead to errors that are difficult to identify)
            PHP Code:
            if(this_condition)
                
            execute_this_command,
                
            execute_this_other_command,
                
            etc
            Anyhow as you can see in the example I posted earlier I had specifically set the drawLineRelative() command as a single statement following the if(showLines) condition meaning that only that one statement would have been executed based on the showLines setting while all the statements included in the curly brackets would have been executed if the a>b condition were true
            Alex


            Originally posted by Rana View Post
            function preMain() {
            // setting parameters to turn off drawlinerelativewhen not wanted
            var fp5 = new FunctionParameter("showLines", FunctionParameter.BOOLEAN);
            fp5.setName("show Lines");
            fp5.setDefault(false); }

            function main(showLines ) {
            ............
            if ( va < vb && vc < vd ) {
            if (showLines );
            drawLineRelative(....... );
            drawLineRelative(....... );

            }

            I am missing something here. Please help me again with this.

            Thank you

            Comment


            • #7
              thank you very much for your help. I guess I can't deal with technicalities and leave it for you guys with better technical understanding and abilities to play with it.
              Thank you anyway for giving my questions a thought.

              Comment


              • #8
                swapping (a>b) with (showlines) has sorted my problems as you explained.
                Thank you very much for your help Alex. I am slow in understanding these things.

                Asking questions here for help from experts like you far outweighs than learning whole JAVA language in my opinion. If I want to drive a fast car, it doesn't matter how companies build a faster engine, I look for " where to buy it and some driving lessons " rather than LEARNING TO build a faster engine. and yea I am not a successful trader.

                Comment

                Working...
                X