NexusFi: Find Your Edge


Home Menu

 





Performance problem with DrawRectangle


Discussion in NinjaTrader

Updated
    1. trending_up 2,374 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

Performance problem with DrawRectangle

  #1 (permalink)
 decs0057 
Munich, Germany
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Broker: IB, NinjaTrader Brokerage
Trading: ES,NQ,6E
Posts: 71 since Feb 2010
Thanks Given: 15
Thanks Received: 25

I want to draw a zone arround horizontial lines (Pivot's)
and use following code

for (int i = 0; (i < base.Values.Length) && (base.Values[i].Count > 0); i++)
{
double value = base.Values[i][0];
double yH = value + zoneSize * TickSize;
double yL = value - zoneSize * TickSize;
Color colorZone = Plots[i].Pen.Color;
if( colorZone != Color.Transparent )
{
if( zoneShowAll )
{
DrawRectangle(
string.Format( "Zone{0}_{1}", i, CurrentBar ),
false,
Displacement+1,
yH,
Displacement,
yL,
Color.Transparent,
Plots[i].Pen.Color,
zoneOpacity );
}
else
{
DrawRectangle(
string.Format( "Zone{0}", i ),
false,
Displacement+width+1,
yH,
Displacement,
yL,
Color.Transparent,
Plots[i].Pen.Color,
zoneOpacity );
}
}
}
}

Problem is that load of indicator is very slow.

Any idea how to improve load time

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
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
34 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
15 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
My NQ Trading Journal
11 thanks
  #3 (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


If you have lot of draw objects, this has indeed a negative impact on performance and the loading of the chart may take quite a long time. This does not only affect rectangles, but also applies to arrows, diamonds and other draw objects.

What I have done for some of my indicators, is that I entered a user-selectable lookback period, for example 15 days from now. I then check for that lookback period in OnBarUpdate and only plot those rectangle if the barTime is inside that lookback period.

This speeds up the indicator, as the rectangles are not plotted over the whole lookback period of the chart.

Another way of doing it - maybe more elegant:

-> Check ChartControl for null in OnStartUp (to avoid problems if your indicator is addressed by another indicator or strategy)
-> Determine the last bar painted on your current chart.
-> Plot rectangles only, if they are within a lookback period of 15 something days counted from the last bar painted.

Reply With Quote
Thanked by:




Last Updated on August 5, 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