Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting the spread with a strategy: nothing happens

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

    Plotting the spread with a strategy: nothing happens

    I want to chart the spread between two instruments.

    I'm using sampleStrategyPlot and SampleMultiInstrument as reference to build my spread indicator but it stays blank in charts.

    It seems like StrategyPlot(0).Value.Set does nothing...
    Things i do:
    1)I open a chart for ES 06-09 and add StrategyPlot(0) as indicator (i tried also without addind the indicator but nothig happens again).
    2) i start my strategy on ES 06-09, inside my strategy i add ES 09-09.
    Nothing happens!

    Here the code...

    Code:
            protected override void Initialize()
            {
                CalculateOnBarClose = true;
                Add("ES 09-09", PeriodType.Minute, 1);
                Add(StrategyPlot(0));
                StrategyPlot(0).Plots[0].Pen.Color = Color.Blue;
                StrategyPlot(0).PanelUI = 2;
            }
    
    
            protected override void OnBarUpdate()
            {
                if (BarsInProgress != 0)
                    return;
                StrategyPlot(0).Value.Set(Closes[1][0]-Closes[0][0]);
                
                // StrategyPlot(0).Value.Set(1); //NOT WORKING EITHER!
                
            }
    Any idea?
    I even tried the simple StrategyPlot(0).Value.Set(1)
    or i tried to remove barsinprogress check

    But nothing again!
    Last edited by skynetman; 03-06-2009, 07:46 AM.

    #2
    Adding StrategyPlot() onto a chart by itself for sure won't do anything. As far as your strategy goes, you need to print values out to see what they are instead of relying visually. Very likely you are trying to plot something completely outside of the y-axis price range of what is being charted. That is why you don't see anything.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi josh.
      I need and indicator BELOW price not on the same chart...
      In fact i chose PanelUI = 2.
      Isn't that enough?
      Do you see any error in the code?
      Last edited by skynetman; 03-06-2009, 08:28 AM.

      Comment


        #4
        Regardless of which panel you put it in you still need to debug via Print()s and not visually. Always check the Control Center for errors too.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          What could i debug in

          StrategyPlot(0).Value.Set(1);

          It should print a line!

          Comment


            #6
            Print the values.

            Print(StrategyPlot(0)[0].ToString());
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Also, remember your strategy won't even begin unless you have at least 20 bars of data for ALL instruments. Please check your secondary instrument. 09-09 expiry?
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Thx josh i did not know how to do that
                Output windows is ok even with (Closes[1][0]-Closes[0][0])

                It prints correctly the spreads..

                2,2
                2,17
                2,03
                2,18
                2,08000000000001
                2,16

                etc.
                What could it be then?

                Comment


                  #9
                  You need to print the StrategyPlot value after you have set it. Not only the math logic. http://www.ninjatrader-support2.com/...ead.php?t=3418
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    I used your code!

                    The numbers i reported are the result of:

                    StrategyPlot(0).Value.Set((Closes[1][0])-Closes[0][0]);
                    Print(StrategyPlot(0)[0].ToString());

                    I can't understand why i do not see anything...
                    Last edited by skynetman; 03-06-2009, 08:53 AM.

                    Comment


                      #11
                      Please ensure you have enough data points for it to start plotting on all instruments. Again, please check the 09-09 because that looks fishy. Try with a different instrument.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Yes i checked.
                        I also tried with CL 04-09 and CL 05-09
                        Any other idea?
                        Should i add StrategyPlot(0) to chart before running the strategy or after or it does not matter? i tried both...
                        Last edited by skynetman; 03-06-2009, 09:03 AM.

                        Comment


                          #13
                          No, you should not manually add StrategyPlot() at all. Please remove it and try just running the strategy by itself.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            nothing happens....
                            what should i see?

                            Comment


                              #15
                              Please stop using your strategy and just use the reference sample. If that does not plot for you then for sure your strategy won't work.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              647 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              367 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              571 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X