NexusFi: Find Your Edge


Home Menu

 





Understanding MTF bars, bar closure times, etc.


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Jayswiss with 9 posts (0 thanks)
    2. looks_two srgtroy with 8 posts (1 thanks)
    3. looks_3 rleplae with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 4,266 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 18 posts
    2. attach_file 4 attachments




 
Search this Thread

Understanding MTF bars, bar closure times, etc.

  #1 (permalink)
 Jayswiss 
San Francisco, CA / USA
 
Experience: Intermediate
Platform: NinjaTrader, TradingView
Trading: ES, TF, NQ, CL, GC
Posts: 29 since Jun 2016
Thanks Given: 4
Thanks Received: 3

I'm trying to consistently mark an indicator panel with a bar-sized block every time the 30 minute bar closes.

(panel properties: fixed, points, 10,110, -10, linear)

My code looks something like:
 
Code
  protected override void Initialize()
        {
            Overlay = false;
            textFont = new Font("Arial",8);
            Add(PeriodType.Minute, 30);
        }

  protected override void OnBarUpdate()
        {
	      if (CurrentBar < 30)
       		return;

             DrawOnPricePanel = false;

              if (BarsInProgress == 1){
               //drawtext is for debug                
              DrawText(CurrentBar + 3.ToString() + CurrentBar, true, CurrentBar.ToString(), 0, 55, 1, Color.Red, textFont,    StringAlignment.Center, Color.Empty, Color.Empty, 0);
              
		DrawRectangle("tag"+CurrentBar, false, 0, 40, 1, 50, Color.Blue, Color.Blue, 2);
	        }

        //console dump for debug...
        
             if (BarsInProgress == 1){
			Print(Time[1] + "INDEX: " + BarsInProgress + "     BAR# " + CurrentBar);
			}

        }
So the problem is I wind up with seemingly stray rectangles drawn in the wrong place on timeline.
After adding console dump with timestamp + the DrawText to list the CurrentBar # above the squares, it seems like the bar # and times are correct though. Very confusing and unexpected output.

Image 1 (console output):
[img]http://hostthenpost.org/uploads/7022d7fbe119d479e0afe8e3e957dee1.gif[/img]
---
Image 2 (indicator view):
[img]http://hostthenpost.org/uploads/3b4d24c2effbea2cac9d050ab908f5ba.gif[/img]

Any ideas or advice here? Thanks

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Increase in trading performance by 75%
The Elite Circle
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Tao te Trade: way of the WLD
24 thanks
My NQ Trading Journal
14 thanks
GFIs1 1 DAX trade per day journal
11 thanks
HumbleTraders next chapter
10 thanks
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


What is your base data series ?
Do you need the base serie ?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 Jayswiss 
San Francisco, CA / USA
 
Experience: Intermediate
Platform: NinjaTrader, TradingView
Trading: ES, TF, NQ, CL, GC
Posts: 29 since Jun 2016
Thanks Given: 4
Thanks Received: 3


rleplae View Post
What is your base data series ?
Do you need the base serie ?

Base is 1min. Yes, need base.

I will have 1, 3, 5, 15 on same indicator, but I am just trying to understand why it is doing this with a simple 2 time frame for now.

Started this thread Reply With Quote
  #5 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863

what is the instrument ? what is the liquidity ?

if the instrument is very liquid, I think the 30 min will show 50% in between the 1 hour
if there are no ticks, it might be off and explain what you are seeing...

does that answer your question ?

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 Jayswiss 
San Francisco, CA / USA
 
Experience: Intermediate
Platform: NinjaTrader, TradingView
Trading: ES, TF, NQ, CL, GC
Posts: 29 since Jun 2016
Thanks Given: 4
Thanks Received: 3


rleplae View Post
what is the instrument ? what is the liquidity ?

if the instrument is very liquid, I think the 30 min will show 50% in between the 1 hour
if there are no ticks, it might be off and explain what you are seeing...

does that answer your question ?


ES in this case.... that was in the middle of the night, but still it was moving within 30 minute TF

