Announcement

Collapse
No announcement yet.

Strange Problem or eSignal Bugs?

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

  • Strange Problem or eSignal Bugs?

    I've been troubleshooting this peice of codes for a couple days and I still don't understand whether this is a bug from eSignal EFS or not.

    Basically I have variable gsYourPosition = "NEUTRAL".
    In main(), I use Alert.eMail(..,gsYourPosition,..) and I get all the time gsYourPosition = "SHORT"

    Can somebody see what is wrong?
    Have you encountered this type of problem?

    Thanks.

    Here is the code:
    // This variable can take following values: LONG, SHORT, NEUTRAL
    var gcLONG = "LONG";
    var gcSHORT = "SHORT";
    var gcNEUTRAL = "NEUTRAL";
    var gsYourPosition = gcNEUTRAL;


    //Declarations


    function preMain() {

    //main() will be executed only after the bar complete or close
    setComputeOnClose();
    setPriceStudy(true);
    setStudyTitle("TEST 1.0");

    }

    function main() {

    var sTrend = gcSHORT;

    Alert.email("Before if... "+ gsYourPosition+ "Trend " +sTrend, close());
    //Why gsYourPosition is equal to "SHORT" at this step??????


    //If you haven't taken any position yet and the trend is DOWN (SHORT)
    if (sTrend == gcSHORT) {
    if (gsYourPosition == gcNEUTRAL) {
    Alert.email("TEST 1.0 - Get in SHORT position now (SELL).", close());
    gsYourPosition = gcSHORT;
    }
    }
    }

  • #2
    It does not == short..

    I ran your code and changed the Alert.email() line to debugPrintln().

    This is the result....

    Before if... NEUTRALTrend SHORT1015.5
    Before if... SHORTTrend SHORT1015.25
    Before if... SHORTTrend SHORT1015.25
    Before if... SHORTTrend SHORT1015.5

    You'll see that the value of your indicator is NEUTRAL when the code first runs. Then your code switches it to SHORT - and it stays short for the rest of the codes operation.

    I think your code it fine. Alerts are typically not generated until the current bar. So, your code starts out with everything in NEUTRAL, but changes the variables to SHORT.

    By the time your alert gets triggered - it's SHORT because your code is forcing it to be SHORT.

    Hope this helps..

    Brad
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Strange Problem or eSignal Bugs?

      Thank Brad.

      So this means that I cannot count on Alert.eMail() function to do any alerts. Unless I have a way to make sure that Alert.eMail() is executed and completed before it goes to the next line of codes.

      Comment


      • #4
        Hello spin0,

        The Alert object only executes in real time, or when you are at the bar index of 0. When a formula is first applied to a chart, the formula processes the bar data starting with the oldest bar first. The Alert object will not generate alerts on historical data, otherwise you would get flooded with emails.
        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


        • #5
          Alert.email only works in Real-Time

          I've found an easy way to test the Alert.email() object....

          Use Advanced SMTP Server (http://www.softstack.com/advsmtp.html). It is free for 30 days. It needs to be registered if used beyond, but is a local SMTP server that LOGS the last 1000 messages. Nice to see if eSignal made an attempt at sending a message. Set View|Alerts|(Email) Settings|SMTP Hosts to localhost to use it. The softstack.com guys have a Free SMTP Server too, but I found that one doesn't have a message sent log, bummer.

          I've found that eSignal only sends Alert email when the Tools|EFS|Settings|'Make all formulas compute on close' is NOT checked. Repeat: NOT CHECKED. It only works in Real-Time, ie. Tick-by-Tick.

          One of the easiest ways to test the Alert object is to enter an Alert.playSound() into the function main() {} code and see if it plays.

          Now I just have to figure out how to have my code check the last COMPLETED bar's close(), since the above doesn't work and I am trying to check the bar's close(), not the high()/low().

          I went through a bit of pain to figure this out, hope it helps someone else.

          -function THEO(working)

          Comment


          • #6
            good job

            The conditional below is a check for a new bar

            if (getBarState() == BARSTATE_NEWBAR){
            //this is true at the beginning of a new bar

            }

            Do you understand that main() is processed every tick? and the above if statement is true at the beginning of a new bar.

            Last edited by ; 03-30-2004, 04:01 AM.

            Comment


            • #7
              tedsmith
              Another way is to use the setComputeOnClose(); statement in preMain().
              Alex

              Comment


              • #8
                Hello tedsmith,

                To get the last completed bar's close in real time, check for the bar state, BARSTATE_NEWBAR, and then reference close(-1).

                PHP Code:
                if (getBarState() == BARSTATE_NEWBAR) {
                    var 
                vPrevClose close(-1);

                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


                • #9
                  Wow, I'm impressed with all the responses!
                  Thanks all!

                  -function THEO( PayingHomageToTheGreatOnes );

                  Comment

                  Working...
                  X