Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Use bid/ask in AddBar() to pass custom values

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

    Use bid/ask in AddBar() to pass custom values

    Hi,

    within AddBar() there is the option to add Bid/Ask values as well.

    I’d like to store in one of those values (e.g. within Ask) a different parameter that is calculated within OnDataPoint.
    More specific: OnDataPoint is calculating a value of bar size that is rounded to tickvalue when plotted. I need to recover the not-rounded value to the strategy, to avoid double calculation on every tick (+ avoid some other issues).This needs to work in backtest as well.

    When doing the following in the BarType
    protected override void OnDataPoint(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isBar, double bid, double ask)
    ask = MyValue;
    AddBar(bars, lastBarClose, lastBarClose, lastBarClose, lastBarClose, lastBarTime, lastBarVolume, bid, ask);
    Print(ask);

    I get the correct value I want in the print, as expected

    Nevertheless, using GetCurrentAsk(0) or Bars.GetAsk(0) from a strategy, I am not able to recover the value (MyValue) that I stored in the “ask” of the BarType.

    How could I achieve this? Or is there a completely different way?

    Thank you in advance
    Martin

    #2
    Hello Martin,

    A barsType script only allows you to form the chart bars based on the data coming from the market. It does not allow for changing the ask bid data coming from the market.

    Unfortunately, you cannot change the ask and bid coming from the market.

    You could push data from a custom external application to the External Data Feed to push the market data.

    Below is a link to a support article on using the API.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    574 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    333 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X