• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Jagged Multi Time Frame Plots

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

    Jagged Multi Time Frame Plots

    NinjaTrader 8 Beta

    Hi,

    I am having trouble plotting multiple SMAs on a 30M chart from within an indicator. My preferred method of doing this would be to add 3 EURUSD Data series to the actual chart and pass all three of then into the indicator as input parameters but it is my understanding that this is not possible.

    Please advise if this is not true.

    So.. My workaround is to use a 30M chart (most detail) and to use the AddDataSeries function to add the additional timeframes in the Indicator

    Code:
    AddDataSeries(BarsPeriodType.Minute, 240); // BarsInProgress = 1
    AddDataSeries(BarsPeriodType.Day, 1); // BarsInProgress = 2
    But what happens is that I end up with really jagged lines on the chart because of the way that multi bars are calculated. (see attached image). Here is my OnBarUpdate function, please advise on how I can get around this and have smooth SMAs within an indicator like in image 2.



    Code:
    protected override void OnBarUpdate()
    {	
    // Ignore bar update events for the supplementary - Bars object added above 
        if (BarsInProgress == 1 || BarsInProgress == 2) {
        	return; 
    	}
    
    	if (CurrentBar > 8) {
    		SMA smaSmall = SMA(Typicals[0], 6);
    		SmallNormal[0] = smaSmall[0];
    	}
    	
    	if (CurrentBar > (24/4) * 8) {
    		SMA smaMedium = SMA(Typicals[1], 6);
    		MediumNormal[0]	= smaMedium[0];
    	}
    	
    	if (CurrentBar > 24 * 8) { 
    		SMA smaLarge = SMA(Typicals[2], 6);
    		LargeNormal[0] = smaLarge[0];
    	}
    }

    Please advise, Thanks
    Attached Files

    #2
    Hello jaetask,

    Thank you for writing in. I am currently investigating this further and will update you as soon as possible. Please note: Our normal operating hours are between 8:30AM EST and 6:00PM EST Monday through Friday.

    Thank you for your continued patience in the meantime.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Hello,

      Thank you for the question.

      I tested the code provided and do see the same outcome. This would be expected in this case as the base series(30 min) has a finer increment than the other series. This would also be a similar outcome in NT7 regarding this usage.

      There would be more closes on the 30 minute series than the other two series so the value for the Daily series for example would maintain its value across multiple bars until the next daily close when the value is updated.

      This also has to do with the Calculate setting you are using and the historical data available. The current settings used I would expect this outcome as the 30 minute series will close multiple times in-between the daily bar.

      Using Tick Replay with OnPriceChange or OnEachTick would yield a different result or a "less blocky" line because there is intrabar data available for all the series in question.

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

      Comment


        #4
        example of higher time frame EMA

        If the timeframe of the indicator (secondary time frame) is higher than that of the price series, the secondary indicator will plot a step function since its only valid data points occur OnFirstTickOfBar of the secondary data series.

        As long as the secondary time frame is tick, volume, or time based (so that its percent complete is known), intermediate values can be continuously interpolated to give a usable continuous plot of the higher time frame indicator.

        See attached showing the 5 period ema of the 5000 Tick E-mini plotted on a 50 second bar series. Note the step function and interpolated plots, which do NOT repaint at any time.

        Please let me know if I can be of further assistance.
        Attached Files

        Comment


          #5
          There are several approaches that you can follow, when you look for a higher timeframe indicator. In fact there are 4 different solutions.

          (1) Add a secondary bar series to the chart and apply the indicator to the secondary bars series. This will typically result in non-equidistant bar spacing, if the first bars are not time-based, such as minute or daily bars.

          (2) Add a secondary bar series to the indicator. In this case the result depends on the coding skills. It is well possible to calculate the indicator values based on nodes (for which actual prices for the secondary bars are available) and interpolate between the nodes. I have attached a chart with with the VisualEMA that displays the result.

          (3) In case that the primary bars and the secondary bars are of the same type - for example tick versus tick bars - and that the period of the secondary bars is an integer multiple of the period of the primary bars, you can calculate composite bars, and display the result as an indicator. The second chart attached shows the result. The indicator does not need to load secondary bars, as the composite bars can be calculated from the primary bars.

          (4) Sometimes it is sufficient to simply adjust the indicator parameters, see chart 3.

          When you compare the different approaches, you will find that they are all pretty close to the original EMA calculated from a secondary bar series added to the chart. In fact solution (2) is similar, but may introduce a small lag depending on the bar types. Both solutions (2) and (3) are repainting the last leg - as does the original in COBC = false. Solution (4) is the most elegant approach, but does not work with all indicators. However, it can be used with the SMA and the EMA.
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by vpzdcv, Today, 02:31 AM
          0 responses
          7 views
          0 likes
          Last Post vpzdcv
          by vpzdcv
           
          Started by YevhenShynkarenko, Today, 01:22 AM
          0 responses
          14 views
          0 likes
          Last Post YevhenShynkarenko  
          Started by ttodua, Today, 12:52 AM
          0 responses
          6 views
          0 likes
          Last Post ttodua
          by ttodua
           
          Started by ttodua, Today, 12:50 AM
          0 responses
          5 views
          0 likes
          Last Post ttodua
          by ttodua
           
          Started by mulshah, Yesterday, 11:12 PM
          0 responses
          7 views
          0 likes
          Last Post mulshah
          by mulshah
           
          Working...
          X