Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Code Snipet: Show to show one Dropdown InstrumentList selectable in chart
Collapse
X
-
Hi Sledge,
Thanks again! In the dispose post, NinjaTrader_Joydeep mentioned the SendKeys method, which works when I added the following line of code directly after the code that sets MySMA's MySMAPeriodValue to 100.
System.Windows.Forms.SendKeys.SendWait("{F5}");
Now, when I press the button, the indicator refreshes to have a period of 100! I have uploaded the code in case it helps somebody else.
The problem I have with this is that "SendKeys.SendWait("{F5}");" is not going to work all of the time, for instance if a user has a different hot key function set up for F5.
Sledge, or anybody, is there a more robust (guaranteed to work on various user's machines, irregardless of what F5 is mapped to) way to programmatically refresh an indicator on a chart using "System.Windows.Forms.SendKeys.SendWait("{F5}" );"?
Thanks to sledge and NinjaTrader_Joydeep for the information to get me this far!
Equity TraderAttached Files
Comment
-
Try the attached - it will allow a user selected MA to be "toggled on/off" via Toolbar Button. Does this by changing Plot color to Transparent. Just add multiple instances with different period settings to get what you are after.
This is based on code originally produced by Mindset on BMT.Attached Files
Comment
-
Hi rt-trader,
Thanks a lot for the helpful code sample. I learned about "ChartControl.ChartPanel.Refresh();" from your code, and tried to use it to do two things:
1. Change the color of an indicator, as you mentioned and as your code is intended to do. This worked nicely.
2. Force an indicator to refresh on the chart with the new, programmatically applied public property (which is the period of a simple moving average). Unfortunately, the line "ChartControl.ChartPanel.Refresh();" didn't cause the indicator's data series values to be re-calculated and refreshed on the chart in the way that "System.Windows.Forms.SendKeys.Send("{F5}");" does.
rt-trader, thanks again for the "ChartControl.ChartPanel.Refresh();" tip. This is a nice low-impact way to change indicator plot colors, widths, etc. without the more processor intensive and disruptive (to the UI) "SendKeys.Send("{F5}")".
rt-trader, sledge, or anybody, is there a more robust (guaranteed to work on various user's machines, regardless of what F5 is mapped to) way to programmatically refresh an indicator's data series values (to account for a new, programmatically set SMA Period value for example), not just plot color and width, on a chart, instead of the less robust/reliable "System.Windows.Forms.SendKeys.SendWait("{F5}" );"?
Thanks for all the help!
EquityTrader
Comment
-
Hi Guys,
Great thread. It looks as though there was no solution put forward to refresh the indicator programatically without having you use the sendkey function for F5.
In my case, my button click events work great, the only issue is I have to use the Send Key F5 function (CPU intensive) or wait for the next market tick for the effects of the button click to take place.
Has anyone found a solution?
Thanks in advance for any assistance and I do understand that this falls into the "unsupported" realm but just putting it out there anywayLast edited by marty087; 06-19-2014, 04:29 AM.
Comment
-
Comment
-
Equity Trader, did You tried recaclculate and re-set SMA values on each bar?
Like:
Code:OnButtonClick() { for( int i=CurrentBar; i>=0; i--) Plot_Sma.Set( i, SMA(Period)); }
Comment
-
Hi fx.practic,
Unfortunately, the post I made about this five years ago which you were asking me about was regarding a project that I haven't worked on since not long after that post, and I don't know where I even put the code or if I still have it. I'm sorry that I don't have an answer to your question at this time, but best of luck!
Best regards,
EquityTrader
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by llanqui, Yesterday, 09:59 AM
|
4 responses
22 views
0 likes
|
Last Post
by llanqui
Today, 07:22 AM
|
||
Started by smartromain, 03-13-2024, 01:42 AM
|
5 responses
93 views
0 likes
|
Last Post
by AndreiBig
Today, 06:08 AM
|
||
Started by Noerclou, Today, 04:55 AM
|
0 responses
5 views
0 likes
|
Last Post
by Noerclou
Today, 04:55 AM
|
||
Started by ThoriSten, Today, 03:56 AM
|
0 responses
6 views
0 likes
|
Last Post
by ThoriSten
Today, 03:56 AM
|
||
Started by PhillT, 04-19-2024, 02:16 PM
|
3 responses
26 views
0 likes
|
Last Post
by mangel2000
Today, 03:04 AM
|
Comment