Announcement

Collapse
No announcement yet.

User control with Edit Studies

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

  • User control with Edit Studies

    With the Edit Studies function on an advanced chart, I would like to control the -
    Line (Bar) thickness
    Line (Bar) color
    Line (Bar) style
    and placing the line (bar) at a user defined value.

    I have an efs example of user defined control of the Thickness and Color. I tried to search the boards for examples of style and value placement. I know I am using the wrong search criteria because I can not find what I want.

    I have the thickness, color, style and placement hard coded in my efs but I would like to make the efs more user friendly.

    Thank you.

  • #2
    jethro87
    Try the following example which will allow you to draw a line at a specified price level (no line is drawn if price is not specified) and modify its pen style between _DOT and _SOLID
    Alex

    PHP Code:
    function preMain(){
        
    setPriceStudy(true);
        
        var 
    fp1 = new FunctionParameter("Price"FunctionParameter.NUMBER);
        
    fp1.setDefault(); 
            
        var 
    fp2 = new FunctionParameter("LineStyle"FunctionParameter.STRING);
        
    fp2.addOption("PS_DOT");
        
    fp2.addOption("PS_SOLID");
        
    fp2.setDefault("PS_SOLID"); 
    }

    function 
    main(Price,LineStyle){

        if(
    Price!=null)
        
    drawLineRelative(-100,Price,100,Price,eval(LineStyle),2,Color.red,"line");

        return;

    Comment


    • #3
      Yes Alexis. This is just what I was looking for.
      Thanks again for your help.
      Much appreciated.

      Comment


      • #4
        jethro87
        You are most welcome
        Alex

        Comment


        • #5
          Adding Text to Line

          How can I add drawTextAbsolute to a code similar to Alexis put up here. I would like to add the text next to the line.

          I would like to input the price level to draw the line and also have the text next to it to show what that level is. I removed the LineStyle input.

          I tried the following right after the drawline and I get an error that Price is not defined.

          Appreciate any help. Thanks in advance

          PHP Code:
              drawLineRelative(-100,Price,100,Price,PS_SOLID,2,Color.red,"Line");
          drawTextAbsolute(2Price.getValue(), "Price=" +Price.getValue(), Color.cyannull
                           
          Text.FRAME Text.VCENTER Text.BOLD"Arial"12"Price"); 

          Comment


          • #6
            akiri
            The error message is generated because Price is not a series from which you can retrieve a value using the .getValue() method but is a single value defined with a functionParameter. In the drawTextAbsolute() command replace both instances of Price.getValue() with Price and it will work correctly
            Alex

            Comment


            • #7
              Draw Lines only from start of Today

              Is there a way to just draw the line from start of day session to the present bar only.

              I tried using the return array function but it draws a line going back left all the way. I would just like to have the line start at 9:30 or the start of day session of the contract. Thanks again for any suggestions.

              AK

              PHP Code:
              return new Array (dOpen,dHigh,dLow,dClose,Price); 

              Comment


              • #8
                Thanks Alexis

                Alexis I figured it out using getFirstBarIndexofDay.

                Thanks for your help here and in other posts.

                AK

                Comment


                • #9
                  akiri
                  You are most welcome
                  Alex

                  Comment

                  Working...
                  X