Announcement

Collapse
No announcement yet.

Trend Indicator

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

  • Trend Indicator

    Any suggestions for setting Upper Limit of 10 and Lower Limit of 0 in the following efs will be appreciated.

    --------------------------------
    var xRatio;

    function preMain(){

    setPriceStudy(false);
    setStudyTitle("TrendStregthIndex");
    setShowTitleParameters(false);
    setShowCursorLabel(true);
    setCursorLabelName("TSI", 0);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarFgColor(Color.green, 0);
    setDefaultBarThickness(1, 0);
    setPlotType(PLOTTYPE_LINE, 0);


    }

    var xRatio = null;



    function main() {


    xRatio = Math.abs((close() - (close(10)))/atr(10));

    return xRatio;


    }

    --------------------------

    Thanks in advance.
    Regards,
    BB

  • #2
    Re: Trend Indicator

    BB
    Use the setStudyMax() and setStudyMin() functions. For the syntax required by these functions see the corresponding articles in the EFS KnowledgeBase
    That said these functions will not correct an underlying problem in your script [which is possibly what you are trying to work around] and that is that one of the values used in your equation is “forward looking” by 10 bars hence it returns null on the most recent 10 bars thereby causing a spike in the results returned by that equation
    Alex


    Originally posted by BB
    Any suggestions for setting Upper Limit of 10 and Lower Limit of 0 in the following efs will be appreciated.

    --------------------------------
    var xRatio;

    function preMain(){

    setPriceStudy(false);
    setStudyTitle("TrendStregthIndex");
    setShowTitleParameters(false);
    setShowCursorLabel(true);
    setCursorLabelName("TSI", 0);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarFgColor(Color.green, 0);
    setDefaultBarThickness(1, 0);
    setPlotType(PLOTTYPE_LINE, 0);


    }

    var xRatio = null;



    function main() {


    xRatio = Math.abs((close() - (close(10)))/atr(10));

    return xRatio;


    }

    --------------------------

    Thanks in advance.
    Regards,
    BB

    Comment


    • #3
      Trend Indicator

      Thanks Alexis for your quick response.

      I realised the error, but when I use the following script instead of my earlier script the signal/indicator is 10 bars late.

      xRatio = Math.abs((close() - (close(-10)))/atr(10));

      (the only change here is "close(-10)" rest all script is same.

      It would be very kind of you for any suggestion/help in improving this script, if possible.

      Many thanks in advance.
      Regards,
      BB

      Comment


      • #4
        Re: Trend Indicator

        BB

        ...but when I use the following script instead of my earlier script the signal/indicator is 10 bars late.
        That is because before your equation was actually "forward looking" [ie based on future data] and while that may give the appearance to work on historical bars it is neither realistic nor attainable in real time
        Alex


        Originally posted by BB
        Thanks Alexis for your quick response.

        I realised the error, but when I use the following script instead of my earlier script the signal/indicator is 10 bars late.

        xRatio = Math.abs((close() - (close(-10)))/atr(10));

        (the only change here is "close(-10)" rest all script is same.

        It would be very kind of you for any suggestion/help in improving this script, if possible.

        Many thanks in advance.
        Regards,
        BB

        Comment


        • #5
          Trend Indicator

          Thanks Alexis.

          I guess I will rework the script.

          Many thanks for your invaluable inputs.

          Regards,
          BB

          Comment


          • #6
            Re: Trend Indicator

            BB
            You are welcome
            Alex


            Originally posted by BB
            Thanks Alexis.

            I guess I will rework the script.

            Many thanks for your invaluable inputs.

            Regards,
            BB

            Comment

            Working...
            X