Announcement

Collapse
No announcement yet.

Logging proper bar close values!!!

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

  • Logging proper bar close values!!!

    I know I have posted about this before, and I thought I solved this problem, but I am home sick and enjoying the luxury of watching E-Sig, and taking notes.

    Here is my dilemma . . .

    Take two studies I declare in an EFS as:

    var study5 = new MAStudy(5,0,"OHLC/4","Simple");
    var study6 = new MAStudy(10,0,"OHLC/4","Simple");

    When I run my script in a backtested mode, I am fully aware how to get the right values to use and correlate them back to the chart:

    myMA_FAST = study5.getValue(MAStudy.MA);
    myMA_SLOW = study6.getValue(MAStudy.MA);

    The problem is when I am running the EFS in a live manner, while watching the market, I can never seem to feed the EFS the correct closing values for the bar.

    In my EFS, on the first tick of a new bar, I grab the last recalled value from the previous bar, and I assume that it should be the closing value of the previous bar. Thinking that the last tick is truly the last tick, and must be equal to one reading made on the final O/H/L/C. However, this is just not the case.

    Can some tell me how to recall the proper final closing value of a moving average in this case, from the first tick of a new bar, but using the proper O/H/L/C from the previous bar????

    As always, I appreciate the help of all in this forum.

    Thomas

  • #2
    Thomas
    I believe the following would get you the last value (in this example of the MA) at the close of the prior bar.

    if(getBarState()==BARSTATE_NEWBAR){
    study5.getValue(MAStudy.MA,-1);
    }

    The value of the MA in this case will be based on the OHLC of the last bar
    Alex

    Comment


    • #3
      yep, that is the ticket

      I finally have it working the way I want, I saw your other posting on the -1 in the getvalue for the study, and it is the EXACT value, I tested it all out and everything:

      myMA_FAST = study5.getValue(MAStudy.MA, -1);
      myMA_SLOW = study6.getValue(MAStudy.MA, -1);

      I just call this on the very first tick of a new bar, and I am exactly where I need to be.

      Thanks again,

      T

      Comment


      • #4
        yep, that is the ticket

        I finally have it working the way I want, I saw your other posting on the -1 in the getvalue for the study, and it is the EXACT value, I tested it all out and everything:

        myMA_FAST = study5.getValue(MAStudy.MA, -1);
        myMA_SLOW = study6.getValue(MAStudy.MA, -1);

        I just call this on the very first tick of a new bar, and I am exactly where I need to be.

        Thanks again,

        T

        Comment

        Working...
        X