Announcement

Collapse
No announcement yet.

How write code for alert signal after bar closes

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

  • How write code for alert signal after bar closes

    How do you write code for the alert to trigger signal after the bar closes not during the bar. I wrote this and it alerts during the bar.

    close(0) > open(0) &&

    high(0) >= high(-1)+.02 &&

  • #2
    Re: How write code for alert signal after bar closes

    sjsr
    You do that by creating a condition that checks for the first tick of a new bar using the getBarState() function (see the link to the KB article for the description and syntax). Then inside the conditional statement you evaluate your condition based on the values of the prior bar or bars eg
    PHP Code:
    if(getBarState()==BARSTATE_NEWBAR){
        if(
    close(-1) > open(-1) && high(-1) >= high(-2)+.02 && ...){
            
    //rest of your code
        
    }

    As you can see in the revised example the bar indexes are now looking at one bar back
    FYI bar state is covered in detail in the Tutorial 4 Understanding Bar State and Bar Indexing which is in the Help Guides and Tutorials-> Beginner Tutorials folder of the EFS KnowledgeBase
    Alex



    Originally posted by sjsr
    How do you write code for the alert to trigger signal after the bar closes not during the bar. I wrote this and it alerts during the bar.

    close(0) > open(0) &&

    high(0) >= high(-1)+.02 &&

    Comment

    Working...
    X