Announcement

Collapse
No announcement yet.

VIDYA Code fails realtime, please help...

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VIDYA Code fails realtime, please help...

    Reference to this link...

    http://forum.esignal.com/showthread....&threadid=5624

    View the VIDYA (black line in EBAY..., the incorrect one has the black one on the last bars close (first file ), where it should be at the lower level. (Second file).

    Maybe calc should stop on the previous bar, I mean the second to last bar on the right hand side of the chart...

    Please help

    CODE****************
    var AbsCMO = 0.0;
    var CurrentBar = 0;
    var VIDYA = 0.0;
    var VIDYA_1 = 0.0;
    var lastbar = 0;

    function preMain()
    {
    setPriceStudy(true);
    setStudyTitle("IansVIDYA");
    setCursorLabelName("VIDYA", 0);
    setDefaultBarFgColor(Color.black, 0);
    }

    function main(Length, Smooth)
    {
    if (Length == null) { Length = 20; }//5 min 12, 2 min 20
    if (Smooth == null) { Smooth = 10; }//5 min 5, 2 min 10

    if (lastbar != getValue("rawtime",0)) {
    CurrentBar += 1;
    VIDYA_1 = VIDYA;
    }

    var BarState = getBarState();
    var UP = 0.0;
    var DN = 0.0;
    var UpSum = 0.0;
    var DnSum = 0.0;
    // var Close = getValue("Close", 0, -(Length + 2));
    var i;
    for (i = 0; i > 0-(Length-1); i--) {
    if (close(i) > close(i-1)) { UP = (close(i) - close(i-1)); } else { UP = 0.0; }
    if (close(i) < close(i-1)) { DN = (Math.abs(close(i) - close(i-1))); } else { DN = 0.0; }
    UpSum += UP;
    DnSum += DN;
    // debugPrintln("Vidya : ["+i+"] "+UpSum+" : "+DnSum);
    }
    // debugPrintln("Vidya : "+UpSum+" : "+DnSum);
    if ((UpSum+DnSum) > 0) { AbsCMO = Math.abs((UpSum-DnSum)/(UpSum+DnSum)) ; }
    var SC= 2/(Smooth+1);
    if (CurrentBar <= Length) { VIDYA = close(); } else { VIDYA = (SC * AbsCMO * close()) + ((1 - (SC * AbsCMO)) * VIDYA_1); }

    if (BarState == BARSTATE_NEWBAR) { VIDYA_1 = VIDYA; }

    return VIDYA;
    }
    Attached Files

  • #2
    Correct view, this is view on when symbol first loaded, the one above is after realtime data enters chart...
    Attached Files

    Comment


    • #3
      I would guess after looking at the code and looking at the results that you are seeing the "drift" issue associated with an incorrectly coded EFS.

      If you do a search on drift, you will find a description of the problem and ways to fix your code.

      If this doesn't help you, just let me know and I will fix the code for you...would do it now but I'm about to head out for a few hours.

      Garth
      Garth

      Comment


      • #4
        Hi,

        Thx for your thoughts, Doji3333 helped me with some code on the previous post, and the code is way beyond my skills, so if you would be so kind as to fix the drift issue. I have done searches, but I dont have the skills beyond the basics. I hope you get the chance to fix and also test it in realtime conditions.

        Thx in advance

        Comment


        • #5
          Hello Digs,

          The attached should fix the problem.
          Attached Files
          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
            Thx, looks good so far...will post monday to confirm...

            Comment


            • #7
              yep works excellent...

              Comment

              Working...
              X