Announcement

Collapse
No announcement yet.

ROC of an Indicator

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

  • ROC of an Indicator

    Hi,
    Is it possible to calculate the ROC of an Indicator? :

    Eg : ( RSI Close() - RSI Close (-1) )

    Paul

  • #2
    Paul
    Would this do?
    Alex

    PHP Code:
    var vRSI14 = new RSIStudy(14"Close");

    function 
    preMain() {
     
        
    setPriceStudy(false);
        
    setStudyTitle("RSI diff");
        
    setCursorLabelName("RSI diff"0);
        
    setDefaultBarStyle(PS_SOLID0);
        
    setDefaultBarFgColor(Color.blue0);
        
    setDefaultBarThickness(10);
        
    setPlotType(PLOTTYPE_LINE0);
    }

    function 
    main() {
     
        var 
    vDiff vRSI14.getValue(RSIStudy.RSI)-vRSI14.getValue(RSIStudy.RSI, -1)
            
        return 
    vDiff;

    Comment


    • #3
      Hi Alex,
      Spot on - thanks.
      I knew it was something straightforward. Can you adjust it so that it can work with a user defined symbol other than the chart it is being plotted on?

      Thanks,
      Paul

      Comment


      • #4
        Paul
        Not sure it can be done using the builtin. Maybe someone else has a better solution
        Alex

        Comment


        • #5
          Hi Alex,
          I'm already using an efs which allows the symbol to be input directly (see attached). I didn't know whether a Builtin study would be more robust/efficient (CPU wise) for completing this task- or exactly the same?

          Also, I'd have no idea how to add RSI ROC into this formula, so i needed the previous Builtin formula you supplied anyway.

          I've another general question : - in formulas i've created, i haven't been able to do a comparison to the previous output (like a ROC of the formula) :

          Eg : output = vValue
          comparison = vValue(-1)

          ROC = vValue - vValue(-1)

          Does this have to be put into any array to hold the previous vValue(-1), so it can be used in the calculation? I tried different things but have had no success.

          Thanks,
          Paul
          Attached Files

          Comment

          Working...
          X