Announcement

Collapse
No announcement yet.

Questions about results in real time

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Questions about results in real time

    Hi,

    Can anyone spot what I am doing wrong in the attached efs?
    It plots fine historic data, but not in real time.

    Thank you.
    Mihai
    Attached Files
    Mihai Buta

  • #2
    Hi Mihai,

    You have several problems with this efs Mihai. First, you have some feedback in the calculation that if it is run every tick, it would cause the output to go to zero. Basically positive feedback. You have to be careful here.

    The other problem is that in real time, when you use zero for the bar index, you are using the highs and lows from the new bar (first tick) in real time. When loading it up with historical values, you are using the value of the closed bar.

    Regardless of whether you are using efs1 or efs2, these are problems with your code.

    I am going to bed presently. There are a number of ways you can get around this (the bar index issue), I would recommend a forum search, as issues similar to this have been discussed extensively.

    Comment


    • #3
      Steve,

      I understand your comments and:
      a/ Yes, I oversimplified the efs and did not make ref=-1 on NEWBAR [because I know open=close=high=low]. I uploaded a new version to correct that, but this is NOT the problem.

      b/ About "feedback": I don't understand what is the problem with using a previously calculated value, because that is what I am doing [or trying to do] here.

      Note: I did search for a Wells Sum [or similar] example but could not find one. Your help in resolving this issue would be appreciated.

      Thank you.
      Mihai

      Mihai Buta

      Comment


      • #4
        Sorry,
        Forgot to upload the modified efs.

        Here it is.
        Attached Files
        Last edited by mbuta; 07-15-2005, 04:24 PM.
        Mihai Buta

        Comment


        • #5
          Hi Mihai,

          I believe I have figured out the problem with your efs, but it will take more time to explain to you than I have at present. Just a recommendation, but you may want to consider using debugPrintln or my trace utility as a debug tool. That would help you see better what the problems are, at least IMO.

          Regardless, as you posted it, referring to the previous bar (-1) versus the most recent bar value, as you had it previously, appears to make it work fine in tick playback.

          I should be able to put some more time into this tomorrow, where I want to post various versions, with my trace utility incorporated, to show you what I am seeing. I am very tired tonight and would probably miss something. So I will try and post something later tomorrow when I have some more time.

          Comment


          • #6
            Steve,

            Thank you and take your time.
            I need this template because I am using it for many other things [to avoid long moving averages that eat up time].

            Maybe, if you have time and disposition, take a look at my other posts on "EFS2 Development"?

            There are two issues there related to efsInternal.

            Thank you.
            Mihai
            Mihai Buta

            Comment


            • #7
              Hi Mihai,

              Well, I have spent several hours on this today. What I would like to do is start with your efs, with all of your comments stripped out, and my modifications in place. I have added a section that writes comments to a file (my trace utility) which should help you understand what the efs2 engine is doing to your efs. I would like to start out showing you how the efs works at present, then, after we have done that, post another example with the fixes in place. I believe going through this in that manner will help greatly.

              Here are the issues as I see them:

              1. You are declaring an internal efs using efsInternal, yet you are accessing it like a regular function. I know why you were doing it, however, it should not be done, as bad things happen. Here is why:

              2. When you declare this using efsInternal, you are passing control to the efs2 engine. Any reference to BARSTATE_NEWBAR within main has no effect on how the efs2 engine deals with the internal efs. In other words, you were calling the internal efs every bar, however, unbeknownst to you, the efs2 engine is also calling it every tick.

              3. The efs2 engine will load the internal efs, and the main efs seperately. This is just an FYI that you will see when you load the efs and look at the file.


              Please take this efs into a tick replay file that has been played back 150 to 200 bars and paused. Take a look at the output file from the efs prior to pressing the tick replay play button.

              Once you have pressed the replay button, let it run around 50 bars, then pause the replay file. You should see that the AvBar variable in main is different than the AvBar variable in your internal efs. Now, why do you think that is ...?

              Here is the file as I have modified it, we can discuss what you see after you take a look at the output. Hopefully, what you see is similar to what I have been observing on my end.

              For reference, I have been running a tick replay file of ES #F, with an interval of 150T. The version of eSignal is 7.9.1, release candidate #4.

              Here is the efs:


              PHP Code:
              var stAvBar;
              var 
              AvBar 0;

              function 
              preMain() {
                  
              setPriceStudy(false);
                  
              setCursorLabelName("Plot0"0);
                  
              setDefaultBarFgColor(Color.cyan0);
                  
              setDefaultBarThickness(40);
              }

              function 
              main() {
                  
              trace ("");    trace ("12: AvBar = "+AvBar);
                
              nBarState   getBarState();
                  if(
              nBarState == BARSTATE_ALLBARS) {  
                  
              stAvBar     efsInternal("AvBarF_s0");
                  
              debugClear();
                }
                if (
              nBarState == BARSTATE_NEWBAR) { 
                  
              AvBar     AvBarF_s0(-1);
                      
              trace ("20: getCurrentBarCount() = "+getCurrentBarCount());
                }
                  
              trace ("22: AvBar = "+AvBar);
                return 
              AvBar;
              }

              function 
              AvBarF_s0(ref) {
                if (
              ref==nullref=-1;trace ("27: ref = "+ref);
                var 
              BarCnt  getCurrentBarCount(); trace ("28: BarCnt = "+BarCnt);
                var 
              AvIdx = (BarCnt<=300) ? BarCnt 300trace ("29: AvIdx = "+AvIdx);
                
              AvBar = (AvBar>0) ? (AvBar*(AvIdx-1) + (high(ref)-low(ref)))/AvIdx high(ref)-low(ref);
                  
              trace ("31: AvBar = "+AvBar);
                  
              trace ("31: typeof(AvBar) = "+typeof(AvBar));
                return 
              AvBar;
              }


              //########### trace section required to be copied complete ##############
              var traceon true;// previous tracefile is overwritten if this is true
              //var traceon = false;// previous tracefile is added to if this is false
              var nStudy "MButaS0.txt";// -  name to be used to name tracefile and button
              var    tracefile = new File(nStudy);
              function 
              trace(data1){
                  
              //if ((getCurrentBarIndex() < -10))return;
                  
              debugPrintln(data1);//comment this line out if you do not want the output echoed to the formula output window

                  
              if (traceon){//first use is true, overwrites previous trace file
                      
              traceon false;
                      
              tracefile.open("wt+");tracefile.close();//opens and overwrites previous file
                      
              tracefile.open("at+");
                  }
                  
              //tracefile.open("at+");
                  
              tracefile.writeln(data1);tracefile.flush();
                  
              //tracefile.close();
                  
              if (trace.caller.name!="preMain" && trace.caller.name!="postMain")tButton();//call to the button that allows opening text file
              }
              function 
              tButton(){
              drawTextPixel(50100, (" click here to see the "+nStudy+" file " "@URL=C:\/Program\ Files\/eSignal\/FormulaOutput\/"+nStudy),  Color.rednullText.RELATIVETOLEFT Text.RELATIVETOBOTTOM|Text.FRAME"Comic Sans MS"13,"trace11");
              }
              //########## section required to be copied complete ################
              function postMain() {
                  if(
              tracefile.isOpen())tracefile.close();//used for trace utility
              }
              //########## include this in above section  ################ 

              Comment


              • #8
                Steve,

                Thank you for all the effort and I will do what you instructed me to do. I have to confess that I never used Tick Replay, so I need some time to get used to it.

                Note1. Apparently, you did not download the last version of my efs. It has not efsInternal, but still gives the same simptoms.

                Thank you,
                Mihai
                Mihai Buta

                Comment


                • #9
                  Hi Mihai,

                  I did download your most recent upload, please check out line 35 of your posted efs:
                  stAvBar = efsInternal("AvBarF");

                  Comment


                  • #10
                    Hi Steve,

                    You are right, sorry. Somehow I loaded the wrong version.

                    Here it is, or just delete the efsInternal in the one you have and access the function directly.

                    Thanks,
                    Mihai
                    Attached Files
                    Mihai Buta

                    Comment


                    • #11
                      Mihai,

                      What I had done with your efs was to take what you had posted and show you why things were behaving in the manner in which they were. I had two more examples set up in the cue to show you how to correctly set up the efs to run in efs2 in real time. I was planning on rolling them out once you were done running the followup efs I posted in tick playback.

                      Changing to the new code now will have an adverse affect on the flow of the examples I had set up, as my intent was to show the interaction between the efs2 engine and your efs.

                      Regarding use of Tick replay, it is a very good troubleshooting tool which allows you to develop an understanding of your code, especially with regards to the difference in behavior between historical bars and realtime. IMO, it is indespensible for use in code development.

                      Use of tick replay along with me taking you through the examples will make you understand what is going on with the efs2 engine Further, it will provide the feedback as to why you are having so many problems with the platform.
                      Last edited by Guest; 07-19-2005, 10:11 AM.

                      Comment


                      • #12
                        Hi Steve,

                        Thank you.
                        I will stop anything else and learn the Tick Replay.
                        I will let you know when I completed your assignment.

                        Mihai
                        Mihai Buta

                        Comment


                        • #13
                          Hi Steve,

                          I ran the file in Replay Mode [Bar Replay, because could not find the Tick Replay thing].

                          I did look at the trace [in Output Window, because I could not open your trace file] and did see that Trace 31 is diferent.
                          As it occurs before main, it must be that EFS2 engine calls the function, as you said, on every tick, in background.

                          But I also noticed that the EFS2 call DOES NOT update MY global var, which means that EFS2 call is not a regular call.

                          Now:
                          1. I still not understand why the EFS2 call and my direct call produce diferent results. They both use the same reference.
                          Note: I used direct call [in real time] only because getValue gave erroneous results.

                          2. I still don't understand how to retrieve correct values in real time from an EFS2 series, declared in an external time interval.

                          3. I still don't understand why we cannot retrieve directly, individual values from an efsInternal that returns an array without "extracting" the series first with getSeries.
                          This is a very common situation, where EFS2 can make a huge diference, but getSeries is a performance killer.

                          Thnak you and best regards.
                          Mihai
                          Mihai Buta

                          Comment


                          • #14
                            Mihai,

                            Instructions for Tick Replay can be found here. Tick Replay allows you to test your formulas and strategies in a simulated real-time environment on a tick-by-tick basis rather than completed bar data like the Bar Replay tool.

                            Regarding your point number 3:

                            To see the differences that I was inferring to, you really need to use tick replay.

                            Regardless, you did see that global variables, when shared between the efsInternal function and the main efs are created as different variables, where the variable in the efsInternal is a global that is local to the "efsInternal function". In reality, when you impose the efsInternal command, the efsInternal function is used to create a seperate efs2 "instance". This "instance" is a copy of your function that is controlled by the efs2 engine, not your efs. This is a critical concept.

                            You saw this a little bit in bar replay, however, you really need tick replay to appreciate this fully and understand why getSeries and getValue are returning different results and appear to you to be performance killers. Once you get Tick replay going, I believe I can show you where you are going wrong and potentially streamline your processes.

                            Regarding your point number 1:

                            The seperate instance I discussed above is key. When you are calling your variable, you are calling the function, once per bar. When you are calling for the efs2 variable, you are asking for a variable that is associated with a different instance of the function, that is being updated every tick, thus my previous reference to why positive feedback was affecting you.

                            Please understand that using getValue is returning exactly the number that you are calculating in this seperate instance of the function, it is not erronious, just not what you expected.

                            Regarding your point number 2:

                            The answer to your point number 2 will be a natural fallout to the solution to number 3 and number 1, and will become obvious to you, I believe, once you get tick playback up and running.

                            Regarding the opening of the trace file, that should have only invoved opened by clicking the button on the chart, provided of course that you have some program set to automatically open up txt files. Alternatively, you can easily grab it in the Formula Output folder, provided you are using that as your default output folder.

                            Comment


                            • #15
                              Hello Mihai,

                              In the most recent file you attached (allobos.v8.test1.efs) there is a syntax error on line 51. Please add your logic for nBars and repost. Also, it would be helpful if you could describe what you are trying to accomplish with this example. I'm uncertain as to what result you are after.
                              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

                              Working...
                              X