Announcement

Collapse
No announcement yet.

Assistance with Price Study Formual Error

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

  • Assistance with Price Study Formual Error

    Dear FORUM,

    Formula programming is really not my forte and I kindly request your assistance with the following formula. I just can not get it to plot on an advanced chart.

    Thanks in advance for your patience,
    Magda

    /*
    Simple Price study
    Subtract the high from the low points
    Over the last 4 periods
    Plot a line of the result
    */


    function preMain(){

    setPriceStudy(true);
    setShowCursorLabel(false);
    setStudyTitle("H - L / 4 Periods");

    }

    function main(){

    var high = high(4);
    var low = low(4);

    return (high - low);
    }

  • #2
    Magda
    If you are trying to calculate the High-Low of 4 bars back then you need to use negative numbers for the bar indexes ie high(-4) and low(-4) in place of high(4) and low(4). Positive numbers are for the bars to the right of the bar being processed.
    Also I would suggest that you name the variables differently eg High and Low instead of high and low as these are the function names for those price series.
    If you are unfamiliar with programming in efs and are interested in learning then I would suggest that you start by reviewing the JavaScript for EFS video series and the Core JavaScript Reference Guide. Those will provide you with a thorough introduction to programming in JavaScript which is at the foundation of EFS. Then go through the EFS KnowledgeBase and study the Help Guides and Tutorials which will provide you with the specifics of EFS.
    Hope this helps
    Alex


    Originally posted by Magda
    Dear FORUM,

    Formula programming is really not my forte and I kindly request your assistance with the following formula. I just can not get it to plot on an advanced chart.

    Thanks in advance for your patience,
    Magda

    /*
    Simple Price study
    Subtract the high from the low points
    Over the last 4 periods
    Plot a line of the result
    */


    function preMain(){

    setPriceStudy(true);
    setShowCursorLabel(false);
    setStudyTitle("H - L / 4 Periods");

    }

    function main(){

    var high = high(4);
    var low = low(4);

    return (high - low);
    }

    Comment


    • #3
      Magda
      Also keep in mind that the values returned by your script will be in a very different range than that of the symbol you are plotting so you will get a compressed chart because you are setting the formula as a price study.
      Alex

      Comment


      • #4
        Alexis,

        Thanks for your points, much appreciated. I have also been studying the various documentation and videos to aid my programming efforts. Alas, programming formulas is not my forte but we are trying. In this learning process it is great to have a forum like this to pose questions and to continue to learn.

        Best regards,
        Magda

        Comment


        • #5
          Magda
          You are most welcome
          Alex


          Originally posted by Magda
          Alexis,

          Thanks for your points, much appreciated. I have also been studying the various documentation and videos to aid my programming efforts. Alas, programming formulas is not my forte but we are trying. In this learning process it is great to have a forum like this to pose questions and to continue to learn.

          Best regards,
          Magda

          Comment

          Working...
          X