Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price-Based (not time or tick-based) Candlestick Chart

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

    Price-Based (not time or tick-based) Candlestick Chart

    I'm a beginner with NinjaScript & trading in general. I've been a C# programmer for 15 years. I have a very specific strategy/chart I'm trying to acheive:

    I'm doing a day trading (futures) strategy, and I want a candlestick chart that is based on price change, not time or ticks. I need to process at the tick level, because the strategy calls for it, and I need to be able to get out mid-bar. The x-axis of the chart would NOT be linear, because the bars would be based on price fluctuation not time. Conceptually, I could do this myself if I could 1.) get an event for every tick and 2.) 'Build' the bar myself, by tracking the price changes and starting a new bar when the price changes by N amount.

    But I'm missing something, because everything in NinjaScript seems to be based off setting up the script settings to a particular time (minute, day) or tick count and then responding to the OnBarUpdate(). This seems backwards for me - I want to control when the bar updates/finishes, based on price. So conceptually, i want an OnTick() event and then a way to form my own candlesticks.

    I'm just starting out in all this so i'm probably missing some fundamental concepts, and maybe there's a different way to approach this to get this result. Any suggestions are much appreciated!

    Thanks,
    buzz

    #2
    Hello buzzripper,

    Welcome to the NinjaTrader support forum.

    I believe in this case what you are looking for would be a BarsType.

    NinjaScript scripts and charts work like a large chain and it sounds like you are just trying to accomplish this from the wrong area.

    Your script has no control over how the bars are being built, this is caused by the BarsType. A BarsType takes the raw data points and calculates segments of data or bars. The next step is the ChartStyle such as candlestick which renders the segments of data (bars) onto the chart in some way you want.

    Your strategy can be applied to a bars type to have its OnBarUpdate called in the frequency of that type. The GUI options your script has natively have an option for OnPriceChange but because you noted you want the X axis to account for the price change by creating bars this is something the BarsType would need to control and not the script. Using OnPriceChange will call your scripts OnBarUpdate for each price change, but that does not specifically build OnPriceChange bars.

    For this question, I would suggest looking at the existing bars types in the NinjaScript editor to get an idea of how bars are already being built, this will also outline what would be required to create what you are asking.




    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    77 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X