Announcement

Collapse
No announcement yet.

Plotting updates without reload

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

  • Plotting updates without reload

    Please help!

    I thought this efs was updating in realtime but I've come to realize that I must reload to get the current plot correct.

    I've tested "if(getBarState() == BARSTATE_NEWBAR)"
    with no success.

    I'm sure it must be simple, but I can't figure it out.

    Thanks in advance for any help you can offer!
    zeller4
    Attached Files

  • #2
    Dynamic loading on realtime bars

    Originally posted by JasonK
    Our SAR study is dynamic on the real time bar, which I had forgotten.

    Jason or Glen (or whomever can help)

    I've read through this thread and played Glen's playback file with the .efs and a couple others. The attached screenshot shows the playback not being updated to the current bar. I'm also attaching another screenshot after a reload. I've had a problem with the realtime data on some .efs and want to know the couple of key things to look for in these scripts.

    Please help if you can.

    Kirk
    Attached Files

    Comment


    • #3
      reloaded version on the same bar as below

      the attached screenshot shows the same bar as before after reloading each script.

      Not really worried about the playbacks or the strategy codes but want to ensure realtime is running true.

      In realtime, the LinearRegressionReversal.efs sometimes leaves the return at 1 or -1 for many bars in a row only to show the correct appearance after a reload.

      I hope this can be easily resolved.

      Thanks for any assistance you can offer.

      Sincerely,

      Kirk
      Attached Files

      Comment


      • #4
        here's the efs
        Attached Files

        Comment


        • #5
          here's the efs

          PHP Code:
          // // Provided by eSignal (c) 2003 //
          function preMain()
          {
              
          setStudyTitle("LinearRegressionReversal1");
              
          setCursorLabelName("LRR"0);
              
          setDefaultBarFgColor(Color.darkgreen0);
              
          setDefaultBarThickness(20);
              
          addBand(0PS_SOLID1Color.RGB(0,0,128), "TagName");
          }

          askForInput();

              var 
          xInterval = new FunctionParameter("Length"FunctionParameter.NUMBER);
              
          xInterval.setDefault);
              
              var 
          fpA2 = new FunctionParameter("Color"FunctionParameter.COLOR);
              
          fpA2.setDefault(Color.darkgreen);
              
              var 
          fpA3 = new FunctionParameter("iButtonX"FunctionParameter.NUMBER);
              
          fpA3.setDefault(55);
              
              var 
          fpA4 = new FunctionParameter("iButtonY"FunctionParameter.NUMBER);
              
          fpA4.setDefault(15);


          function 
          main(Length,Color,iButtonX,iButtonY ) {

              if(
          getBarState() == BARSTATE_ALLBARS) {
                      
          //drawTextPixel(
                      
          drawTextPixeliButtonXiButtonY "LinearRegressionReversal1 @URL=EFS:editParameters",null,null,/* Color.white, Color.green,*/ 
                      
          Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.BUTTON
                      
          "Comic Sans MS"13"UpExp1"); 
                  }


              if(
          Length == nullLength xInterval//5;
              
          var sum 0;
              var 
          0;
              var 
          mt 0;
              var 
          WT 0;
              var 
          vWT2 getGlobalValue"WT2" );
              if (
          vWT2 == null) {
                  
          setGlobalValue("WT2");
              }
              for(
          Length0i--)
                  
          sum += (- (Length 1) / 3) * close(Length);
              
          WT / (Length * (Length 1)) * sum


              
          if(getBarState() == BARSTATE_NEWBAR) {
              if(
          WT >= vWT2)
              {
                  
          setGlobalValue"WT2"WT );
                  return 
          1;
              }
              else
              {
                  
          setGlobalValue"WT2"WT );
                  return -
          1;
              }
              if (
          WT 0){
              
          //drawTextRelative(0,low()-.8,"LONG",Color.white,Color.lime,Text.ONTOP | Text.VCENTER | 
                //  Text.RIGHT|Text.BOLD | Text.ITALIC,"Arial",8,getValue("rawtime") + "LNG1" );
              //drawTextRelative(0,low()-.3,"é",Color.blue,null,Text.TOP|Text.CENTER|Text.BOLD,"Wingdings",12,getValue("rawtime") + "WAIT");//alt+0233
              
          setBarBgColor(Color.lime);
              }
              }
              
              
              return;
          }
          function 
          editParameters(){
              
          askForInput("LinearRegressionReversal1");
              return;
          // 

          Comment


          • #6
            Hi Kirk,

            Being unfamiliar with this LR code I was having alot difficulty understanding the logic flow so I reorganized it a bit to line up the brackets in a format that I am familiar.

            All I can tell you is I recently spent days reading code mostly Chris, Jason and Alexis's on this topic and with Jason's help answering my post's I think I have a decent understanding.

            When it comes to realtime processing the 0 index bar when setComputeOnClose() is not set to true, is being built, tick by tick in realtime and that is problematic, use -1.

            This is true for any series generated including close(0). I made a small change which I haven't yet tested to increment Length by one to avoid the index to zero and have not certain it will correct the problem.

            PHP Code:
            // // Provided by eSignal (c) 2003 //
            function preMain()
            {
                
            setStudyTitle("LinearRegressionReversal1");
                
            setCursorLabelName("LRR"0);
                
            setDefaultBarFgColor(Color.darkgreen0);
                
            setDefaultBarThickness(20);
                
            addBand(0PS_SOLID1Color.RGB(0,0,128), "TagName");
            }

            askForInput();

                var 
            xInterval = new FunctionParameter("Length"FunctionParameter.NUMBER);
                
            xInterval.setDefault);
                
                var 
            fpA2 = new FunctionParameter("Color"FunctionParameter.COLOR);
                
            fpA2.setDefault(Color.darkgreen);
                
                var 
            fpA3 = new FunctionParameter("iButtonX"FunctionParameter.NUMBER);
                
            fpA3.setDefault(55);
                
                var 
            fpA4 = new FunctionParameter("iButtonY"FunctionParameter.NUMBER);
                
            fpA4.setDefault(15);

            ////******KIRK  **NOTE SEE CHANGE  ON LINE 38  (Length++)AND COMMENTED bracket on lin 75 glen********************//

                
            function main(Length,Color,iButtonX,iButtonY 
                {
                    if(
            getBarState() == BARSTATE_ALLBARS)
                    {
                        
            //drawTextPixel(
                        
            drawTextPixeliButtonXiButtonY "LinearRegressionReversal1 @URL=EFS:editParameters",null,null,/* Color.white, Color.green,*/ 
                        
            Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.ONTOP|Text.BOLD|Text.BUTTON
                       
            "Comic Sans MS"13"UpExp1"); 
                    } 
            // end _ALLBARS 
                  
                    
            if(Length == nullLength xInterval//5;
                    
            Length++; // increment Length by one to avoid using index 0 which is problematic during realtime and tick replay
                    
            var sum 0;
                    var 
            0;
                    var 
            mt 0;
                    var 
            WT 0;
                    var 
            vWT2 getGlobalValue"WT2" );
                    if (
            vWT2 == null
                    {
                       
            setGlobalValue("WT2");
                    }
                    for(
            Length0i--)
                        
            sum += (- (Length 1) / 3) * close(Length);
                      
                    
            WT / (Length * (Length 1)) * sum
                    
                    
            if(getBarState() == BARSTATE_NEWBAR
                    {
                        if(
            WT >= vWT2)
                        {  
                            
            setGlobalValue"WT2"WT );
                             return 
            1;
                        }
                        else
                        {
                            
            setGlobalValue"WT2"WT );
                            return -
            1;
                        }
                            if (
            WT 0)
                            {
                                
            //drawTextRelative(0,low()-.8,"LONG",Color.white,Color.lime,Text.ONTOP | Text.VCENTER | 
                                //  Text.RIGHT|Text.BOLD | Text.ITALIC,"Arial",8,getValue("rawtime") + "LNG1" );
                               //drawTextRelative(0,low()-.3,"é",Color.blue,null,Text.TOP|Text.CENTER|Text.BOLD,"Wingdings",12,getValue("rawtime") + "WAIT");//alt+0233
                              
            setBarBgColor(Color.lime);
                            }
                        }
                        return;
                    } 
            // end barstate newbar
              /// }    *****NOTE THOUGHT WE HAD A MISSING BRACKET????   
                
            function editParameters()
                {
                    
            askForInput("LinearRegressionReversal1");
                   return;
                } 
            // end function editParameters] 


            Hope this helps,

            Glen
            Last edited by demarcog; 08-05-2007, 06:27 PM.
            Glen Demarco
            [email protected]

            Comment


            • #7
              Thanks Glen, I'll check it out...

              I was especially intrigued when JasonK said that he remembered that the SAR has dynamic characteristics for realtime.

              Do you know of any other builtins that work in a dynamic fashion?

              Thanks for your help in the meantime.

              Kirk

              Comment


              • #8
                GlobalValue

                I'm wondering if the getGlobalValue or setGlobalValue need something else to ensure updating in realtime???

                I've done a search and currently reading up on "globals"

                Kirk
                Last edited by zeller4; 08-06-2007, 05:36 AM.

                Comment


                • #9
                  Hello Kirk,

                  Regarding dynamic studies, all built-ins are dynamic. Meaning that they update in real time. I initially was thinking the the SAR didn't flip in real time, but it does.

                  As for the formula code, there is a logic problem that needs to be resolved. The problem is that the condition that returns a 1 or -1 to the chart is only evaluating at BARSTATE_NEWBAR, which occurs at the open of a bar. On subsequent trades that occur during the bar (i.e. intra-bar) your return statement at the end of main() gets executed, which is returning nothing. This causes the initial 1 or -1 that was returned at the opening trade to be removed from the chart. In effect you are returning "null" to the chart, which removes the data point plotted for that bar.

                  There are two ways to resolve this. First, you can change the condition to evaluate on every tick by removing the BARSTATE_NEWBAR condition. Alternatively, you can add a global variable and set it equal to the 1 or -1 when the NEWBAR state occurs and then return that variable from all of your return statements. This will force the study to "remember" what value was plotted at the open and will simply return that value until the condition is evaluated again at the open of the next bar.

                  Add global var, nSignal, outside of main() to store the 1 or -1 value.


                  Assign the 1 or -1 return values to this variable in the conditional blocks and return it from the return statements.
                  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


                  • #10
                    Thanks Jason,

                    That helps immensely,

                    Sincerely,
                    Kirk

                    Comment


                    • #11
                      You're most welcome Kirk.
                      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