Announcement

Collapse
No announcement yet.

Auto Scale of study values?

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

  • Auto Scale of study values?

    Can anyone tell me if there's a way to auto-scale a study value so that the max study value over the given time period is at the top of the indicator pane, and the min at the bottom?

    I have studies which can have any positive or negative values, and they always seem to plot in such a way that i have to manually adjust the indicator pane to be able to see all the values.

    Hope I'm making sense

    Thanks,

    SQ

  • #2
    SQ
    Assuming I understood what you are asking it is possible to set the scale to the maximum and minimum values recorded by a study using the setStudyMax() and setStudyMin() functions..
    The enclosed code sample shows one way to do this. In the example I use the Oscillator study and keep track of the highest and lowest levels recorded by the study and then use those to set the maximum and minimum scale of the window
    Alex

    PHP Code:
    var study null;
    var 
    maxValue 0;
    var 
    minValue 0;
     
    function 
    main() {
     
        if(
    study==nullstudy osc(10,21,0);
        
        
    maxValue Math.max(maxValuestudy.getValue(0));
        
    minValue Math.min(minValuestudy.getValue(0));
        
        
    setStudyMax(maxValue);
        
    setStudyMin(minValue)
     
        return 
    study.getValue(0);

    Comment


    • #3
      Thanks Alexis, that's just what i was after.

      Comment


      • #4
        SQ
        You are most welcome
        Alex

        Comment

        Working...
        X