• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Blinking Chart Background

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_AdamP
    replied
    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.

    Leave a comment:


  • laocoon
    replied
    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:


  • NinjaTrader_AdamP
    replied
    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.

    http://www.ninjatrader.com/support/h...nstruments.htm

    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:


  • laocoon
    started a topic Blinking Chart Background

    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?

    Thanks

Latest Posts

Collapse

Topics Statistics Last Post
Started by NickyD, Today, 09:20 AM
0 responses
1 view
0 likes
Last Post NickyD
by NickyD
 
Started by UncleRyan, Yesterday, 08:18 PM
1 response
10 views
0 likes
Last Post NinjaTrader_Kate  
Started by Plaket, Today, 08:58 AM
0 responses
8 views
0 likes
Last Post Plaket
by Plaket
 
Started by trader333, Today, 08:51 AM
1 response
9 views
0 likes
Last Post NinjaTrader_Jesse  
Started by Julien1, Today, 08:32 AM
1 response
8 views
0 likes
Last Post NinjaTrader_DrewO  
Working...
X