Announcement

Collapse
No announcement yet.

Adding Formula Parameters question

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

  • Adding Formula Parameters question

    Hello,
    I've been using the script below to view just todays efs data while the chart above it displays multi-days of price data. Sometimes however I want to view multi-days of efs data also. I've been trying to use Formula Parameters so I can easily 'bypass' the script below via Edit Studies, but am having no luck. I am hoping someone knows of an efs where this has been done. Or maybe there is an easier way?

    Any help would be appreciated
    Thanks
    shaeffer

    function preMain() {

    var bCurrentDay = false;

    function main() {

    if(getBarState()==BARSTATE_ALLBARS){
    bCurrentDay=false;
    }
    if (bCurrentDay == false && getDay(0) != getDay(-1)){
    var xTime = getValue("time");
    var xDate = new Date();
    var sTime = (xTime.getMonth()+1+"/"+xTime.getDate()+"/"+xTime.getFullYear());
    var sToday = (xDate.getMonth()+1+"/"+xDate.getDate()+"/"+xDate.getFullYear());
    if ( sTime == sToday ) {
    bCurrentDay = true;
    }
    }
    if (bCurrentDay==false){
    return;
    }

  • #2
    Re: Adding Formula Parameters question

    shaeffer
    Add a boolean FunctionParameter called for example "Test", set it to true by default and add the parameter to the arguments of main. Then enclose the entire section of code
    if(getBarState()==BARSTATE_ALLBARS){
    ...
    if (bCurrentDay==false){
    return;
    }

    in a conditional statement that checks if Test is true.
    When the Test parameter is set to false that entire section of code will not be executed thereby returning the plots also on previous days
    Alex


    Originally posted by shaeffer
    Hello,
    I've been using the script below to view just todays efs data while the chart above it displays multi-days of price data. Sometimes however I want to view multi-days of efs data also. I've been trying to use Formula Parameters so I can easily 'bypass' the script below via Edit Studies, but am having no luck. I am hoping someone knows of an efs where this has been done. Or maybe there is an easier way?

    Any help would be appreciated
    Thanks
    shaeffer

    function preMain() {

    var bCurrentDay = false;

    function main() {

    if(getBarState()==BARSTATE_ALLBARS){
    bCurrentDay=false;
    }
    if (bCurrentDay == false && getDay(0) != getDay(-1)){
    var xTime = getValue("time");
    var xDate = new Date();
    var sTime = (xTime.getMonth()+1+"/"+xTime.getDate()+"/"+xTime.getFullYear());
    var sToday = (xDate.getMonth()+1+"/"+xDate.getDate()+"/"+xDate.getFullYear());
    if ( sTime == sToday ) {
    bCurrentDay = true;
    }
    }
    if (bCurrentDay==false){
    return;
    }

    Comment


    • #3
      Success. Thanks, Alex

      Comment


      • #4
        shaeffer
        You are welcome
        Alex


        Originally posted by shaeffer
        Success. Thanks, Alex

        Comment

        Working...
        X