Announcement

Collapse
No announcement yet.

Advice on which data to use for a intraday formula.

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

  • Advice on which data to use for a intraday formula.

    I am trying to set a long or short value for an EFS variable to be used on an intraday chart.

    Basically I want the variable to be true if the current price is above the yesterday's close.

    I have tried dsgetValueAtTime to achive this but it unfortunately hangs the computer as it steps through all the chart data until it has loaded all the bars.

    I have tried to work around this by using a 1 day 24 hour time template but for some reason I am getting a null value where I should be getting the close even though enough bars are loaded and the closing value I require is on the chart.

    Any suggestions would be appreciated

    Thanks

    [ code]var myLib = addLibrary( "dsUtilities.efsLib" );

    function preMain() {
    setStudyTitle("Test");
    setPriceStudy(true);
    setShowCursorLabel(false);

    }

    function main(){

    var nYestClose = myLib.dsgetValueAtTime( "16:00", 1, close() );

    debugPrintln("nYestClose " +nYestClose);

    } [/code ]

  • #2
    Re: Advice on which data to use for a intraday formula.

    Patch227
    The reason you are getting a null with a 1 day time template could be because there is no bar time stamped 16:00 available on the chart for the specified day. Try loading more days of data through the Time Template.
    With regards to the formula hanging while it loads try enclosing the line of code in which you retrieve nYestClose inside an if(isLastBarOnChart()) statement. This way that line of code will be executed only when the script is processing the last bar on the chart (ie the current one)
    Alex


    Originally posted by Patch227
    I am trying to set a long or short value for an EFS variable to be used on an intraday chart.

    Basically I want the variable to be true if the current price is above the yesterday's close.

    I have tried dsgetValueAtTime to achive this but it unfortunately hangs the computer as it steps through all the chart data until it has loaded all the bars.

    I have tried to work around this by using a 1 day 24 hour time template but for some reason I am getting a null value where I should be getting the close even though enough bars are loaded and the closing value I require is on the chart.

    Any suggestions would be appreciated

    Thanks

    [ code]var myLib = addLibrary( "dsUtilities.efsLib" );

    function preMain() {
    setStudyTitle("Test");
    setPriceStudy(true);
    setShowCursorLabel(false);

    }

    function main(){

    var nYestClose = myLib.dsgetValueAtTime( "16:00", 1, close() );

    debugPrintln("nYestClose " +nYestClose);

    } [/code ]

    Comment


    • #3
      Re: Re: Advice on which data to use for a intraday formula.

      Hi Alex

      The strange thing isthat I have a 16.00 bar and a value but still get a null return

      The isLastBarOnChart is perfect and I will use this a lot in future

      Thanks for the help

      P





      Originally posted by Alexis C. Montenegro
      Patch227
      The reason you are getting a null with a 1 day time template is probably because there is no bar time stamped 16:00 available on the chart for the specified day.. Try loading more days of data through the Time Template.
      With regards to the formula hanging while it loads try enclosing the line of code in which you retrieve nYestClose inside an if(isLastBarOnChart()) statement. This way that line of code will be executed only when the script is processing the last bar on the chart (ie the current one)
      Alex

      Comment


      • #4
        Patch227
        You are most welcome
        Alex


        Originally posted by Patch227
        Hi Alex

        The strange thing isthat I have a 16.00 bar and a value but still get a null return

        The isLastBarOnChart is perfect and I will use this a lot in future

        Thanks for the help

        P

        Comment

        Working...
        X