Announcement

Collapse
No announcement yet.

New study that either crashes or loops esignal

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

  • New study that either crashes or loops esignal

    I have a freshly written study that seems to either crash or loop esignal. I tried to go through support but they said I need to get help here.

    except for the premain and global variables, this is the code

    basically, if in the OneSetup function, if I move the return right at the start, I get an error (correctly because things aren't initiallized). If I move it further, I either get loops (esignal goes away) or crash dump.

    I think esignal has a problem because an efs shouldn't be able to crash esigna.

    Bernie


    //---------------------------------------------------------------------------------------------------
    // main is called once per tic

    function main(SessionStart, SessionEnd, CCILookback, CCIColor, CCISize, CCIHSize, TurboDisplay, TurboColor, TurboSize ) {

    debugPrintln("Entry sw="+OneSwitch);
    if (OneSwitch == 0) { // one time only
    OneSetup(CCILookback, CCIColor, CCISize, CCIHSize, TurboDisplay, TurboColor, TurboSize);
    OneSwitch = 1;
    debugPrintln("exit sw="+OneSwitch);
    }

    if (getBarState() == BARSTATE_NEWBAR) { // only once per bar
    }

    var time = getHour()*100+getMinute()*1;
    var CCI = CCI14.getValue(CCIStudy.CCI);
    var Turbo = CCITurbo.getValue(CCIStudy.CCI);
    debugPrintln(time+" "+CCI+" "+Turbo);

    return new Array(CCI, CCI, Turbo, 0, +100, -100, +200, -200);
    }

    //--------------------------------------------------------------------------------------------
    // OneTimeSetup -- Called once by main to initialize things that can't be done in preMain

    function OneSetup(CCILookback, CCIColor, CCISize, CCIHSize, TurboDisplay, TurboColor, TurboSize)
    {
    //return;
    //debugPrintln("OneTimeSetup");
    // setup interval info
    /*i = getInterval(); // get raw interval value
    len = i.length();
    return;
    IntervalType = i.charAt(len-1);
    IntervalSize = parseInt(i)*1;
    return; */
    // setup CCI
    CCIStudy = new CCIStudy(CCILookback, "HLC/3");
    return;

    // setup chart properties
    setDefaultBarFgColor(CCIColor, 1); // set color of CCI Line
    setDefaultBarThickness(CCISize, 1); // set size of CCI Line

    setDefaultBarThickness(CCIHSize, 0); // set size of CCI Histogram bars

    setDefaultBarFgColor(TurboColor, 2); // set color of CCI Line
    setDefaultBarThickness(TurboSize, 2); // set size of CCI Line

    if (TurboDisplay == "Yes") {
    TurboDisp = true;
    } else {
    TurboDisp = false;
    }

    return;
    }

  • #2
    Hello Bernie,

    May I see your entire formula please? I need to test your formula. Please use the attachment feature.

    Thanks,
    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


    • #3
      ok here it is, I've been applying it to tick charts (ab #f) 610t or ym #f 1 min (if it makes any difference). Play around with moving the return statement in the function.

      Bernie
      Attached Files

      Comment


      • #4
        I don't know if you can make it crash, but the study as posted, crashes my esignal 100% of the time
        Bernie

        Comment


        • #5
          Hello Bernie,

          The crash was related to the case of your CCILookback parameter name.

          You need to change 2 things in your code. In preMain() your parameter name for CCIlookback has a lower case l. In main() and throughout your formula you are referencing CCILookback with a capital L. Just change that parameter name in preMain() to have a capital L.

          The second item is the study object name used in your OneSetup function. You haven't declared the study name, CCIStudy, globaly and it may also be conflicting with the CCIStudy() efs function name. Similar to using a reserved word as a variable. As a good habit, use unique names for your study objects. I changed it to CCI14, since you had that declared in your global variables.

          You should be all set now.

          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 for the quick response. I hope your tech people can fix the bug also because it sure makes it difficult to debug!.

            Also as you may have surmised, i'm kind of the keeper of the woodie cci studies and I'm trying to create a very cleaned up (and efficient) version.

            Thanks,
            Bernie Schoch

            Comment


            • #7
              Thanks for the quick response. I hope your tech people can fix the bug also because it sure makes it difficult to debug!.

              Also as you may have surmised, i'm kind of the keeper of the woodie cci studies and I'm trying to create a very cleaned up (and efficient) version.

              Thanks,
              Bernie Schoch

              Comment


              • #8
                Ok I made the changes, however now I get my original problem. I've posted my revised version with addition debugprint statements to document the problem. My output of the debugwindown looks as follows:
                .
                .
                .
                OneTimeSetup
                Entry sw=0
                p0 610T
                OneTimeSetup
                Entry sw=0
                p0 610T
                OnetimeSetup
                Entry sw=0
                Init done

                it appears that the logic stops right at the len = i.length(); statement and causes main to be re-entered, kindof strange.

                Bernie
                Attached Files

                Comment


                • #9
                  More info, if I replace the len = i.length(); statement temporarily, with len = 3; everything works, so there must be something wrong with it.

                  Bernie

                  Comment


                  • #10
                    Hello Bernie,

                    In OneSetup() your trying to call a method, length(), which doesn't exist. If you want to access the length property of the string, i, use var len = i.length;. Leave off the function call operators, () .
                    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


                    • #11
                      Jason, thanks for the help and sorry for the delayed thank you.

                      In talking to earl, it looks I need to email you because what you saw is now almost a working shell that can be used to integrate with what you are doing, my emal is ([email protected])

                      Bernie

                      Comment


                      • #12
                        Performance questions

                        A couple of performance questions:

                        1) How expensive is the call to write text on the chart? Is it worthing checking to see if i'm writing the same thing on each tick entry to main and bypass the text calls? For example, writing the close price. The same question in using other drawing calls such as draw shape or line.

                        2) Is there a way to change the color of a plot midstream without having to set the color with each call? (assuming theat the call is expensive) I would be nice to change it only when there is a change

                        Thanks

                        Comment


                        • #13
                          Hello Bernie,

                          1) The larger the collection of drawn objects on a chart the more expensive it gets. You'll notice this mostly when scrolling back in time to view historical data. The key is to manage the collection with a set number of tag names for the drawn objects. Create a global counter and use it when building the tag names. At NEWBAR, you'll increment the counter by 1 until it reaches a limit that you'll set within the code, say 200. If the counter reaches 200, reset it to 0. When building your tag names do something like "TexTLabel" + Cntr, which would be TextLabel0 for the first bar, TextLabel1 for the second and so on. This will force the formula to remove the oldest image in the collection and redraw it on the current bar, once the total reaches 200. This way you'll never have more that 200 labels or images on the chart for that particular collection. Also you only want to call the draw function when it's necessary. Put some conditions around the call to prevent it from being called on every trade.

                          In the case of the close label to the right of the price bars. You would need to call the draw function on every trade. Just be sure to use a unique tag name so that only you redraw the object instead of drawing multiple repetitive objects.

                          2) Yes, you can call setDefaultBarFgColor() within main when needed.
                          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

                          Working...
                          X