Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Jon17, Today, 04:33 PM
    0 responses
    1 view
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    4 views
    0 likes
    Last Post Javierw.ok  
    Started by timmbbo, Today, 08:59 AM
    2 responses
    10 views
    0 likes
    Last Post bltdavid  
    Started by alifarahani, Today, 09:40 AM
    6 responses
    41 views
    0 likes
    Last Post alifarahani  
    Started by Waxavi, Today, 02:10 AM
    1 response
    20 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Working...
    X