Announcement

Collapse
No announcement yet.

drawLineRelative() scaling to price instead of study

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

  • drawLineRelative() scaling to price instead of study

    I have a stochastic type study with setPriceStudy(false) configured,

    Then I use the Shift-Drag operation to place the study on the price window with its own scale.

    Calls (w/in that study) to drawShapeRelative() places those shapes on the same scale as the stochasting in the study.

    But calls to drawLineRelative() place the lines on the price scale (thus my lines w/ Y values 0 to 100 are way off the bottom of the chart).

    Is there something I am doing wrong to cause this to happen, or is drawLine supposed to work in a different scale than drawShape?

    In the attached image, note the same study is on the chart twice. At the bottom, the lines and triangle symbols are clearly visible where they should be. At the top in the price window, only the simbols are visible. To see the lines, you have to scale the price window all the way until the 0 value line is visible.


    Thanks
    Attached Files

  • #2
    Code which exhibits the behavior

    The attached EFS shows the problem I am experiencing

    It will draw two dots and a cyan line on the Stoch study.

    When you drag this study onto the price window, the Cyan line will drop off the bottom of the screen and the dots will remain visible.

    Extreme scaling of the price chart is necessary to see the line.

    Comment


    • #3
      Hello dgerdes,

      No file was attached. Please try again.
      Jason K.
      Project Manager
      eSignal - an Interactive Data company

      EFS KnowledgeBase
      JavaScript for EFS Video Series
      EFS Beginner Tutorial Series
      EFS Glossary
      Custom EFS Development Policy

      New User Orientation

      Comment


      • #4
        Hmm. that file didn't seem to attach.

        Let me try again.


        Here's the guts of it:

        function main(K,Fast,Slow,Upper,Lower) {

        if(vStoch==null) vStoch = stochD (K, Fast, Slow);


        if (getBarState() == BARSTATE_NEWBAR) {

        clearShape();
        clearLines();

        drawShapeRelative ( -10, vStoch.getValue(-10),
        Shape.CIRCLE, null, Color.red,
        Shape.TOP | Shape.ONTOP, 1);
        drawShapeRelative ( -20, vStoch.getValue(-20),
        Shape.CIRCLE, null, Color.green,
        Shape.TOP | Shape.ONTOP, 2);
        drawLineRelative (-10, vStoch.getValue(-10), -20, vStoch.getValue(-20),
        PS_SOLID, 4, Color.cyan, 3);

        }

        return new Array(vStoch.getValue(StochStudy.FAST),vStoch.getV alue(StochStudy.SLOW));

        }
        Attached Files

        Comment


        • #5
          Hello dgerdes,

          This appears to be a bug. Thank you for reporting this and posting the example script to reproduce. I've reported this to our development team. Our internal tracking number for future reference is EDL# 12219.
          Jason K.
          Project Manager
          eSignal - an Interactive Data company

          EFS KnowledgeBase
          JavaScript for EFS Video Series
          EFS Beginner Tutorial Series
          EFS Glossary
          Custom EFS Development Policy

          New User Orientation

          Comment


          • #6
            Thanks Jason.

            Comment


            • #7
              Autoscaling of drawShapeRelative()?

              Can anyone tell me if dgerdes was correct in his post below that drawShapesRelative() shapes are included in the automatic rescaling process? I ask because it seems to me they are not. Below is a simple non-price study script that generates a 45 minute moving average of the close and a drawShapeRelative() circle at the close of every bar. If the bar spacing of a one minute chart is openned up to the point where only 15 minutes of data is showing and today's tick price data is replayed, the 45 minute moving average does automatically rescaled in the indicator window but the drawShapeRelative() circle seems to me not to as it sometimes appears and sometimes dissappears depending on whether it gets too high or low above the moving average's value.

              Jason mentioned a bug report, EDL# 12219, on dgerdes' observation that his drawLineRelative() was not rescaling. I don't know how to check on the results of a bug report but am curious as to its findings. Thanks for any help.

              Mike



              var bInit = false;
              var myStudy1 = null;
              function preMain() {
              setStudyTitle("Scaling drawShapeRelative");
              setPriceStudy(false);
              }
              function main() {
              var myVar1;
              if ( bInit == false ) {
              myStudy1 = sma(45);
              bInit = true;
              }
              myVar1 = myStudy1.getValue(0);
              clearShape();
              drawShapeRelative(0, close(), Shape.CIRCLE, null, Color.red,
              Shape.TOP);
              return (myVar1);}
              Last edited by mikejhelms; 10-23-2006, 07:51 PM.

              Comment


              • #8
                Mike
                In reading dgerdes' posts I don't think he was stating that the shapes drawn with drawShapeRelative() are included in the auto-scaling of a window but that the locations of the shapes drawn in a non-price study are scaled correctly when that study is overlayed on to the price window while the lines are not.
                To answer your question none of the graphic objects will rescale a window. Only a value returned to the chart will do that which is why the circle drawn by your script will at times disappear above/below the upper/lower boundary of the window if the Close is above/below the moving average.
                Alex

                Comment


                • #9
                  autoscaling drawShapeRelative()

                  A consequence of the fact that some real-time indicators best viewed superimposed may have very different volatilities is that one outsized spike in the value of the more volatile indicator may throw off the scaling for the less volatile indicator. This may occur to the point where subtle patterns that formerly might have been detected in the less volatile indicator through simple visual inspection may go unobserved because a radical rescaling has been forced upon it by its more volatile windowmate. Probably the most basic example would be where a spike in a one minute moving average would for the rest of the session rescale the indicator window to the point where the accompanying 45 minute moving average may be too compacted for its more subtle patterns to be observed.

                  As I wrote in my previous note I tried using drawShapeRelative() to display the value of the more volatile indicator thinking when one of its outsized spikes had passed, the window would autoscale back to a scale more appropriate for the less volatile indicator. But as Alexis noted in his last post none of the graphic objects will rescale a window. So using the drawShapeRelative() approach resulted in the window autoscaling only for the less volatile indicator and when a spike occurred in the more volatile indicator the graphic object displaying it would simply disappear from the screen. So for the last couple of weeks I've been using a quick and dirty approach to getting around the fact that the autoscale function does not include graphic objects and I thought I'd post it.

                  Simply put I define a variable that matches the movement of the drawShapeRelative object, color that variable white so it doesn't appear on the screen (assuming your background chart color is white), return it first so the other variable is not overwritten by a white line, and then use the setBar() statement to reset the more volatile indicator's previous values to match that of the less volatile indicator's value. So when there is a spike in the more volatile indicator, the autoscale will adjust the scale so the graphic object does not disappear from the screen but then will autoscale it back to a more appropriate scale for the less volatile indicator after the spike has passed and its value reset with setBar(). If you put this study on a playback chart and playback today's emini tick file you'll see that the graphic object is always visible, whereas without the invisible indicator and the setBar() statement it would have occasionally disappeared, and that the chart's scaling is autoscaled back to a more acceptable scale after each spike in the more volatile indicator has passed.

                  It's just one approach to getting around the fact that autoscale doesn't include graphics objects but I thought someone might find it useful. Below is the code for the simple example of two moving averages.


                  var bInit = false;
                  var myStudy1 = null;
                  var myStudy2 = null;
                  function preMain() {
                  setStudyTitle("Autoscaling drawShapeRelative");
                  setPriceStudy(false);
                  setDefaultBarFgColor(Color.white, 0);
                  setDefaultBarFgColor(Color.green, 1);
                  }
                  function main() {
                  var myVar1;
                  var myVar2;

                  if ( bInit == false ) {
                  myStudy1 = sma(1);
                  myStudy2 = sma(45);
                  bInit = true;
                  }
                  myVar1 = myStudy1.getValue(0);
                  myVar2 = myStudy2.getValue(0);

                  clearShape();
                  drawShapeRelative(0, myVar1, Shape.CIRCLE, null, Color.red, shape.TOP);
                  setBar(Bar.Value, -1, 0, myVar2)

                  return new Array(myVar1, myVar2);
                  }

                  Comment

                  Working...
                  X