Using DrawRegion to shade between two data series - NinjaTrader Programming | futures io social day trading
futures io futures trading


Using DrawRegion to shade between two data series
Updated: Views / Replies:3,418 / 6
Created: by FBJS Attachments:2

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Using DrawRegion to shade between two data series

  #1 (permalink)
Elite Member
Toronto
 
Futures Experience: Advanced
Platform: NinjaTrader
 
Posts: 108 since Sep 2009
Thanks: 30 given, 183 received

Using DrawRegion to shade between two data series

Hey there...

I am trying to use DrawRegion to shade the background between data series, but I am noticing a bit of an interesting side effect that I am wondering if someone can help me with.

Let's suppose we take something simple like shading the area between the middle/upper and middle/lower bollinger bands, depending on whether price is above or below the midline:

if (Close[0] > Bollinger(2, 14).Middle[0])
{
DrawRegion("tag1", CurrentBar, 0, Bollinger(2, 14).Upper, Bollinger(2, 14).Middle, Color.Empty, Color.Lime, 2);
}
else
{
DrawRegion("tag2", CurrentBar, 0, Bollinger(2, 14).Lower, Bollinger(2, 14).Middle, Color.Empty, Color.Red, 2);

}

This should shade the upper part of the bollinger band green when price is in the upper half, and red when price is in the lower half.

However, two things occur when I put this code in OnBarUpdate():

1. Upon loading the chart, BOTH regions are colored all the way back to the beginning of the chart.

2. As price starts to move, only one region starts out colored (the correct one, based on whether price is above or below). However, the minute price crosses back into the other region, it is automatically colored all the way back. So for example if price stays above the middle BB line for 5 minutes after I load the chart then the upper portion is green, but as soon as it crosses below it the lower region gets colored red, including the entire portion of time where price stayed above the middle band.

I am not an expert on this, so any help would be appreciated. I'd like to know how to color a region based only on the current location of price, so that when it crosses the middle bollinger band it starts coloring the proper area from that point forward and leaves the past bars alone.

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,215 since Jun 2009
Thanks: 628 given, 6,308 received


somebody else just request the same thing, here you go

Attached Files
Register to download File Type: cs BBand2.cs (13.7 KB, 157 views)
Reply With Quote
The following 2 users say Thank You to cory for this post:
 
  #4 (permalink)
Elite Member
Toronto
 
Futures Experience: Advanced
Platform: NinjaTrader
 
Posts: 108 since Sep 2009
Thanks: 30 given, 183 received

Never mind... I got it to work after some experimentation. The key is to rename the "tag1" to "tag1" + CurrentBar, so it creates a different draw object instead of repainting the last one. I also changed parameters 2 and 3 to be the values 1 and 0, so it only draws one bar back:

DrawRegion("tag1" + CurrentBar, 1, 0, Bollinger(2, 14).Upper, Bollinger(2, 14).Middle, Color.Empty, Color.Lime, 2);

I wish this was better explained...

Reply With Quote
 
  #5 (permalink)
Elite Member
Toronto
 
Futures Experience: Advanced
Platform: NinjaTrader
 
Posts: 108 since Sep 2009
Thanks: 30 given, 183 received


cory View Post
somebody else just request the same thing, here you go

Thanks... apparently I found the answer myself just as you posted it... much appreciated!

Reply With Quote
 
  #6 (permalink)
Market Wizard
Las Vegas, NV
 
Futures Experience: Advanced
Platform: Abacus, Slide Rule, HP-65, Metastock, TOS, NT
Favorite Futures: Futures
 
aligator's Avatar
 
Posts: 3,424 since Aug 2010
Thanks: 1,053 given, 5,822 received
Forum Reputation: Legendary

This is a simple modification to draw region between Default RSI and the 50 line level.

The code will compile but regions are not painted.

Any hints please?

Attached Files
Register to download File Type: cs RSIRegion.cs (8.5 KB, 28 views)
Reply With Quote
 
  #7 (permalink)
Market Wizard
Columbus, OH
 
Futures Experience: None
Platform: NT 8, TOS
Favorite Futures: ES
 
Silvester17's Avatar
 
Posts: 3,332 since Aug 2009
Thanks: 4,579 given, 10,313 received


aligator View Post
This is a simple modification to draw region between Default RSI and the 50 line level.

The code will compile but regions are not painted.

Any hints please?

@aligator,

I'm pretty sure it does paint, but on the price panel above and below the 50 points

try to add "DrawOnPricePanel = false;" in initialize

Reply With Quote
The following user says Thank You to Silvester17 for this post:

Reply



futures io > > > > > Using DrawRegion to shade between two data series

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
CTA - Series 3, Series 7, Series 9, Series 10, Series 56 NASD exams certifications Big Mike Traders Hideout 41 January 15th, 2015 10:27 AM
Multiple data series code help rkepler EasyLanguage Programming 3 August 16th, 2011 10:12 AM
TF Data Series tderrick Emini Index Futures Trading 7 July 31st, 2011 01:30 PM
_ADXVMA_Alerts_v01_5 data series ryohkyo NinjaTrader Programming 5 March 6th, 2010 12:28 AM
What should I have as 'days back' under 'Format Data Series' eone Traders Hideout 5 February 24th, 2010 07:38 AM


All times are GMT -4. The time now is 12:22 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-10 in 0.11 seconds with 20 queries on phoenix via your IP 54.90.207.75