Announcement

Collapse
No announcement yet.

if stmt controlling another if stmt question

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

  • if stmt controlling another if stmt question

    Any ideas if the following idea can be implemented. I want to define a variable, cpuLoad, to determine if the efs runs on every tick or every new bar.

    This code has a lot of stuff wrong and I was wondering how to fix it.

    My alternative is to just comment out one or the other getBarState lines.

    if(cpuLoad=="Lite"){
    if(getBarState()==BARSTATE_NEWBAR&&getCurrentBarIn dex()==0){ //Runs at the start of a new bar, cpu lite
    }
    else}
    if(getBarState()==BARSTATE_CURRENTBAR&&getCurrentB arIndex()==0)){ //Runs on (almost) every tick, cpu heavy
    }

  • #2
    Dave:

    I might be missing something but couldn't it be as simple as:

    //if "Lite" only run on each new bar, otherwise run every tick
    if (cpuLoad=="Lite") {
    if (getBarState() != BARSTATE_NEWBAR) {
    return;
    }
    }

    Chris

    Comment

    Working...
    X