Announcement

Collapse
No announcement yet.

getBarState not working!!!

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

  • #16
    Garth,

    I appreciate the explanation regarding the subleties between the methods, it was not clear, at least for me. The interval I was running at was 20 sec with the emini.

    Thanks again,

    Steve

    Comment


    • #17
      I will test tonight . . .

      Garth,

      Thanks so much for your efforts, I thought I would have time to test last night, I will try running your code tonight and see what happens. I will keep all posted . . .

      Thomas.

      Comment


      • #18
        Rawtime...

        The "rawtime" example I illustrated works for most applications.

        The trick to this is that it is only true ONCE (on the first tick of the new bar that forms.

        If you are trying to do something else (say test for a condition on a new bar and record it once the condition is true), then you would need to convert the code to what I call a "timestamp" - like the following...

        if ((stoK > 40) && (lastStoK < 40) && (getValue('rawtime",0) != nLastStoTime)) {
        // condition is true and no current action has been taken on this bar
        Execute action (buy/sell/whatever);
        nLastStoTime = getValue('rawtime",0);
        }

        This type of code will wait for a condition to form on a new bar (a bar where the condition has not been acted upon previously), then execute the conditional requirements, then timestamp the bar (so the condition can't be acted upon again - until another new bar forms).

        Hope this helps.

        Brad
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #19
          BarState

          PS. The problem I found with getCurrentBarState() is that it is only true on the FIRST INSTANCE of the new bar. When the second tick comes in, the bar state has changed.

          So, I use getValue("rawtime",0) as an alternate (more diverse) way of handling this.

          Hope this helps..
          Brad Matheny
          eSignal Solution Provider since 2000

          Comment

          Working...
          X