Announcement

Collapse
No announcement yet.

EFS code Works on Historical Bars, but Not in Real Time

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

  • EFS code Works on Historical Bars, but Not in Real Time

    I have written the attached EFS code to signal the crosses of a 3 bar simple moving average, offset back 3 bars, with the upper and lower bollinger bands. When I apply it to a 1 minute bar chart of symbol NQ U3=2, it will signal the crosses of the historical bars, but not the crosses as they occur in real time.

    Can someone please help me rewrite the code so that it will signal the crosses, at the close of the bar, in real time?

    Thanks, Gary Moore
    Attached Files
    Gary Moore

  • #2
    Just edit the -3 and -4 to 0 and -1 respectively.

    Comment


    • #3
      dloomis,
      It would be nice if your suggestion worked in real time, but unfortunately, it does not. It works when reloaded on historical bars, but not in real time. Maybe it has to do with the moving average offset back 3 bars, finding the bollinger band value during that same time bar. The crossing signal will always be using data from 3 bars ago for the bollinger band, but current data offset back 3 bars for the moving average. There must be something I am missing. I would appreciate any other suggestions for a fix.
      Thanks, Gary Moore
      Gary Moore

      Comment


      • #4
        Solution...

        Get rid of line 25...

        setComputeOnClose(true);

        This line causes the system to wait for the bar to close before running the EFS.

        If you get rid of this line (comment it out with "//" at the beginning), your code will run in RT without any problems...

        Except, it might generate the EXIT code more than once as the market "ticks".. This can be resolved with a "timestamp".

        If you need more help, let me know.

        Brad
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          Brad,
          I took out "//" line 25, as you suggested. Again unfortunately, it will only work when reloaded on historical bars. It does not work in RT. I appreciate the help. Keep the suggestions coming. I'm sure (I hope) someone can figure out a fix.
          Thanks, Gary Moore
          Gary Moore

          Comment


          • #6
            Hi,

            What symbol and interval are you using?

            The EFS looks fine, and I think it should work...but there may be some issues on running it on tick charts.

            If you are running it on a normal interval chart, you might try (as a start) returning the values of the offset MA, and upper and lower bb's. I would setPriceStudy(false) when doing this. It should give some indication of what is going wrong.

            If you still have problems later tonight, let me know and I'll take a closer look.

            G
            Garth

            Comment


            • #7
              gspiker,
              I am running it on symbol NQ U3=2, one minute bar chart. I already do have the 3 bar SMA, offset -3 (back), and the bollinger band displayed on the chart. When the EFS is reloaded on historical bars, the signal is given on 2 bars past the crossing bar. If the crossing bar is #1, then the signal is given on bar #3. If the crossing bar is #0, then the signal is given on bar #2. I have thought that this was strange, but using bollinger -2 and -3, or -4 and -5, intead of -3 and -4, doesn't seem to make it work in real time either. It just shifts the bar on which the signal is displayed, when I reload it on historical bars. I have not tried returning the values of the offset SMA and upper and lower bb's as seen by the EFS. I just assumed that having them displayed on the chart would be the same thing. Right?
              I am open to any and all suggestions. Keep them coming.
              Thanks, Gary Moore
              Gary Moore

              Comment


              • #8
                I just assumed that having them displayed on the chart would be the same thing. Right?
                Well that's the whole point really. When debugging you test all your assumptions. If you don't you don't find solutions. If I was going to try to figure this out, that is the first thing I would have done...verified the formula was doing what I thought it was.

                G
                Garth

                Comment


                • #9
                  gspiker,
                  O.K., point well taken. I rewrote the EFS to display the 3 values, offset SMA, upper BB, and lower BB. The data is the same as the values presented by the studies I already have displayed on the chart. Again, using historical bars, the EFS finds and signals the crosses. So, we are right back to the original question "why does the EFS not signal the crosses in real time?". Help!
                  Thanks, Gary Moore
                  Gary Moore

                  Comment


                  • #10
                    Gary
                    The attached efs is a slight revision of the one in the first message of this thread and it is triggering the signals you see in the chart in real time using Tick Playback.
                    I would not know whether these are the signals you want, never the less it may give you some ideas.
                    Slightly different signals can be triggered by changing the -4 offset in the conditions of the MA to -3 but without the BB or MA plots it is difficult to tell which ones are correct.
                    Alex

                    Attached Files
                    Last edited by ACM; 08-27-2003, 05:31 PM.

                    Comment


                    • #11
                      Alexis,
                      Interesting thought. I have not tried that combination. I will see if it works tomorrow in real time.
                      Thanks for your help, Gary Moore
                      Gary Moore

                      Comment


                      • #12
                        HALLELUJAH !
                        Alexis's solution works beautifully in real time. Gspiker's trouble shooting suggestions showed me that in real time the offset SMA did not have a value on the current bar. Alexis's solution reached back 3 bars to obtain the offset SMA value. That was the key.
                        Thanks to Alexis, Gspiker, Doji3333, and dloomis for taking their time to direct me to the solution.
                        Good trading, Gary Moore
                        Gary Moore

                        Comment

                        Working...
                        X