NexusFi: Find Your Edge


Home Menu

 





Repainting Historical Bar


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one srgtroy with 3 posts (1 thanks)
    2. looks_two Fat Tails with 2 posts (2 thanks)
    3. looks_3 bukkan with 1 posts (1 thanks)
    4. looks_4 Big Mike with 1 posts (1 thanks)
      Best Posters
    1. looks_one Fat Tails with 1 thanks per post
    2. looks_two Big Mike with 1 thanks per post
    3. looks_3 bukkan with 1 thanks per post
    4. looks_4 srgtroy with 0.3 thanks per post
    1. trending_up 2,879 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Repainting Historical Bar

  #1 (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

I'm trying to create a situation where if a bar meets a certain condition it gets painted red, however, if the bar following it fails to meet another condition, the initial bar gets re-painted dark red.

Here is my code:

if (BoolSeries1[0])
{BarColor = Color.Red;
}

if (Historical && BoolSeries1[0] && !BoolSeries2[-1])
{
BarColor = Color.DarkRed;
}


Why is it painting the following bar dark red instead of the initial one?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
45 thanks
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Bigger Wins or Fewer Losses?
24 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,446 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,610


Historical is only true while backtesting or while a chart is being loaded/drawn for the first time after you open it. It is not true once it is fully loaded.

That said, I can't help with how to paint backwards on the price bars - don't have ninja installed anymore - but as for making an indicator repaint all you do is modify the array 1 bar back, like:

myArray[1] = newValue;

Probably similar for price bars. Hopefully someone can help.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271


srgtroy View Post
I'm trying to create a situation where if a bar meets a certain condition it gets painted red, however, if the bar following it fails to meet another condition, the initial bar gets re-painted dark red.

Here is my code:

if (BoolSeries1[0])
{BarColor = Color.Red;
}

if (Historical && BoolSeries1[0] && !BoolSeries2[-1])
{
BarColor = Color.DarkRed;
}


Why is it painting the following bar dark red instead of the initial one?

dont know what exactly u r upto but if -1 represents previous bar then it should be only 1.

Reply With Quote
Thanked by:
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


srgtroy View Post
I'm trying to create a situation where if a bar meets a certain condition it gets painted red, however, if the bar following it fails to meet another condition, the initial bar gets re-painted dark red.

Here is my code:

if (BoolSeries1[0])
{BarColor = Color.Red;
}

if (Historical && BoolSeries1[0] && !BoolSeries2[-1])
{
BarColor = Color.DarkRed;
}


Why is it painting the following bar dark red instead of the initial one?

I did not answer this in the first place because several things are confused. So let me summarize:

-> BarColor will only paint the current bar, you cannot use it to paint back.
-> "Historical" cannot be used this way. "Historical" refers to historical data as stored in the historical data base.If you connect to a data provider, typically NinjaTrader will backfill historical data for the time prior to connection and then collect real-time data. The previous bar, which you wanted to paint, can therefore be a real-time data bar. The use you made of "Historical" does not make any sense.
-> As @ bukkan pointed out, if you want to reference the previous value of a BoolSeries, it would be BoolSeries[1], Boolseries[-1] will likely throw an out of range exception as the value has not been set.

What are you actually trying to achieve?

Reply With Quote
Thanked by:
  #6 (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

I define a Marubozu bar with a certain set of parameters. If the current bar meets those requirements, it gets painted green if it is an up bar or red if it is a down bar. However, the following bar is the confirmation bar. If it doesn't show sufficient follow through as defined by another set of parameters, then the initial Marubozu bar has 'failed' and that bar gets repainted a darker shade to show that status.

"-1" was used on purpose to refer to the next bar (confirmation bar), not the last bar.

The code was supposed to work like this: If this is the current bar, and it meets my definition of Marubozu, paint it red or green. However, if it is not the current bar, but it meets my definition of Marubozu, check the next bar and see if it has been confirmed. If it hasn't been confirmed, paint it the darker shade.

-> BarColor will only paint the current bar, you cannot use it to paint back.

I assume this means I cannot do what I would like to do as described above?

Thanks for your response and patience.

Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


srgtroy View Post
I define a Marubozu bar with a certain set of parameters. If the current bar meets those requirements, it gets painted green if it is an up bar or red if it is a down bar. However, the following bar is the confirmation bar. If it doesn't show sufficient follow through as defined by another set of parameters, then the initial Marubozu bar has 'failed' and that bar gets repainted a darker shade to show that status.

"-1" was used on purpose to refer to the next bar (confirmation bar), not the last bar.

The code was supposed to work like this: If this is the current bar, and it meets my definition of Marubozu, paint it red or green. However, if it is not the current bar, but it meets my definition of Marubozu, check the next bar and see if it has been confirmed. If it hasn't been confirmed, paint it the darker shade.

-> BarColor will only paint the current bar, you cannot use it to paint back.

I assume this means I cannot do what I would like to do as described above?

Thanks for your response and patience.

I just remembered that there is an easy way of doing what you want to do.

Instead of BarColor, you can use BarColorSeries. For example

 
Code
BarColorSeries[1] = Color.Red;
will paint the previous bar red. That should solve your problem. Sorry, should have seen this earlier.

Reply With Quote
Thanked by:
  #8 (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

Wow! Great! Thanks!

Started this thread Reply With Quote




Last Updated on July 16, 2011


© 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