Announcement

Collapse
No announcement yet.

Donchian channel alert

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

  • Donchian channel alert

    hi there,

    I've had lots of great help from this forum and I hope you guys can come through with this one! Attached/below is the Donchian channel with an offset of 1, which I use to ID trailing (any period) breaks, for entries and sometimes exits. I've tried to place the simple alert in the code without sucess. Here is what I want it to do. Once one of the channel lines are broken, give me an alert, ONLY ONE TIME, posted in the alert trigger list and a sound. (it's already giving a color bar when triggered). I had placed the alert string right after the following if and else statements,

    if(high() > hh)
    setPriceBarColor(Color.lime);
    else if(low() < ll)
    setPriceBarColor(Color.red)
    else
    setPriceBarColor(Color.black)

    which worked but alerts kept repeating with each new price.

    Thanks for your help,

    chris...

    //////////////////////////////////////////////////////////////
    //This is the Donchian channel with offset of 1
    //alert test
    function preMain() {
    setStudyTitle("Chris HHLL alert");
    setCursorLabelName("Highest High", 0);
    setCursorLabelName("Lowest Low", 1);
    setPriceStudy(true);
    setColorPriceBars(true);
    }

    var bIsLong = false;
    var bIsShort = false;

    function main(nInputLength) {
    if(nInputLength == null)
    nInputLength = 2;

    var nLength = nInputLength + 1;
    var i;
    var hh = 0;
    var ll = 0;

    var vLow = low(0, -nLength);
    var vHigh = high(0, -nLength);

    if(vHigh == null || vLow ==null)
    return null;

    for(i = 1; i < nLength; i++) {
    hh = Math.max(hh, vHigh[i]);
    if(i == 1)
    ll = vLow[i];
    else
    ll = Math.min(ll, vLow[i]);
    }
    if(high() > hh)
    setPriceBarColor(Color.lime);
    else if(low() < ll)
    setPriceBarColor(Color.red)
    else
    setPriceBarColor(Color.black)
    return new Array(hh,ll);


    //set popup on alert list and sound
    if(high() > hh) {
    if(!bIsLong) {
    Alert.addToList(getSymbol(), "Highest High", Color.black, Color.green);
    Alert.playSound("swoosh.wav");
    bIsLong = true;
    bIsShort = false;
    }
    } else {
    //set popup on alert list and sound
    if(low() < ll) {
    if(!bIsShort) {
    Alert.addToList(getSymbol(), "Lowest Low", Color.blue, Color.red);
    Alert.playSound("train.wav");
    bIsLong = false;
    bIsShort = true;
    }
    }
    }
    }
    //////////////////////////////////////////
    Last edited by cgnahc; 03-04-2003, 11:49 AM.

  • #2
    Chris
    You may want to try again with the attachment.
    Also have you tried adding setComputeOnClose()?
    Alex

    Comment


    • #3
      hey alex,

      I cut and pasted the code I have below. took some trial and error sessions. what's the best way (procedure) to post a formula file?

      chris

      Comment


      • #4
        Chris
        When you create a message (or reply to one) if you scroll towards the bottom of the page you will see that there is a section called Attach file: and next to it there is a box and a Browse button.
        You can then navigate your folders find the file and attach it.
        Accepted file formats are graphic files, txt, doc, efs and zip.
        Alex

        Comment


        • #5
          alex,

          yes, I think I had my formula file open when I attached, so it didn't work. I'm going to try again here.

          Where do you suggest placing the setcomputeonclose? Before return new array?

          chris...
          Attached Files

          Comment


          • #6
            Chris
            I don't know why your formula is not playing any alerts so I just created the same using the Formula Wizard.
            Attached is the resulting efs that should color the bars respectively in green or red, play one ding only and trigger an Alert when the Donchian Upper or Lower channels are broken.
            You may be able to extrapolate what you need out of it.
            Alex
            Attached Files

            Comment


            • #7
              alex,

              Wow, it plots the same. Gonna take a closer look at that Wizard. Didn't know there was a getValue for the DonchianStudy. One last request...Can it make the input length variable? I had this in my old code.

              function main(nInputLength) {
              if(nInputLength == null)
              nInputLength = 2;

              var nLength = nInputLength + 1;

              I'll have to load and check the response during market hours.
              Thanks so much!!!!

              chris...
              Last edited by cgnahc; 03-04-2003, 04:02 PM.

              Comment


              • #8
                Re: Reply to post 'Donchian channel alert'

                Chris
                For now you cannot but the next version of the Wizard (no idea when it will
                be released) is supposed to have a lot more features amongst which the
                option to pass variables to built-ins and more.
                Non the less even with some of the limitations the current Wizard is very
                good and very handy.
                For now you can either use the Editor to change the variables or the Wizard
                itself.
                Alex

                Comment


                • #9
                  Closing Thoughts:

                  The wizard works very well. I've been working with it non stop. After working with it, my original question was an easy fix, but, learned something new from Alex's code in set 3. This BB is great, especially with all the new moderators I've noticed.

                  One scary moment, when somehow the layout (with new wizard alert formulas) wasn't saved properly and could not load eSignal the following session. Loaded a backup version and saved the day. Possible bug?

                  Lastly, it would be nice on the next version to include the price in the Triggered Alert List, just like when we open an alert ticker window. I'm going to try to fit last price in the comment line from editor.

                  Thanks for all your help...

                  chris...

                  Comment

                  Working...
                  X