I was thinking it could be a "no ticks" situation. No ticks would mean onbarupdate wouldn't fire then, is that what you mean?

I don't think that's the case here though (but not 100% sure yet).

Is there something better or different available within Ninjatrader to accomplish basically marking the panel consistently with the bars from other timeframes? Instead of onbarupdate, maybe something that fires every X seconds or every minute?

This is a roundabout example of what I am trying to accomplish within Ninjatrader:
https://www.luckscout.com/have-all-timeframes-on-one-single-chart-in-your-metatrader-platform-mt4/

From there I do quite a bit more with it, but that indicator view is the starting point.

Started this thread Reply With Quote
  #7 (permalink)
 
srgtroy's Avatar
 srgtroy 
Los Angeles, California Republic
Legendary  R.I.P. 1965-2023 
 
Experience: None
Platform: Sierra Chart
Broker: CQG
Trading: ES
Posts: 1,928 since Jan 2011
Thanks Given: 1,375
Thanks Received: 3,722

 
Code
Using declarations

namespace NinjaTrader.Indicator
{
    
   
    public class test : Indicator
    {
        protected override void Initialize()
        {
            Overlay		= false;
	    DrawOnPricePanel	= false;
			
	    Add(PeriodType.Minute, 30);
	    BarsRequired = 1;
        }

        
        protected override void OnBarUpdate()
        {
            if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired) return;
			
	    if (BarsInProgress == 1)
	    {
		DrawSquare("a1" + CurrentBars[0], false, 0, 1, Color.Blue);
	    }
          
        }
    }
}

Reply With Quote
  #8 (permalink)
 Jayswiss 
San Francisco, CA / USA
 
Experience: Intermediate
Platform: NinjaTrader, TradingView
Trading: ES, TF, NQ, CL, GC
Posts: 29 since Jun 2016
Thanks Given: 4
Thanks Received: 3


srgtroy View Post
 
Code
Using declarations

namespace NinjaTrader.Indicator
{
    
   
    public class test : Indicator
    {
        protected override void Initialize()
        {
            Overlay		= false;
	    DrawOnPricePanel	= false;
			
	    Add(PeriodType.Minute, 30);
	    BarsRequired = 1;
        }

        
        protected override void OnBarUpdate()
        {
            if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired) return;
			
	    if (BarsInProgress == 1)
	    {
		DrawSquare("a1" + CurrentBars[0], false, 0, 1, Color.Blue);
	    }
          
        }
    }
}



How does this look at 15:30-16:00 EST? This is where I am currently seeing a dupe/stray...

Started this thread Reply With Quote
  #9 (permalink)
 
srgtroy's Avatar
 srgtroy 
Los Angeles, California Republic
Legendary  R.I.P. 1965-2023 
 
Experience: None
Platform: Sierra Chart
Broker: CQG
Trading: ES
Posts: 1,928 since Jan 2011
Thanks Given: 1,375
Thanks Received: 3,722


Jayswiss View Post
How does this look at 15:30-16:00 EST? This is where I am currently seeing a dupe/stray...



This is Pacific Standard Time so 12:30 - 13:00. No strays. Note, however, there is no data between 13:15 and 13:30 so the next square looks closer but its actually correct.

Reply With Quote
  #10 (permalink)
 Jayswiss 
San Francisco, CA / USA
 
Experience: Intermediate
Platform: NinjaTrader, TradingView
Trading: ES, TF, NQ, CL, GC
Posts: 29 since Jun 2016
Thanks Given: 4
Thanks Received: 3



srgtroy View Post


This is Pacific Standard Time so 12:30 - 13:00. No strays. Note, however, there is no data between 13:15 and 13:30 so the next square looks closer but its actually correct.


Ah I see. I am actually running a drawing rectangles with start 0 end 30 in(to draw a 30 minute long rectangle). But in the case mentioned above, it winds up overlapping in some of those spots where the is no data.. Using your code and start 0 end 1 bars, it seems to draw them correctly now. I just need to figure out how to draw until the next bar instead of fixed 30 mins.

Started this thread Reply With Quote




Last Updated on July 8, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts