NexusFi: Find Your Edge


Home Menu

 





Question on ChartControl and custom buttons


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 erk707 
Irvine, CA
 
Experience: Intermediate
Platform: Ninjatrader
Trading: Piano, ES, GC, CL, NQ, 6E
Posts: 21 since Feb 2011
Thanks Given: 5
Thanks Received: 4

Hello guys,

I have what’s naturally an unsupported question for ninjatrader but would like to see if I can get some input from you guys. I have a strategy that has a custom button on it and this custom button when clicked adds an indicator to the chart. I was able to achieve this by using the following code in OnStartUp() in the strategy.

Indicatorbase indicatorTemplate = new ADX(13);
indicatorTemplate.Panel = 1;

Then in the event Handler for by button click I do something like this.

ChartControl.Add(indicatorTemplate);

This part works fine and it adds the indicator to the chart in panel 1.

The problem I run into is when I want to remove the indicator from the chart.

If I call

ChartControl.Remove(indicatorTemplate);

Nothing happens. If I click the button again then it adds another copy of ADX(13) to the 1st panel. If I close the chart nothing happens. If I reload Ninjascript it throws this nasty NT7 error saying I broke everything.

It seems it should work. The only thing I can see that is different between Add and Remove is the following

Add give this in intellisense (IndicatorBase indicatorTemplate)
While Remove gives this (IndicatorBase indicator)

Any help would be much appreciated.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Ceasefire Collapse: Iran Fires 24 Missiles, Israel Hits …
Traders Hideout
June 15 Peace Odds Surge From 3.6% to 12.25% After Trump …
Prediction Markets & Event Contracts
Six Days to Kickoff: World Cup Prediction Markets Hit $1 …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks




Last Updated on October 16, 2014


© 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