Announcement

Collapse
No announcement yet.

Do it 5 Times on New bar

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

  • Do it 5 Times on New bar

    I know this code works for just creating 1 event per new bar,

    if (getBarState() == BARSTATE_NEWBAR) {
    vFlag = false;
    var vData1 = 5;
    var vData2 = 1;
    if (vData1 > vData2 && vFlag == false) {
    Alert.playSound(vSFREV);
    vFlag = true;
    }
    }

    But I need a few more signals/alerts, say the first 5 of a new bar.

    Better yet, it would be nice to have 5 alerts/signals but every 5th tick, so they are spread out a bit (every 5 ticks) instead of 5 in rapid suicession one right after anoteher with no pause.

    How would you add code to do this? Whatever I have tried, has not worked.

  • #2
    Untested, but I think this will work:

    Ouside of any function (ie: not in main() or preMain() or any other defined function):

    var nNewBarCounter = 0;

    In main() do the following:

    if (getBarState() == BARSTATE_NEWBAR || nNewBarCounter < 5) {
    if (nNewBarCounter >= 5 ){
    nNewBarCounter = 0;
    }
    nNewBarCounter++;
    vFlag = false;
    var vData1 = 5;
    var vData2 = 1;
    if (vData1 > vData2 && vFlag == false) {
    Alert.playSound(vSFREV);
    vFlag = true;
    }
    }
    Last edited by gspiker; 08-22-2006, 02:18 PM.
    Garth

    Comment

    Working...
    X