Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Capture BarTime

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

    Capture BarTime

    I would like to be able to reference a bar which sets up a condition, then use a count from that bar to bracket when to enter a position. As an example, say a bar has a very high volume relative to its volume average. I would like to use that bars high and low values to determine a long or short entry, and make that valid for three bars so if say, price closes above the high of the reference bar and does that within three bars of the reference bar, I would like to enter a long position. Vice versa for the short entry. Is there any kind of variable I can use to establish the time of the bar which I can then use to reference the next bars? I am running this on range bars so bar time wouldn't be as useful as say bar count or something like "bars since reference bar".
    Thanks
    DaveN

    #2
    DaveN, you could work with the CurrentBar count for this - http://www.ninjatrader-support.com/H...urrentBar.html

    Just save the barcount to a variable on your condition occuring and then you work with the difference between this and the most CurrentBar.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Current Bar Count

      Thanks Bertrand, this helps though I need a little more information. In the strategy wizard I am trying to set a user-defined variable to current bar, but I see no indicator in the indicator list that looks like the current bar. I'm assuming I have to do this in regular NinjaScript code, so would something like this work?

      private int refbarcount = CurrentBar[1];

      if CurrentBar < refbarcount + 3

      {do something here
      }

      DaveN

      Comment


        #4
        DaveN, this is correct you would need to work with this in the NinjaScript editor. CurrentBar[1] is an invalid call, as this is an Int value. For example to store the previous bar index to a variable you can use this -

        Code:
        int myBar = CurrentBar - 1;
        For your entry I believe there's a simpler solution, just place your Stop entry order at your price level and CancelOrder() it if it does not fill within your 3 bars - http://www.ninjatrader-support.com/H...ncelOrder.html
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Waxavi, Today, 02:10 AM
        0 responses
        3 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        7 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        4 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Working...
        X