Announcement

Collapse
No announcement yet.

Line plotting efs indicator ?

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

  • Line plotting efs indicator ?

    Hi,
    i'm looking for an efs that would allow the following. I think it is doable, and I would appreciate help from some skilled efs programmer.

    Basically, the indicator must draw horizontal lines, at custom set values on intraday charts, horizontally starting from the first today's chart candle and expanding to the right as the day develops.

    So if I enter in the indicator datafield line 1, "50", it should plot a horizontal line at "50" on the chart.

    There should be room for 10 lines as this. Each with its own label, default color and style.

    Example:

    Line 1: Value = 50, color = red, style = dashed
    Line 2: Value = 49, color = green, style = dashed
    Line 3: Value = 47,5, color = white, style = dashed
    Line 4: Value = 52, color = blue, style = dashed

    Color and style would be set as default, but I could set from the indicator setting, a value for each line. Some line could be left with no value and hence would not be plotted of course.

    If I did not make myself clear, please ask questions.

    Cordially,
    Koros

  • #2
    Koros
    Insert the section of code enclosed below in an efs and replace [your price] with a value and it will plot a horizontal line from the first bar of the day to the current bar at the price you defined.

    PHP Code:
    var vTime getValue("rawtime");
    var 
    vIndex getFirstBarIndexOfDay(vTime);

    drawLineRelative(vIndex,[your price],0,[your price],PS_SOLID,1,Color.blue,"line1"); 
    You can duplicate the drawLineRelative command to insert as may lines as you wish. Just replace [your price] with the price levels and replace also "line1" with "line2", "line3" etc depending on the number of lines drawn. If you want the prices to be user defiinable then you will need to create some Function Parameters. For information on Function Parameters, the required syntax and some examples see this article in the EFS KnowledgeBase
    You may also want to read through the information concerning drawLineRelative function which is available here
    All of the above should provide you with all the information that is required to create the efs you want.
    Alex

    Comment


    • #3
      Thanks for your help.

      i've created an efs with:

      var vTime = getValue("rawtime");
      var vIndex = getFirstBarIndexOfDay(vTime);

      drawLineRelative(vIndex,[635],0,[635],PS_SOLID,1,Color.blue,"line1");


      but when I try to add it to a chart, I get:

      Downloads\pivotsshort.efs, line 1: getValue() can only be called in main()

      Any clue why ?

      Thanks,
      Koros

      Comment


      • #4
        Koros
        The section of code I posted earlier needs to be all in main.
        Also you need to remove the square brackets surrounding the price.
        Alex

        Comment


        • #5
          Thanks, but what is the main section ? I just put the code in a new efs and get the message.

          Cordially,
          Koros

          Comment


          • #6
            Koros
            See this article in the EFS KnowledgeBase for an explanation of preMain and main
            Alex

            Comment


            • #7
              I've spent over an hour on this and still get error messages. I'm sure it is easy and obvious once you master this.

              Premain(), main(), functions ......it is way to difficult to learn if you don't allocate enough time, and I don't have time to learn a program language sorry.

              Thanks anyway,
              Koros

              Comment


              • #8
                Koros have a look at the example below, it will draw 4 lines through the Edit Studies , the first line is drawn as default at the close price
                Attached Files

                Comment


                • #9
                  Thanks a lot Shogun, sure it helps.
                  I managed to add additional lines, each with their own colors.

                  For some reason, when I edit this indicator from the "edit studies" link, I can't save. Since I will apply this on several charts, it would be good to save and set as defaults when I past it on other charts.

                  Not a big deal tough, since I can still edit the hardcoded text.

                  Cordially,
                  Koros

                  Comment


                  • #10
                    Koros if you know what default settings you want you can do this by changing the zero in the Function Parameter setDefault line to your preferred setting ,

                    ie,

                    fp1.setDefault(0);

                    change to

                    fp1.setDefault( your setting );



                    and so on with the others i only set them to zero as i was not sure what you were trading

                    Comment


                    • #11
                      OK thanks.
                      I added some line, and tried to make some to look as dash or dots. So I set the style like:

                      drawLineRelative(vIndex,WR3,0,WR3,PS_DASHDOT,1,Col or.red,"WR3");

                      It won't change the way the line is plotted: no matter the setting, it is still plain. Style change works for color, and thickness, but not style.

                      Do you know why ?

                      Thanks,
                      Koros

                      Comment


                      • #12
                        Hello Koros,

                        The drawLine functions only accept one pen style currently, which is PS_SOLID. Hopefully we can get the others working for a future release.
                        Jason K.
                        Project Manager
                        eSignal - an Interactive Data company

                        EFS KnowledgeBase
                        JavaScript for EFS Video Series
                        EFS Beginner Tutorial Series
                        EFS Glossary
                        Custom EFS Development Policy

                        New User Orientation

                        Comment


                        • #13
                          Ok, so how can I replace it in this code with a function that will allow to draw differently styled lines ?

                          Thanks,
                          Koros

                          Comment


                          • #14
                            Hello Koros,

                            That will not be possible. The pen style parameter only accepts one constant at this time, PS_SOLID.
                            Jason K.
                            Project Manager
                            eSignal - an Interactive Data company

                            EFS KnowledgeBase
                            JavaScript for EFS Video Series
                            EFS Beginner Tutorial Series
                            EFS Glossary
                            Custom EFS Development Policy

                            New User Orientation

                            Comment

                            Working...
                            X