Announcement

Collapse
No announcement yet.

0 based RSI Histogram

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

  • 0 based RSI Histogram

    Hi,

    I am trying to create a RSI efs that uses 0 instead of 50. I do not receive a syntax error but the histogram will not display. Can anyone see what I am doing wrong?


    var rsi = rsi(14)-50;
    function preMain() {
    setStudyMin(-100);
    setStudyMax(100);
    setStudyTitle("Zero Based RSI");
    setCursorLabelName("ZeroRSI");
    setDefaultBarFgColor(Color.blue, 0);
    setPlotType(PLOTTYPE_HISTOGRAM,0);

    }
    function main() {
    return rsi;
    }
    Attached Files

  • #2
    Re: 0 based RSI Histogram

    emorrison
    The reason why your script is not returning anything is because you placed your equation outside of the main() function where it will be executed only on the first iteration of the script when the formula is loaded or reloaded in the chart
    To resolve this replace the return statement ie
    return rsi;
    with the following
    return rsi(14)-50;
    and delete the first line of your script where you assign your calculations to the variable rsi. As an aside you should not name variables using reserved keywords such as names of existing functions etc
    Once you make this change the formula will work
    Alex


    Originally posted by emorrison
    Hi,
    I am trying to create a RSI efs that uses 0 instead of 50. I do not receive a syntax error but the histogram will not display. Can anyone see what I am doing wrong?

    var rsi = rsi(14)-50;
    function preMain() {
    setStudyMin(-100);
    setStudyMax(100);
    setStudyTitle("Zero Based RSI");
    setCursorLabelName("ZeroRSI");
    setDefaultBarFgColor(Color.blue, 0);
    setPlotType(PLOTTYPE_HISTOGRAM,0);
    }
    function main() {
    return rsi;
    }

    Comment


    • #3
      Re: Re: 0 based RSI Histogram

      Thank You Alex. I appreciate your assistance insolving my issue. I will definitely head your advice in naming my variables more carefully.

      Thanks again!

      Ed



      Originally posted by Alexis C. Montenegro
      emorrison
      The reason why your script is not returning anything is because you placed your equation outside of the main() function where it will be executed only on the first iteration of the script when the formula is loaded or reloaded in the chart
      To resolve this replace the return statement ie
      return rsi;
      with the following
      return rsi(14)-50;
      and delete the first line of your script where you assign your calculations to the variable rsi. As an aside you should not name variables using reserved keywords such as names of existing functions etc
      Once you make this change the formula will work
      Alex

      Comment


      • #4
        Re: Re: Re: 0 based RSI Histogram

        Ed
        You are welcome
        Alex


        Originally posted by emorrison
        Thank You Alex. I appreciate your assistance insolving my issue. I will definitely head your advice in naming my variables more carefully.

        Thanks again!

        Ed

        Comment

        Working...
        X