Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Blinking Chart Background
Collapse
X
-
laocoon,
I would suggest adding your blinking code to the indicators you want to use it as this would be the surest way to get it to work correctly.
Otherwise, here is a reference sample : http://www.ninjatrader.com/support/f...ead.php?t=4991
The main issue here is you will have to have an indicator call another indicator before this may work. There is no way to link the MyCondition across separate indicator instances.
-
AdamP
Thanks a lot for that. Could I ask you to have a look at the following code. It makes the chart background color change every 2 seconds.
public class ChartBlink : Indicator
{
#region Variables
// Wizard generated variables
private int xSeconds = 2; // Default setting for XSeconds
private bool myCondition = false; // Default setting for MyCondition
// User defined variables (add any user defined variables below)
private DateTime conditionTime;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Overlay = true;
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(MyCondition)
{
conditionTime = DateTime.Now;
myCondition = false;
}
if (DateTime.Compare(conditionTime.AddSeconds(600), DateTime.Now) >= 0) //Chart flashing is active for the first 600 seconds after setting MyCondition = true.
{
if (DateTime.Now.Second % xSeconds == 0) //xSeconds controls how often the chart background changes to Gray
{
for (int x = 0; x < CurrentBar; x++)
BackColorAllSeries[x] = Color.Gray;
}
else
{
for (int x = 0; x < CurrentBar; x++)
BackColorAllSeries[x] = Color.White;
}
}
else //Sets back to white after done flashing
for (int x = 0; x < CurrentBar; x++)
BackColorAllSeries[x] = Color.White;
}
What I'm trying to do now is to call the indicator from my strategy to make the chart backgound of the market with a trading signal blink while the signal is valid (ie during the duration of the most recent 10 minute bar). (The strategy also draws a black diamond above the bar that gave the signal).
if (my conditions here)
{
DrawDiamond("BlackDiamondLong" + CurrentBar, false, 0, High[0]+ 3*(TickSize), Color.Black);
MyCondition = true;
}
My question now is: how can I call the ChartBlink indicator from my strategy? I'm not sure how to link the "MyCondition" part of the (strategy) code to the ChartBlink indicator.
Thanks a lot for your help.
Leave a comment:
-
laocoon,
You will need to add a "1 second" dataseries to your indicator in order to get the granularity to keep track of something like this.
Then, you can simply check if BarsInProgress == 1, if so increment a counter until its equal 2, then reset the counter and change color. Once the signal occurs for that minute, you just need to reset the signal flag the next minute.
Please let me know if I may assist further.
Leave a comment:
-
Blinking Chart Background
Hello
I have quite a lot of charts with a custom strategy on my screens and whenever there's a trading signal my strategy will put an arrow on the corresponding chart and generate a sound.
What I'd like to do to save some time is to include a code snippet into my strategy that additionally makes the chart "blink" while there's an active signal on it.
By blinking I mean that the chart background color should change between white and gray in a 2 second interval during the 60 seconds the signal is active (I'm trading on a 1 minute chart and a signal is cancelled if it is not triggered within this 60 second interval). I've already played with the background color using
BackColorAll = Color.White etc
but the tricky part is to make the background color change every 2 seconds, thus creating the blinking effect.
How should I go about this?
ThanksTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by eladlevi, Today, 11:02 AM
|
4 responses
21 views
0 likes
|
Last Post
by eladlevi
Today, 01:47 PM
|
||
Started by synthhokie, Today, 10:24 AM
|
5 responses
14 views
0 likes
|
Last Post Today, 01:37 PM | ||
Started by llanqui, 05-06-2024, 03:51 PM
|
7 responses
30 views
0 likes
|
Last Post
by llanqui
Today, 01:33 PM
|
||
Started by Lele2k24, Today, 01:32 PM
|
0 responses
3 views
0 likes
|
Last Post
by Lele2k24
Today, 01:32 PM
|
||
Started by Richozzy38, Today, 01:06 PM
|
1 response
7 views
0 likes
|
Last Post Today, 01:31 PM |
Leave a comment: