Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Performance on custom market analyzer column

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

    Performance on custom market analyzer column

    First post here, so please be gentle! I am trying to write a generic custom market analyzer column that will translate my indicators into more of a "dashboard" look and feel (since some of the algorithms could be complex, I prefer to write them using custom market analyzer columns, rather than use the Indicator type market analyzer column). Below is the generic code I would like to use, but the performance is terrible. Any thoughts on how to improve the peformance?

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public class RJCCustomMAColumn : MarketAnalyzerColumn
    {
    #region Variables
    private Indicators.RJCSampleIndicator myIndicator;
    #endregion

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"MA Column to work with Custom Indicator";
    Name = "RJCCustomMAColumn";
    Calculate = Calculate.OnBarClose;
    }
    else if (State == State.Configure)
    {
    myIndicator = new Indicators.RJCSampleIndicator();
    }
    }

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    CurrentText = "Bull";

    if (myIndicator.SampleSignal[0] == 1)
    {
    CurrentText = "Bull";
    // set background color of column to green
    }
    else if (myIndicator.SampleSignal[0] == -1)
    {
    CurrentText = "Bear";
    // set background color of column to red
    }
    else
    {
    CurrentText = "Neut";
    // set background color of column to gray
    }
    }
    }
    }


    Also, any thoughts on how to programmatically change the background color of the custom market analyzer column? Reason being that the background color is more than likely going to be based on different information than the text message. For instance, I may want to identify when a signal fires by the text, and use color to identify if in a trend, for example.

    Thank you!

    -- Rick

    #2
    Hello rjc959,

    Welcome to the forums and thank you for your post.

    Using OnBarUpdate() in a custom Market Analyzer Column script adds a requirement for historical data. This means that at least one day of data will be requested to satisfy the data series. Then, the data series has to be calculated for each instrument in the Market Analyzer.

    A large Market Analyzer with indicators added or using Market Analyzer Columns with OnBarUpdate could quickly add data requirement(s) and loading time.

    If possible, the logic from OnBarUpdate should be moved to OnMarketData. However, this is not a solution if indicators that require bars are needed.

    Please keep in mind that using a custom Market Analyzer Column may work well when using few instruments, but the instrument count will quickly add to the loading time of the Market Analyzer.

    See the help guide documentation below for more information.
    OnMarketData - https://ninjatrader.com/support/help...marketdata.htm

    Programmatically changing the background color of a custom Market Analyzer Column is done by using WPF rendering and the OnRender method. Please see the attached example that demonstrates creating a custom Market Analyzer Column and programmatically changing the background color of the Market Analyzer Column when a certain condition becomes true.

    Working with brushes - https://ninjatrader.com/support/help...th_brushes.htm
    OnRender - https://ninjatrader.com/support/help.../onrender2.htm
    PathGeometry - https://ninjatrader.com/support/help...thgeometry.htm

    Please let us know if we may assist further.
    Attached Files
    Last edited by NinjaTrader_ChelseaB; 08-17-2021, 09:57 AM.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi Brandon - Thank you for responding and giving me these insights. Was wondering if you have any sequence diagrams that would explain how the call sequence flows when a custom market analyzer column includes a custom indicator, and in particular, the sequence of calls to OnMarketData, OnBarUpdate, and the other places where calculations ae performed. Having this would provide extremely valuable information regarding where to place what logic. Also, is there a way to share Series<T> data from custom indicators with market analyzer columns so that I can have the indicator managing the value of the indicator, and only use Market Analyzer to interpret a combination of values. Then, if there is a way to throttle the calculation in Market Analyzer columns (for instance, if I am only using 1 minute charts, perhaps there is a way to throttle the OnMarketData call in the Market Analyzer calculation to escape fast if already calculated for the time period)? Any thoughts on this approach? I used to know how to do all of these types of tricks in C, but really stopped programming when Java became popular (and yes, I have a few years on me). C# is brand new (also learning python as well). And thank you for the code sample and links!

      All the best.

      -- Rick

      Comment


        #4
        Hello rjc959,

        Thank you for that information.

        No, there are not any sequence diagrams that explain a call sequence flow for when a custom Market Analyzer Column includes a custom indicator. OnMarketData and OnBarUpdate are based on events and are not sequential. For example, when the Ask changes without a tick being produced OnMarketData will run but OnBarUpdate will not.

        There is also not a documented or supported way to share Series<T> data from custom indicators with Market Analyzer Columns so that you can have the indicator managing the value of the indicator, and only use Market Analyzer to interpret a combination of values.

        If you are using 1-minute charts and want the Market Analyzer to calculate using a 1-min interval you would need to set the Data Series property for the Market Analyzer Column to 1-minute (Right-click on Market Analyzer > Columns > Data Series section in Properties).

        Please let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by f.saeidi, Today, 12:14 PM
        4 responses
        11 views
        0 likes
        Last Post f.saeidi  
        Started by Russ Moreland, Today, 12:54 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by philmg, Today, 12:55 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by TradeForge, 04-19-2024, 02:09 AM
        2 responses
        32 views
        0 likes
        Last Post TradeForge  
        Started by aprilfool, 12-03-2022, 03:01 PM
        3 responses
        329 views
        0 likes
        Last Post NinjaTrader_Adrian  
        Working...
        X