//For toggle
private void hideshow(object s, EventArgs e)
{
if ( show == false )
{
DrawText("wtf", ...);
show = true;
button.ForeColor = Color.Silver;
}
else
{
RemoveDrawObject("wtf");
show = false;
button.ForeColor = Color.Blue;
}
ChartControl.ChartPanel.Refresh();
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Button on toolbar
Collapse
X
-
Originally posted by GeorgeW View PostCode:
-
Thanks Koganam, that's worked fine for the final BarsAgo DrawText. But the DrawText is also applied to earlier bars, and those are not being toggled on and off.
The original code was:
The code inserted to toggle it on and off, but only toggles off the one at BarsAgo[0] is:Code:DrawText (TagdiffVol1 + CurrentBar, "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), 0, High[0] + 6 * TickSize, Color.Black);
I have tried a for loop for the other bars, but it is not working:Code:DrawText ("wtf", "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), 0, High[0] + 6 * TickSize, Color.Black);
I have also tried inserting the original DrawText arguments without the "+CurrentBar" after the tag, before the new DrawText code, but that has not worked.Code:if ( show == false ) { for (int x = CurrentBar; x > CurrentBar - 256; x--) { DrawText ("wtf", "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), x, High[0] + 6 * TickSize, Color.Black); } show = true; button.ForeColor = Color.Silver; }
Comment
-
Sorry, but I only answered the question that you asked, about how to modify a particular block of code for drawing instead of plotting.Originally posted by GeorgeW View PostThanks Koganam, that's worked fine for the final BarsAgo DrawText. But the DrawText is also applied to earlier bars, and those are not being toggled on and off.
The original code was:
The code inserted to toggle it on and off, but only toggles off the one at BarsAgo[0] is:Code:DrawText (TagdiffVol1 + CurrentBar, "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), 0, High[0] + 6 * TickSize, Color.Black);
I have tried a for loop for the other bars, but it is not working:Code:DrawText ("wtf", "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), 0, High[0] + 6 * TickSize, Color.Black);
I have also tried inserting the original DrawText arguments without the "+CurrentBar" after the tag, before the new DrawText code, but that has not worked.Code:if ( show == false ) { for (int x = CurrentBar; x > CurrentBar - 256; x--) { DrawText ("wtf", "A"+"\n"+diffVol+"\n"+wTSum+"\n"+a1+"\n"+aPB+"\n"+a3.ToString(), x, High[0] + 6 * TickSize, Color.Black); } show = true; button.ForeColor = Color.Silver; }
I am unaware of your larger purpose, and this post does not explain it. It is a piecemeal, made of code snippets without telling us what the intended effect is supposed to be. If you want to remove all draw objects, the command is RemoveDrawObjects(), or else iterate though all IText objects into a collection, and use their tags to delete them in a second pass. If you want to make them invisible, you will have to iterate through them and turn them transparent.
It is easier to help if the requirements are more clearly stated.
Comment
-
Ok, sorry about the lack of explanation.
Basically I have an indicator which draws some calculations to several bars on the chart. I want to make them all transparent at certain times by using the toggle on off button, whilst leaving any other indicators drawn to the chart unaffected. Currently the code switches on and off the last calculation on the chart, and then as I toggle on and off with Market Replay running, it keeps moving that calculation to later bars on the chart.
Comment
-
That would require you to iterate through all DrawObjects, find the relevant IText objects and change their color to transparent. You would run that code instead of the RemoveDrawObject() code. To turn the text back on, you would do the opposite, iterating through and turning the colors back on, and adding any other IText objects as they come due.Originally posted by GeorgeW View PostOk, sorry about the lack of explanation.
Basically I have an indicator which draws some calculations to several bars on the chart. I want to make them all transparent at certain times by using the toggle on off button, whilst leaving any other indicators drawn to the chart unaffected. Currently the code switches on and off the last calculation on the chart, and then as I toggle on and off with Market Replay running, it keeps moving that calculation to later bars on the chart.
Comment
-
Yes. If I understand it correctly, I think example #3 here https://ninjatrader.com/support/help...ub=Drawobjects and reply #6 to the thread here http://ninjatrader.com/support/forum...ad.php?t=48502 are what I need. I just have to work out how to link it to the button.
Comment
-
Yes, those about cover it.Originally posted by GeorgeW View PostYes. If I understand it correctly, I think example #3 here https://ninjatrader.com/support/help...ub=Drawobjects and reply #6 to the thread here http://ninjatrader.com/support/forum...ad.php?t=48502 are what I need. I just have to work out how to link it to the button.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
656 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
371 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
579 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment