Announcement

Collapse
No announcement yet.

AlertOncePerBar.efs

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

  • AlertOncePerBar.efs

    If I do not use this setting, how many times per bar EFS will be executed. Or may be in other words, with what friquency EFS works. What should I do to run EFS 2,3,n times per bar.

    Thanks,
    Rost

  • #2
    Hello Rost,

    The main() function will execute with every trade. If your condition for the alert is meet and you do not incorporate some logic similar to the first example, the alert will trigger on every trade where the condition is true.

    In the example below, I've added a counter, vFlagCntr, to keep track of how many times the alert is triggered during the interval for the bar. This example will allow the alert to be triggered up to 3 times when the alert condition is true.

    PHP Code:
    /*********************************
    Provided By : eSignal. (c) Copyright 2003
    *********************************/
    var vFlag false;
    var 
    vFlagCntr 0;

    function 
    main() {
        if (
    getBarState() == BARSTATE_NEWBAR) {
            
    vFlag false;
            
    vFlagCntr 0;
        }


        
        var 
    vData1 5;
        var 
    vData2 1;
        
        if (
    vData1 vData2 && vFlag == false && vFlagCntr 3) {
            
    Alert.playSound("train.wav");
            
    setBarBgColor(Color.yellow);
            
    vFlag true;
            
    vFlagCntr += 1;
        }
        
        return;

    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
      Hi Jason,

      Thank you for the reply.
      First of all you want to say that -The main() function will execute with every tick. Am I correct?

      Secondly, as I can see in your code, alarm will work three times in total but at the beginning of each bar. It means it will work once a bar.
      What I would like to figure out, how to run this code 3 times a bar. Let say at the beginning of the bar, in 10 min and in 20min on 30min bar interval.

      Thanks,
      Rost

      Comment

      Working...
      X