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

Custom Candles

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

    Custom Candles

    Hello,

    I am configuring or creating some candles by ticks, however, a priori I do not know the number of ticks that will be included in a candle, because the grouping of ticks for a candle depends on an indicator that I have created, how can I Do all this that I have commented?
    Thank you,
    Regards,

    Richard Martínez M.

    #2
    Hello Richardmm,

    Thank you for the post.

    I wanted to clarify, when you say you are creating candles, do you currently have some logic you are working on that is not working as expected or is this an idea you are asking to have created for you?

    I would not have any sample of this type of logic, but we could review what you have created at this point if you are stuck somewhere in your logic. If this is an idea you are wanting to create, as noted this is not something I have a sample of but I could provide some educational material to help learn NinjaScript. You could also reach out to third-party developers if needed to have something created for you.

    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello Richardmm,

      Thank you for the post.

      I wanted to clarify, when you say you are creating candles, do you currently have some logic you are working on that is not working as expected or is this an idea you are asking to have created for you?

      I would not have any sample of this type of logic, but we could review what you have created at this point if you are stuck somewhere in your logic. If this is an idea you are wanting to create, as noted this is not something I have a sample of but I could provide some educational material to help learn NinjaScript. You could also reach out to third-party developers if needed to have something created for you.

      Please let me know if I may be of additional assistance.
      Hi Jesse,

      Thank you,

      I have already created the candles in excel according to the conditions and indicators that I added. The difficulty I have is to make these same candles in NinjaTrader. Do you have any idea how to help me ? Please

      Comment


        #4
        Hello,

        Can you tell me, is the data you have created OHLCV data like a normal price bar? If so, you could just create an instrument using the Instrument Manager, and import data for that instrument. The data would need to be exported from excel into the supported formats listed here: https://ninjatrader.com/support/help...AndDataFormats

        Otherwise, if this data is indicator value data or something which would be plotted over bars you would likely need to design an indicator to calculate this.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello,

          Can you tell me, is the data you have created OHLCV data like a normal price bar? If so, you could just create an instrument using the Instrument Manager, and import data for that instrument. The data would need to be exported from excel into the supported formats listed here: https://ninjatrader.com/support/help...AndDataFormats

          Otherwise, if this data is indicator value data or something which would be plotted over bars you would likely need to design an indicator to calculate this.

          I look forward to being of further assistance.
          Code:
           protected override void OnDataPoint(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isBar, double bid, double ask)
          		{
          			if (SessionIterator == null)
          				SessionIterator = new SessionIterator(bars);
          
          			bool isNewSession = SessionIterator.IsNewSession(time, isBar);
          			if (isNewSession)
          				SessionIterator.GetNextSession(time, isBar);
          			if (bars.BarsPeriod.Value == 1)
          				AddBar(bars, open, high, low, close, time, volume, bid, ask);
          			else if (bars.Count == 0)
          				AddBar(bars, open, high, low, close, time, volume);
          			else if (bars.Count > 0 && (!bars.IsResetOnNewTradingDay || !isNewSession) && bars.BarsPeriod.Value > 1 && bars.TickCount < bars.BarsPeriod.Value)
          				UpdateBar(bars, high, low, close, time, volume);
          			else
          				AddBar(bars, open, high, low, close, time, volume); 
          		}
          This is the Ticks Bartype Code. Is there any problem if i Add my logic to create Tick bars depending on several conditions into these code?

          Comment


            #6
            Hello,

            Thank you for the reply.

            yes, there would likely be problems if you plan to use Indicators as a BarsType cannot access indicators specifically. If the logic used in the indicators can be converted to work in a BarsType, you could use a BarsType to calculate your own bars. some math logic may be able to be reused in a BarsType but depending on how the indicator was coded, you may need to recreate that logic in a way that would work with a BarsType which may or may not be possible.

            If you have the pre-calculated data, you could also import it as price data depending on if it fits the format required to import that data.

            You could also use an indicator to paint your own bars over existing bars, there are many ways to accomplish displaying data but it would relate to what is required to calculate that data initially.

            Please let me know if I may be of additional assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thank You,

              I'll try.

              Richard Martínez M.

              Comment


                #8
                Example

                Hi Jesse,

                Could you give an example (code) of an indicator to paint my own bars over existing bars?

                Richard Martínez M.
                Last edited by Richardmm; 01-19-2018, 05:23 PM.

                Comment


                  #9
                  Hello,

                  Thank you for the reply.

                  For this, you could utilize both the existing ChartStyles for examples on how to "render" a bar, but also the indicator SampleCustomRender.

                  NT8 uses SharpDX for rendering which would be needed to render a bar on a chart from an Indicator specifically. The existing ChartStyles already use OnRender so the code to render bars already exists and can be viewed.

                  An existing ChartStyles render code could be repurposed and made to work in an indicator with modifications. This is not really something we have an example/short guide to do but is something you could explore as the full code is available for each ChartStyle.

                  Likely you could use the SampleCustomRender as a starting point to see if this is something you want to dive into, and then review the ChartStyles to check how difficult it would be. The standard CandleStyle style is likely the easiest to review for a candle style bar specifically.




                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Creating BarType

                    Hi,

                    I am creating a BarType but I need to have access to the last candles (i.e., Open, Close, High, Low) For example, I want to access to the last five candles, How can I do it?

                    Richard Martínez.

                    Comment


                      #11
                      Hello,

                      Thank you for the reply.

                      You may be able to utilize bars.GetClose(index) for this purpose, so long as the index being used does not exceed the available indexes in the collection. You could see the Renko bars for an example of the Get method accessing data.


                      I look forward to being of further assistance.
                      Last edited by NinjaTrader_Jesse; 02-05-2018, 09:06 AM.
                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        Hi Jesse & Other Members,

                        Is anyone aware of a vendor who has created an indicator that renders Price Change candles/bars? A Price Change Candle/Bar chart is an interval chart that uses changes in price, instead of time, to display the data. Instead of using a 5-minute chart, you might want a chart that renders 10 price changes per bar. Only a price change counts in this type of bar chart.

                        For example, if there were, in order, 3 trades on CL at 61.28, 2 trades at 61.29, and then 5 trades at 61.28 again, then 3 price changes have occurred. Once the selected number of price changes is reached, the current bar is closed out and a new bar is created.

                        Thanks in advance for any input.
                        Jim

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by TraderBCL, Today, 04:38 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post TraderBCL  
                        Started by martin70, 03-24-2023, 04:58 AM
                        14 responses
                        105 views
                        0 likes
                        Last Post martin70  
                        Started by Radano, 06-10-2021, 01:40 AM
                        19 responses
                        606 views
                        0 likes
                        Last Post Radano
                        by Radano
                         
                        Started by KenneGaray, Today, 03:48 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post KenneGaray  
                        Started by thanajo, 05-04-2021, 02:11 AM
                        4 responses
                        471 views
                        0 likes
                        Last Post tradingnasdaqprueba  
                        Working...
                        X