NexusFi: Find Your Edge


Home Menu

 





Firing a Custom Paint Event in NinjaTrader


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 Zeos6 
Toronto, Ontario, Canada
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts, TradeStation, E-Signal
Broker: Amp Futures/CQG; TransAct Futures
Trading: Currency Futures, Commodities Futures, Bonds, Stocks, Indices
Posts: 16 since Jan 2011
Thanks Given: 0
Thanks Received: 1

Hi,

I have written a custom event in my indicator code. As part of this event, I need to repaint the various graphic objects drawn on the visible part of the chart, which I do via Refresh(). The repaint needs to be done regardless of whether the chart is connected to data from a provider.

Unfortunately, the chart is not being repainted. I believe the custom event is firing but is being consumed by the form. I can access the window of the chart and attach to its Paint event but this still does not work as there does not seem to be an equivalent to KeyPreview that relates to paint events.

This is unsupported by Ninja, but can someone please point me in the right direction so that I can achieve a chart repaint based on a custom paint event even when disconnected form a data provider? Any suggestions would be greatly appreciated. Thanks.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NYSE Owner ICE Invests in Crypto Exchange OKX at $25 Bil …
Cryptocurrency
Orban at 29pct as Hungary Votes Tomorrow -- McIlroy Surg …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
Iran Peace Expired NO: Ceasefire on Life Support, OPEC a …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 
cory's Avatar
 cory 
virginia
the coin hunter
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,093


Zeos6 View Post
Hi,

I have written a custom event in my indicator code. As part of this event, I need to repaint the various graphic objects drawn on the visible part of the chart, which I do via Refresh(). The repaint needs to be done regardless of whether the chart is connected to data from a provider.

Unfortunately, the chart is not being repainted. I believe the custom event is firing but is being consumed by the form. I can access the window of the chart and attach to its Paint event but this still does not work as there does not seem to be an equivalent to KeyPreview that relates to paint events.

This is unsupported by Ninja, but can someone please point me in the right direction so that I can achieve a chart repaint based on a custom paint event even when disconnected form a data provider? Any suggestions would be greatly appreciated. Thanks.

as long as you know how many bar ago you can repaint it
https://ninjatrader.com/support/helpGuides/nt7/index.html?barcolorseries.htm


Reply With Quote
  #3 (permalink)
 Zeos6 
Toronto, Ontario, Canada
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts, TradeStation, E-Signal
Broker: Amp Futures/CQG; TransAct Futures
Trading: Currency Futures, Commodities Futures, Bonds, Stocks, Indices
Posts: 16 since Jan 2011
Thanks Given: 0
Thanks Received: 1


Thank you for the response but the reply misses the point of my question entirely. Perhaps it is the way I have written it. I simply need a way to fire a custom paint event when there is no incoming data, and the data feed is disconnected.


Started this thread Reply With Quote
  #4 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 649 since Aug 2009
Thanks Given: 320
Thanks Received: 623


Zeos6 View Post
Thank you for the response but the reply misses the point of my question entirely. Perhaps it is the way I have written it. I simply need a way to fire a custom paint event when there is no incoming data, and the data feed is disconnected.

If you do plot override this method is fired every time something is drawn on the chart (eg. new bar, scrolling left or right, zoom in and out, etc.).

Take a look at g3ChartSpan where this is utilised in the simplest way.


Reply With Quote
  #5 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 649 since Aug 2009
Thanks Given: 320
Thanks Received: 623

In some circumstances you may also find the following useful:
 
Code
                this.ChartControl.ChartPanel.Invalidate();
                this.ChartControl.ChartPanel.Update();


Reply With Quote
  #6 (permalink)
 Zeos6 
Toronto, Ontario, Canada
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts, TradeStation, E-Signal
Broker: Amp Futures/CQG; TransAct Futures
Trading: Currency Futures, Commodities Futures, Bonds, Stocks, Indices
Posts: 16 since Jan 2011
Thanks Given: 0
Thanks Received: 1

Thank you. I generally tend to use this.ChartControl.Refresh() to get an immediate redraw.


Started this thread Reply With Quote
  #7 (permalink)
 Zeos6 
Toronto, Ontario, Canada
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts, TradeStation, E-Signal
Broker: Amp Futures/CQG; TransAct Futures
Trading: Currency Futures, Commodities Futures, Bonds, Stocks, Indices
Posts: 16 since Jan 2011
Thanks Given: 0
Thanks Received: 1


gregid View Post
If you do plot override this method is fired every time something is drawn on the chart (eg. new bar, scrolling left or right, zoom in and out, etc.).

Take a look at g3ChartSpan where this is utilised in the simplest way.

Thank you. I had a look at the indicator (very nice), and it seems to have the behaviour I need. I need to fire this paint draw from a custom event, so I will work with this approach and see how it goes. Thank you.


Started this thread Reply With Quote




Last Updated on April 20, 2015


© 2026 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 - Downloads - Top
no new posts