Announcement

Collapse
No announcement yet.

Fine-tuning custom alerts

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

  • Fine-tuning custom alerts

    I've been able to create a couple of custom alerts using the Formula Wizard, and have been tweaking them a bit each day to make everything perfect, but I haven't been able to figure out how to make the alerts fire only AFTER the latest bar is closed. Oscillators and indicators will traverse the range of several values just as price will over the course of a one-minute bar, and I'm finding that my alerts are triggering multiple times - multiple DOZENS of times in some cases - during the one minute it takes for the bar to complete.

    I'd really like to know how to modify the alert so that it fires only if the bar meets the specified requirements as it closes. I did try messing with the offset setting a few times, thinking that if I set it to a -1 it would fire on the previous bar (which *is* the last closed bar), but it did not work for me, leading me to think that that offset setting isn't what I think it is.

    Any ideas from you wizards out there?

    Thanks in advance,
    Gary

  • #2
    Gary
    You have several solutions available to you.
    The simplest one is to set the entire formula to compute on completed bars only. To do this you will need to edit the script with the Editor (Tools-> EFS-> Editor from the main menu in eSignal) and add the following line in the preMain() function
    setComputeOnClose();
    This statement will force the entire formula to compute on completed bars only. The drawback of this solution is that you do not get any real time plots of your indicator(s).
    The more appropriate way to accomplish this is to let the formula run in real time and only evaluate the conditions that will trigger the alerts (or other events) on completed bars.
    To do this you need to add the following in your conditions (this needs to be entered manually in the Formula Wizard)



    This condition will be true only on the first tick of every new bar.
    Once you have added this you need to modify your conditions to look back one bar respect to what you are currently doing so as to base them on the bar that has just completed otherwise you would be basing your conditions on the current bar which has instead just begun.
    Let us assume that your current condition is written as follows



    In this case an alert will be triggered every time the Close is above the moving average. Here is how you would need to change it so that the same alert is triigered only when the bar is completed



    Notice that I have added a check for a new bar and modified the existing consitions to evaluate the values at the prior bar (ie at Offset -1) rather than those of the current bar. Keep in mind that this alert will still trigger on the first tick of every new bar so long as the Close is above the average.
    If you want this event to be triggered only on the first bar in which the Close is above the average then you will need to write it as follows



    In this case I added a further statement to make the condition unique by also defining the position of the Close two bars back.
    Alex

    Comment


    • #3
      Fantastic. Since I don't plot anything with this formula, I don't need to do anything more than add the setComputeOnClose() line. Works perfectly.

      Thank you VERY MUCH for your help!

      Comment


      • #4
        Gary
        You are most welcome
        Alex

        Comment

        Working...
        X