Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Max Down Day

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

    Max Down Day

    I see that you can check the graph in strategy analyzer for Daily Net p&l per instrument but if I have a basket of stocks I can't see the cumulative amount. Is it possible that I can print the combined Net p&l amount for each day for the whole basket to the output window?

    Just as an example say I have 3 instruments that have the following p&l on 1/1/12..

    SPY -500
    QQQ -400
    DIA +200

    Total Combined Loss for day -700. Looking to print "1/1/12 -700" to the output window.

    I tried something like this below but doesn't seem to be working

    Code:
    if (Bars.FirstBarOfSession)
    {
    priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Points.CumProfit;
    }
    //Entry conditions in here..			
    
    {
    EnterLong(200, "");
    Print(Performance.AllTrades.TradesPerformance.Points.CumProfit - priorTradesCumProfit);
    Print(Times[2][0].ToString());
    }
    Last edited by zachj; 06-23-2013, 08:57 PM.

    #2
    Zach, is this a single series strategy applies to multiple instruments then? Those would not share their results / trades, thus the info could not be generated by your code. Only if you would trade all instruments from one script you had access here.

    Comment


      #3
      Is it possible to apply the whole s&p500 to one script? If so how would I go about doing that?

      Comment


        #4
        For realtime trading you could start your strategy on a instrument list like the SP500, if you wanted to have access to the individual trades / performances in backtesting like you outlined earlier you would need to Add the instruments in as needed and then drive your logic on each BarsInProgress.

        Comment


          #5
          Im just doing backtesting. How do i add the instruments into the script, is there an example of this somewhere?

          Comment


            #6
            Sure, just check into the per default installed 'SampleMultiInstrument' strategy for example.

            The full docs on the MultiSeries framework we have in place would be found here -

            Comment


              #7
              My primary is 5min. Can I can I just keep adding instruments in this fashion for a 5min price series...

              Add("MSFT", PeriodType.Minute, 5);
              Add("SPY", PeriodType.Minute, 5);
              Add("QQQ", PeriodType.Minute, 5);
              Add("DIA", PeriodType.Minute, 5);

              Comment


                #8
                Correct, you would need to Add() all symbols in you're interested in.

                Comment


                  #9
                  So then how do you run it in the strategy analyzer for backtesting, what symbol would you choose in the left window? I tried choosing SPY and in my code I had Add("DIA", PeriodType.Minute, 5);
                  but it was as if it was only running SPY per the net profit I received.

                  I think I'm likely not setting up the BIP properly, not quite understanding. I looked at the multi-instrument strategy example but it's not doing the same thing I'm attempting to do here. All its doing is showing how to use a second instruments ADX reading.
                  I want to actually run my entire strategy identically for multiple instruments so I can have one results row show up in the strategy analyzer when backtesting. That way I can see graphs and other data based on a whole basket of stocks.
                  Last edited by zachj; 06-24-2013, 08:00 PM.

                  Comment


                    #10
                    Please try running the attached for example to compare, that's the SampleMA one on 2 instruments, the primary and an added one. Strategy logic for each series is split by a BarsInProgress check, the orders would be submitted then to the instrument called in context - although only the primary would be visualized.
                    Attached Files

                    Comment


                      #11
                      I kind of already had the same thing but it doesn't seem to be working right. Is there anything wrong with the format? I have 3 price series for each instrument.

                      Code:
                      protected override void Initialize()
                              {
                                              //The first Primary series is 5min SPY//
                      			Add(PeriodType.Minute, 1); //series 1 for SPY
                      			Add(PeriodType.Day, 1);  //series 2 for SPY
                      			Add("DIA", PeriodType.Minute, 5);  //series 3 primary for DIA
                      			Add("DIA", PeriodType.Minute, 1);  //series 4 for DIA
                      			Add("DIA", PeriodType.Day, 1);  //series 5 for DIA
                      			Add(SMA(Fast));
                                              Add(SMA(Slow));
                      				
                                  CalculateOnBarClose = false;
                              }
                      
                       protected override void OnBarUpdate()
                      {
                      if ((BarsInProgress == 1) //OnBarUpdate called for 1min bars
                      && (SMA(BarsArray[0],Fast)[1] > SMA(BarsArray[0],Slow)[1] && SMA(BarsArray[0],Fast)[2] < SMA(BarsArray[0],Slow)[2] && Close[0] > Highs[0][1] + distance))
                      {
                      EnterLong(200, "");
                      }
                      
                      if  ((BarsInProgress == 4) //OnBarUpdate called for 1min bars
                      && (SMA(BarsArray[3],Fast)[1] > SMA(BarsArray[3],Slow)[1] && SMA(BarsArray[3],Fast)[2] < SMA(BarsArray[3],Slow)[2] && Close[3] > Highs[3][1] + distance))
                       {
                       EnterLong(200, "");
                        }
                      Last edited by zachj; 06-25-2013, 05:31 PM.

                      Comment


                        #12
                        Zach, I would name those entries uniquely and then run again with the EntryHandling set to .UniqueEntries - currently you would be limited to have one position open only.

                        Comment


                          #13
                          Do you mean just simply add this line under initialize()?

                          EntryHandling = EntryHandling.UniqueEntries;

                          Comment


                            #14
                            Yes, either via this code addition or setting this property from the UI.

                            In addition name your entries uniquely in the code, this way you can also better distinguish them if you review the reports.

                            Comment


                              #15
                              I have the primary series unlinked to a specific instrument and the added series linked to the DIA instrument. So if I want to backtest SPY and DIA I would choose SPY in the strategy analyzer and then it would automatically also run DIA due to the added series correct?

                              When I run it this way and then I try running a single instrument script and choose both SPY&DIA in the strategy analzyer I get different net profit results. They should be exactly the same I would think?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              572 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              331 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              549 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              550 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X