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

  • #16
    Jason,

    You are right, I saw that two days ago, but did not upload a corrected file because we evolved past that point. However, the nBars was nothing else than the number of bars in the chart, to calculate RealTime, which can now can be done simpler with your new functions.

    Steve,
    I will go and do the Tick Replay and I am sure I will find what you say. Again, I understand that the real time values are not incorrect [mathematically speaking], I just can't make sense of them and don't understand how they can be used to make trading decisions. They go all over the map [intra-external-bar].

    Note: I compare that output to my emulation, which is simply a multiple of base interval.
    For example: cci(20, inv(15)) in a 5 min chart, I have it as cci(20*5). I know it is not the same, but at least gives consistent output.

    I go do the Tick Replay.
    Steve, I saw no button in my pane and I have not changed any settings, they are loaded with 7.9.1,

    Thank you
    Last edited by mbuta; 07-20-2005, 02:34 PM.
    Mihai Buta

    Comment


    • #17
      Hi Steve,

      I did the Tick Replay and I think I understand what happens, which now appears obvious.

      First, I passed over the AvBar example, because it was clear that my assumption [that EFS2 engine uses MY global var] was incorrect. I modified the script to calculate [at ALBARS] the value for entire data series and use it as a constant, Less accurate, but no problems anymore.

      I spent more time running EFS2 studies for external time intervals and, as I said, I think I understand what happens: the real time values go all over the map, but that is normal.
      They do the same thing in base interval, but there we don't care. If we don't like the intra-bar values, we just wait for NEWBAR to get the value at the close of the bar.
      With external intervals we can't do that. We do not have an indication when the external bar has finished and maybe this what is really missing [pass it as a suggestion?!?].
      If we had this information we can do the same thing. Moreover, we may also be able to access the external time interval indicators based on chart bars [which now it is not possible and I find it a limitation].
      NOTE: I would introduce a getBarState(inv(xx)), or something similar. This would, most likely, reduce significantly the EFS2 overhead for time synchronization [do it once and apply it to all studies].

      Now, I understand what is happening, but still don't know how to address the issue. Any suggestions?

      Thank you,
      Mihai

      P.S. I assume there is no way to filter out the ticks in pre/post market.
      Last edited by mbuta; 07-20-2005, 06:14 PM.
      Mihai Buta

      Comment


      • #18
        Mihai

        With external intervals we can't do that. We do not have an indication when the external bar has finished

        You can do that in 7.9.1 using
        getBarStateInterval("interval")
        getBarStateSymbol("symbol" or "symbol,interval")

        In both functions the parameter is a string and you do not use inv() or sym()

        Moreover, we may also be able to access the external time interval indicators based on chart bars

        If you mean accessing external bar time you can do that using for example
        minute(inv(interval))
        hour(sym(symbol,interval))
        etc

        Alex

        Comment


        • #19
          Hi Mihai,

          Well, obviously you see the advantages of tick playback, especially when trying to create any efs that may not be straightforward. Alex had advised me about employing this technique a while back. Needless to say, it really helped me out as well.

          It sounds like you have advanced a little farther than this next efs, if you would, please download this next efs and run this. It is very similar to the last one, with a couple of steps I will comment out in the next version. I believe going through this exersize will help answer your questions.

          In this example, I am also retrieving the efs2 value and comparing it with what the efs2 engine is computing.


          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_s1");
              
          debugClear();
            }
            if (
          nBarState == BARSTATE_NEWBAR) { 
              
          AvBar     AvBarF_s1(-1);
                  
          trace ("20: getCurrentBarCount() = "+getCurrentBarCount());
            }
              
          trace ("22: This is still the function return ==>> AvBar = "+AvBar);
              
          trace ("23: This is efs2 variable call still not what you want, however exactly what the efs2 instance is calculating ==>> stAvBar.getValue(0) = "+stAvBar.getValue(0));
            return 
          AvBar;
              
          //trace ("25: This is efs2 variable call , now it is what you want ==>> stAvBar.getValue(0) = "+stAvBar.getValue(0));
            //return stAvBar.getValue(0);
          }

          function 
          AvBarF_s1(ref) {
              
          //if (getBarState() != BARSTATE_NEWBAR)return AvBar;
            
          if (ref==nullref=-1;trace ("30: ref = "+ref);
            var 
          BarCnt  getCurrentBarCount(); trace ("31: BarCnt = "+BarCnt);
            var 
          AvIdx = (BarCnt<=300) ? BarCnt 300trace ("32: AvIdx = "+AvIdx);
            
          AvBar = (AvBar>0) ? (AvBar*(AvIdx-1) + (high(ref)-low(ref)))/AvIdx high(ref)-low(ref);
              
          trace ("34: AvBar = "+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 "MButaS1.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  ################ 
          now I will comment out a couple lines and uncomment out some others. I will leave the enterpretation of this to you tonight, as I am getting ready for bed. Again, I believe this will answer some of your questions.
          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_s1a");
              
          debugClear();
            }
            if (
          nBarState == BARSTATE_NEWBAR) { 
              
          AvBar     AvBarF_s1a(-1);
                  
          trace ("20: getCurrentBarCount() = "+getCurrentBarCount());
            }
              
          trace ("22: This is still the function return ==>> AvBar = "+AvBar);
              
          //trace ("23: This is efs2 variable call still not what you want, however exactly what the efs2 instance is calculating ==>> stAvBar.getValue(0) = "+stAvBar.getValue(0));
            //return AvBar;
              
          trace ("25: This is efs2 variable call  ==>> stAvBar.getValue(0) = "+stAvBar.getValue(0));
            return 
          stAvBar.getValue(0);
          }

          function 
          AvBarF_s1a(ref) {
              if (
          getBarState() != BARSTATE_NEWBAR)return AvBar;
            if (
          ref==nullref=-1;trace ("30: ref = "+ref);
            var 
          BarCnt  getCurrentBarCount(); trace ("31: BarCnt = "+BarCnt);
            var 
          AvIdx = (BarCnt<=300) ? BarCnt 300trace ("32: AvIdx = "+AvIdx);
            
          AvBar = (AvBar>0) ? (AvBar*(AvIdx-1) + (high(ref)-low(ref)))/AvIdx high(ref)-low(ref);
              
          trace ("34: AvBar = "+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 "MButaS1a.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(2020, (" 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  ################ 
          Please note that I modified the trace function to change location of the button and to not save so much data as well. Also, we are at the point of transitioning to using different intervals.

          We will be using information from several of the posts in related threads, in addition to using the commands Alex discussed in his last post.

          Comment


          • #20
            Alex,

            getBarStateInterval("interval")
            Where is this function explained?
            Does it return the same indications (NEWBAR, etc.) like the regular function? If yes, is great.


            Moreover, we may also be able to access the external time interval indicators based on chart bars
            I am refering to the value of a series some [chart] bars back.
            For example for ExtCCI = cci(xx, inv(yy)), to retrieve its value 3 or 7 chart bars back, which may or may not coincide with external time boundaries.

            Thank you,
            Mihai
            Mihai Buta

            Comment


            • #21
              Hi Steve,

              I ran the two files and it is obvious why the second one give correct results, AvBar function was modified to return MY global var if not NEWBAR.

              And this might a solution for other cases when I want to use a Wells Sum like calculation [which, by the way, I do it only to avoid a time consuming sma(300, xyz), because that is what AvBar is, in fact]. As I mentioned, I circumvented this particular problem.

              On the other hand, this leaves wide open the question: "Why does EFS2 engine return such a diferent result than a direct call to the same function?". And how can this be prevented for builtin functions?

              But I guess you are leading in that direction and I wait for the next step.
              Note: If you need "seed" efs with multiple time intervals, I have plenty.

              Thank you,
              Mihai
              Mihai Buta

              Comment


              • #22
                Hi Mihai,

                Regarding your seed efs's, we may go there, however, I was thinking we could continue with this one, adapting it to a different interval.

                As to why the second efs gave the correct results, your conclusion was a bit off and it is essential that we clarify what was really happening.

                In the second example, the reason that the correct result was returned using the stAvBar.getValue(0); is two fold.

                1st, this is the return from the efs2 instance of your function.

                2nd, the reason that it was the number you expected was that we had changed the way the efs2 instance of your function was calculated. This is critical that you understand this aspect, as in my opinion, this is at the center of why you are having issues with efs2.

                Let me explain #2 - Remember that when you declare your function as being an efs2 instance:
                stAvBar = efsInternal("AvBarF_s1a");

                The efs2 engine takes this function, and creates a new object. This new object can be referred to as an instance of your function. To expound on this a bit, you could have one function associated with your efs, yet have 3 efsInternal declarations, each one referencing that same function at a different interval.

                In each case, each one would be a seperate instance of the function (object), with all of the variables being seperately handled by the efs2 engine. The variables may have the same name as a global variable you had declared, however, they are all handled as individual instances of that variable, making them completely independant from each other.

                Now, the efs2 engine will process each instance you have declared every tick. In the case of the first example below, this is why the efs2 instance of your function was returning a number different than you were expecting. Specifically, it was calculating the number every tick. You specifically wanted the calculation to be performed every bar, however, since you handed control over to the efs2 engine, it processed it every tick. You have only a limited ability to control how the efs2 engine processes this instance you have created.

                In the second example, I went ahead and placed a control on the efs2 instance. In this case, I knew that the instance would be called every tick by the efs2 engine. We have no control over that. However, what I did was to put a line in the beginning of the function (which became the efs2 instance) as follows:if (getBarState() != BARSTATE_NEWBAR)return AvBar;

                This line controls how the calculation is performed within the efs2 instance and prevents it from occuring more than once per bar. When there is a newbar, it allows the calculation to be performed. However, when it is not a newbar, it returns the previously calculated value. Just as important, the value it returns is a global value that belongs to the efs2 instance of the function. It is not the global variable that you declared and are using in your efs.

                Comment


                • #23
                  Hi Steve,

                  I understand what you did and it is a good trick to gain some control of the execution for series declared with efsInternal.

                  I suggest to move to a simple builtin study and see what can be done to get the correct results intra-bar and in external time interval.

                  We can take any study, I prefer cci [this gives most trouble] and run it is 2x and 4x time interval.

                  Note: I did run my base efs in tick replay and the results where not consistent with real time.

                  The way I do it is as follows:
                  a/ use getVaslue(0) for historic data, then use getSeries for real time.
                  b/ I declared CCIM0, CCIM1 and CCIM2 [for the three time intervals] as global varibles and I update them on NEWBAR and couple of times per minute.
                  c/ I construct a ReturnArray [also global variable] every time I update the variables, which what I plot [updated one @ "TimeToUpdate" or the stored one in between].

                  Note: As I said, if you want, I can provide template.

                  We can come back to efsInternal, if there are more issues to clarify. You've been very patient with an old man and I thank you for that.

                  Thank you.
                  Mihai
                  Mihai Buta

                  Comment


                  • #24
                    Hi Mihai,

                    We can move onto your CCI example, however, prior to your last post I had already completed this efs, so please bear with me so we can close the loop on this efsInternal example we have been working with. I'll make this my last post on this family of efs examples if you can give me some assurance that you understand the concepts I have been trying to convey. But first, here is the final generation of your efs, modified to create three seperate instances of your function, with all three instances on different timeframes.
                    PHP Code:
                    var stAvBar150;
                    var 
                    stAvBar250;
                    var 
                    stAvBar350;
                    var 
                    AvBar 0;

                    function 
                    preMain() {
                        
                    setPriceStudy(false);
                        
                    setCursorLabelName("150T"0);
                        
                    setCursorLabelName("250T"1);
                        
                    setCursorLabelName("350T"2);
                        
                    setDefaultBarFgColor(Color.cyan0);
                        
                    setDefaultBarFgColor(Color.red1);
                        
                    setDefaultBarFgColor(Color.blue2);
                        
                    setDefaultBarThickness(40);
                        
                    setDefaultBarThickness(31);
                        
                    setDefaultBarThickness(22);
                    }

                    function 
                    main() {
                      
                    nBarState   getBarState();
                        if(
                    nBarState == BARSTATE_ALLBARS) {  
                        
                    stAvBar150     efsInternal("AvBarF_s1b",-1,inv("150T"));
                        
                    stAvBar250     efsInternal("AvBarF_s1b",-1,inv("250T"));
                        
                    stAvBar350     efsInternal("AvBarF_s1b",-1,inv("350T"));
                        
                    debugClear();
                      }
                      if (
                    nBarState == BARSTATE_NEWBAR) { 
                            
                    trace ("28: main ==> getCurrentBarCount() = "+getCurrentBarCount());trace ("");
                      }
                      return new Array( 
                    stAvBar150.getValue(0), stAvBar250.getValue(0), stAvBar350.getValue(0));
                    }

                    function 
                    AvBarF_s1b(ref) {
                        if (
                    getBarState() != BARSTATE_NEWBAR)return AvBar;
                      if(
                    ref==nullref=-1;
                        
                    trace ("36: ref = "+ref);
                      var 
                    BarCnt  getCurrentBarCount(); trace ("37: BarCnt = "+BarCnt" interval = "+getInterval());
                      var 
                    AvIdx = (BarCnt<=300) ? BarCnt 300trace ("38: AvIdx = "+AvIdx);
                      
                    AvBar = (AvBar>0) ? (AvBar*(AvIdx-1) + (high(ref)-low(ref)))/AvIdx high(ref)-low(ref);
                        
                    trace ("40: AvBar("+getInterval()+") = "+AvBar);trace ("");
                      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 "MButaS1b 3timeframes.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  ################ 
                    What I would like some feedback on is:

                    1 - Are you seeing the trace button yet?
                    2 - Do you see how using output from your efs similar to the manner in which I have really helps figure out most problems?
                    3 - Does the output of this function clear up this concept I tried to get across in my previous post (which is why I created this efs btw)?
                    Let me explain #2 - Remember that when you declare your function as being an efs2 instance:
                    stAvBar = efsInternal("AvBarF_s1a");

                    The efs2 engine takes this function, and creates a new object. This new object can be referred to as an instance of your function. To expound on this a bit, you could have one function associated with your efs, yet have 3 efsInternal declarations, each one referencing that same function at a different interval.

                    In each case, each one would be a seperate instance of the function (object), with all of the variables being seperately handled by the efs2 engine. The variables may have the same name as a global variable you had declared, however, they are all handled as individual instances of that variable, making them completely independant from each other.
                    4 - Do you notice based on the output of the efs that the commands getBarState(),getCurrentBarCount() and getInterval() all work correctly in the timeframe context in which the efs2 instance is created. I assume if you were to use getSymbol() in this manner, it would work as well. Does this make sense??

                    5 - Do you understand that your function in this example, was particularily susceptable to returning unexpected results when used as an efs2 object because of
                    a) how you used the output of the calculation as an input for the next calculation (positive feedback) and
                    b) because the efs2 engine (out of necessity) processes these instances every tick?

                    Comment


                    • #25
                      Hi Steve,

                      Before I respond to your questions, please note that I modified your efs to work in regular timeframes and I trace the time [to avoid confusion during pre/post market ticks].

                      Now to your questions:

                      1. No, I do not see the button, I still use the Formula Output Window, but it's ok.

                      4. Yes, I do see how those functions operates within the external time interval. This is something new to me, if it is explained anywhere, I missed it.

                      2 & 3 & 5. No, this exercise did not clear up "most" of the issues, only some of them, and I can't wait to use some builtin studies to clarify them.

                      Re: My using a global var in efsInternal function: As I already said, I did not know that EFS2 engine does not use my global vars, now I know.

                      Hint: Using the modified efs [see attached], I could see that the efsInternal call in base interval is executed BEFORE main, whereas the calls to external time intervals are executed AFTER the main, and this might provide the clue.

                      One more thing: If it is ok with you, let's point on the diferences between EFS1 and EFS2. EFS2 was supposed to be easy to use, I hope this will become obvious, soon.

                      Thank you and best regards,
                      Mihai
                      Attached Files
                      Last edited by mbuta; 07-23-2005, 10:19 AM.
                      Mihai Buta

                      Comment


                      • #26
                        Hi Mihai,

                        efs2 is very easy, I am off to lunch, back in a bit.

                        Comment


                        • #27
                          Hi Steve,

                          You must be on the East Coast, I just had breakfast.

                          Here is a efs with cci(20) in three time intervals.

                          Mihai
                          Attached Files
                          Last edited by mbuta; 07-23-2005, 12:04 PM.
                          Mihai Buta

                          Comment


                          • #28
                            Hi Mihai,

                            I am very curious to why you have not been able to see the button for my trace utility especially since the last efs I posted should have corrected any problems with it. First, I figured the output would have helped you understand what was happening much better than it did (hey, its not upside down!). Secondly, I was in the process of publishing this utility in one of my libraries for this forum. Since this has been a pet project of mine for the last couple of years, and it was reaching fruition, I feel I have to take a break until I can figure this one out (been trying to reproduce most of the day)... it has me baffled (and burnt out).

                            FWIW, I did look at your efs a bit, it seemed to work well once you were able to load a sufficient number of bars for each study.

                            Comment


                            • #29
                              Hi Steve,

                              I made the button shnow. You did not have the BUTTON flag [See attached], but button does not work, because you do not have a routine for clicking on it. Give me 5-10 more minutes.

                              OK. I included the Event Handling Routine, but you need to put there the command to open the file on click [I am not that smart, sorry].

                              Mihai
                              Attached Files
                              Last edited by mbuta; 07-23-2005, 10:05 PM.
                              Mihai Buta

                              Comment


                              • #30
                                Hi Mihai,
                                Hmm, I am not sure if that is it in its entirety as it has been working for some time without it, regardless that is a good catch, thank you. From where I am it seems as if the pixel locations could be to blame as well. Please try and replace the tButton function in my trace function with this one (different pixel locations). Also, if you would try it with and without the Button flag, I would appreciate it as well.

                                function tButton(){
                                drawTextPixel(20, 20, (" click here to see the "+nStudy+" file " + "@URL=C:/Program Files/eSignal/FormulaOutput/"+nStudy),Color.red,null,Text.BUTTON|Text.RELATIVE TOLEFT|Text.RELATIVETOBOTTOM|Text.FRAME, "Comic Sans MS",13,"t11");}

                                Comment

                                Working...
                                X