Announcement

Collapse
No announcement yet.

NaN

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

  • NaN

    I am creating a test strategy. When I run the strategy on data sometimes the bars seem to have no prices/values (open/high/low/close) and return "NaN" when I check values using "debugPrint". Does anyone know why that happens? Am I missing something?

    Thanks in advance!

    --TC
    --TC

  • #2
    Hi TC,

    Not sure what could be causing this, though it sounds like it's with the code. If you could post the code here we can get more eyes on it.

    I see that this was your first post. Welcome Aboard!!

    Regards,
    Andy S.
    eSignal Support

    Comment


    • #3
      NaN

      Originally posted by AndyS
      Hi TC,

      Not sure what could be causing this, though it sounds like it's with the code. If you could post the code here we can get more eyes on it.

      I see that this was your first post. Welcome Aboard!!

      Regards,
      Andy S.
      eSignal Support

      I have already changed the code. But basically I was trying to issue LIMIT orders like these:

      if (high() > high(-1) && high(-2) > high(-1))
      {
      if (!Strategy.isLong())
      Strategy.doLong("Long Entry",Strategy.LIMIT,Strategy.THISBAR,Strategy.DE FAULT,high(-1)+1);
      }

      if (low() < low(-1) && low(-2) < low(-1))
      {
      if (!Strategy.isShort())
      Strategy.doLong("Short Entry",Strategy.LIMIT,Strategy.THISBAR,Strategy.DE FAULT,low(-1)-1);
      }

      These are small 3 bar reversals. My other question is concerning the LIMIT price that am specifying. I want to go long/short at 1 pt above the previous bar high/low. So these orders are to be generated on the 3rd bar. Do you think this code is right for that concept? BTW Is there some guide that clearly indicates how eSignal decides on entry/fill price for LIMIT & STOP orders? This is a bit confusing for me at the moment.

      Thanks!

      --TC
      --TC

      Comment


      • #4
        Hello TC,

        In order to determine why you were getting "NaN" from your debugPrint statement, we need to see how you were using it. If this issue is still unresolved for you, post an example of your debugPrint statement.


        As for your code, I believe you intended to use a Strategy.doShort() for your short entry instead of doLong(). Also, I changed the order around a bit. There's no need to make the calls to high() if you are currently in a long position for example.

        Code:
        function main() {
            if (!Strategy.isLong()) {
                if (high() > high(-1) && high(-2) > high(-1)) {
                    Strategy.doLong("Long Entry",Strategy.LIMIT,Strategy.THISBAR,Strategy.DEFAULT,high(-1) + 1);
                }
            }
        
            if (!Strategy.isShort()) {
                if (low() < low(-1) && low(-2) < low(-1)) {
                    Strategy.doShort("Short Entry",Strategy.LIMIT,Strategy.THISBAR,Strategy.DEFAULT,low(-1) - 1);
                }
            }
            
            return;
        }
        Your code looks logical to me, but keep in mind that depending on the symbol you use with this formula, your fill prices could be unrealistic in some cases. Read through the documentation on back testing strategies. You might want to consider some different logic for setting the limit prices.

        http://www.esignalcentral.com/traini...ackTesting.asp
        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


        • #5
          Re: NaN

          I have attached my strategy file. The problem I have is with the LIMIT Long & Short orders at the bottom of the file. These are my entries and sometimes they get filled and sometimes they don't. When they don't get filled I see a NaN in the "Formula Output Window" when debugPrint is used.

          I am running these strategy on DJ Euro Stoxx 50 futures contract on EUREX. That is why the buy/sell 1 pt above the previous high (1 tick = 1 pt). If you run this strategy on this futures contract (Dec 2002) you will see lots of NaNs in the output window. I am not able to figure out why these are not getting filled. And what does NaN mean?

          Thanks,

          --TC

          Originally posted by JasonK
          Hello TC,

          In order to determine why you were getting "NaN" from your debugPrint statement, we need to see how you were using it. If this issue is still unresolved for you, post an example of your debugPrint statement.


          As for your code, I believe you intended to use a Strategy.doShort() for your short entry instead of doLong(). Also, I changed the order around a bit. There's no need to make the calls to high() if you are currently in a long position for example.

          Code:
          function main() {
              if (!Strategy.isLong()) {
                  if (high() > high(-1) && high(-2) > high(-1)) {
                      Strategy.doLong("Long Entry",Strategy.LIMIT,Strategy.THISBAR,Strategy.DEFAULT,high(-1) + 1);
                  }
              }
          
              if (!Strategy.isShort()) {
                  if (low() < low(-1) && low(-2) < low(-1)) {
                      Strategy.doShort("Short Entry",Strategy.LIMIT,Strategy.THISBAR,Strategy.DEFAULT,low(-1) - 1);
                  }
              }
              
              return;
          }
          Your code looks logical to me, but keep in mind that depending on the symbol you use with this formula, your fill prices could be unrealistic in some cases. Read through the documentation on back testing strategies. You might want to consider some different logic for setting the limit prices.

          http://www.esignalcentral.com/traini...ackTesting.asp
          --TC

          Comment


          • #6
            file attachment

            The file I had attached to the previous post didn't go thru'. Will try this once again, hope I am doing everything right. I can see the file path in the "Attach file" entry field (file selected using the "Browse" button). Where am I going wrong?

            --TC
            Attached Files
            --TC

            Comment


            • #7
              TC

              If you are using an e-mail client (Outllook, Outlook Express etc) then attachments will not be posted.

              If instead you are posting your message online it depends on the type of attachment. You can only attach graphic (bmp, jpg, gif or png), zip or txt files.

              If you want to post an efs file then may I suggest you load it in FileShare (in the Open Publishing Group for example or a group of your own) and then post the link here.

              Alex

              Comment


              • #8
                To your:

                PHP Code:
                if (vTime == null) {
                   return;

                I would suggest adding:

                PHP Code:
                if (vTime == null || esval ==null || elval == null || pesval == null) {
                   return;

                NaN stands for 'not a number'

                Comment

                Working...
                X