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!
See more
See less

Partner 728x90

Collapse

BackColor in Strategy

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

    BackColor in Strategy

    I'm having a bit of weird behavior in my strategy regarding backcolors. I have my strategy set to paint the background a certain color if the close in a certain time period is above/below the open in another time period. The painting works fine if my strategy is left with that alone, but the moment I add other indicators from within my strategy the painting of my main time frame disappears. I have some indicators with painting on separate panels that continue to paint fine. Just the main time frame's painting based on the close/open on multi-time frame disappears.

    This part has me confused. If I comment out the initialization of my indicators and run the backtest the main time painting shows up. Immediately afterwards if I uncomment my indicators and click on my instrument name from the left bar everything works perfectly. The moment I refresh the chart or rebacktest the main time frame painting disappears again.

    Any ideas as to why this is happening?
    Josh P.NinjaTrader Customer Service

    #2
    There are some cross dependencies as it goes to back coloring a chart. I suggest either setting the back color by strategy or by indicator but not by both.

    Comment


      #3
      Hmm. I tried removing my indicators that have back coloring properties to see if that would help. No dice. I then stripped the strategy down to the bare-bones and added a simple SMA(5) indicator. When I backtest the first time everything works, but the moment I refresh or rebacktest the painting is gone. The painting stays gone until I repoen Strategy Analyzer or until I do some changes on the strategy code and recompile. Perhaps whats causing this isn't a cross dependency issue?

      I don't have this issue with my non-multitime framed strategies. Maybe it is something to do with the strategy not reevaluating the different time frame's data when I refresh?

      Here's my bare-bones strategy code. I'm pretty sure there are no mistakes in its coding.
      Code:
              protected override void Initialize()
              {
                  
                  Add(PeriodType.Minute, 5);
                  Add(PeriodType.Minute, 60);
                  Add(SMA(5));
                  CalculateOnBarClose = true;
              }
      
              protected override void OnBarUpdate()
              {
                  double Diff1 = Closes[1][0] - Opens[1][0];
                  double Diff2 = Closes[2][0] - Opens[2][0];            
                  if ( Diff1 > 0 && Diff2 > 0)
                  {
                      BackColor = Color.PaleGreen;
                  }
                  else if ( Diff1 < 0 && Diff2 < 0)
                  {
                      BackColor = Color.Pink;
                  }
                  else
                  {
                      BackColor = Color.Gold;
                  }
              }
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Please attach your (simple-as-possible) strategy to your post so I could try here. Thanks.

        Comment


          #5
          Here you go. Thanks for the help Dierk.

          I'm running this on a 1 minute chart and my other two periods are 5 minutes and 60 minutes.

          From what I can tell, if no indicators are called from the strategy via Add() the refreshing/re-backtesting doesn't kill the background colors. I've added some debugging print commands and noticed that hitting F5 to refresh doesn't result in the strategy re-running, but re-backtesting does.

          I also noticed that if you add an indicator after running the backtest, the background disappears when you rerun the strategy.

          Edit: I think I might have spoken too early on the not having issues with non-multi time framed strategies. I just looked back on the coding and the painting was done via indicators so they don't count. I've included an even simpler strategy (BackColorTest.cs) that shows the painting problems from within a strategy. I'm thinking maybe its a bug in the Strategy Analyzer.
          Attached Files
          Last edited by NinjaTrader_JoshP; 05-31-2007, 10:47 AM.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Ok, let's make sure your observations match mine:
            - pull up new SA (important!), backtest TRO no SMA added, F5 -> no problem
            - pull up new SA (important!), backtest TRO with SMA added, F5 -> won't work
            - pull up new SA (important!), backtest BackColorTest no SMA added, F5 -> no problem
            - pull up new SA (important!), backtest BackColorTest with SMA added, F5 -> won't work

            Correct?

            Comment


              #7
              Yup. That is exactly what I'm seeing on my end.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Thanks for confirmation.

                The problem is that internally there really is no strategy running on the chart component on the performance manager (opposed to a stand alone chart). We will remove the refresh NS option (F5) on strategy analyzer with next update.

                Comment


                  #9
                  What about these observations?
                  -new SA, backtest BackColorTest with SMA added -> works
                  -new SA, backtest BackColorTest with SMA added, rebacktest -> problem
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    This is a bug which will be fixed with next update. Thanks for bringing this up.

                    Comment


                      #11
                      Great. Hopefully in the next release we can have the ability to have multi-time framed indicators so I can push these painting routines into an indicator too. Thanks Dierk.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Sorry, no. Multi-time frame indicators won't come with next release. There is no ETA available yet.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Perr0Grande, Today, 08:16 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post Perr0Grande  
                        Started by elderan, Today, 08:03 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post elderan
                        by elderan
                         
                        Started by algospoke, Today, 06:40 PM
                        0 responses
                        10 views
                        0 likes
                        Last Post algospoke  
                        Started by maybeimnotrader, Today, 05:46 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post maybeimnotrader  
                        Started by quantismo, Today, 05:13 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post quantismo  
                        Working...
                        X