Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to run backtest...

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

    #16
    Please enter the margin for the symbol in currency, not percentage wise.

    Comment


      #17
      Originally posted by NinjaTrader_Bertrand View Post
      Please enter the margin for the symbol in currency, not percentage wise.
      but for a future contract, it's margin depends on percentage of it's spot price, not a fixed value......so how to handle this case?

      Comment


        #18
        Correct this is adapted from time to time by the exchange to reflect the underlying price changes - for the backtest, you can enter the initial margin needed for your instrument.

        Comment


          #19
          Originally posted by NinjaTrader_Bertrand View Post
          Correct this is adapted from time to time by the exchange to reflect the underlying price changes - for the backtest, you can enter the initial margin needed for your instrument.
          Please see the attached jpg. 2000 in "sim feed start price", 1600 in "margin value", so it is 80% of contract value, is it correct?
          Attached Files

          Comment


            #20
            SimFeedStartingPrice and Margin are not related, the first is for setting the price starting point when you start using the internally generated simulation feed for this symbol then. I would suggest you check the overnight margin for the MHI and enter this.

            Comment


              #21
              Originally posted by NinjaTrader_Bertrand View Post
              SimFeedStartingPrice and Margin are not related, the first is for setting the price starting point when you start using the internally generated simulation feed for this symbol then. I would suggest you check the overnight margin for the MHI and enter this.
              The overnite margin is 80%....which I can'y input to the system......

              Comment


                #22
                Overnight initial would be 17340 and overnight maintenance 13872 (= 80%) for the MHI. Intraday would be normally half those values depending on your broker.

                Comment


                  #23
                  Originally posted by NinjaTrader_Bertrand View Post
                  Overnight initial would be 17340 and overnight maintenance 13872 (= 80%) for the MHI. Intraday would be normally half those values depending on your broker.
                  1. Do i have to input 17340 or it will get from my historical data?

                  2. Do the system keep this margin ratio throughout the whole backtesting process? Even the contract priced at 3000 but not 17340?

                  Comment


                    #24
                    1. You will have to input the currency value you wish to use as margin.

                    2. The margin set is used for this instrument and not changed dynamically.

                    Comment


                      #25
                      Originally posted by NinjaTrader_Bertrand View Post
                      1. You will have to input the currency value you wish to use as margin.

                      2. The margin set is used for this instrument and not changed dynamically.
                      My question maybe trivial but I have to know the underlying mechanism inside out so that I can produce an accurate result....

                      Say the day end price of the last day of my historical record is 17340, then I input 13872 as Margin value, so the system knows the margin ratio is 80%.

                      But I gonna do backtest starts from 20 years b4. At that moment, the contract only worth for 3000 dollars instead of 17340, so is the 80% margin still works? which is 2400 at 20 yrs b4, and the system will calculate it automatically thru the backtesting journey.
                      Last edited by Jeffrey.Ng; 05-14-2009, 08:41 AM.

                      Comment


                        #26
                        No, unfortunately not, since the values I posted are relevant for the current valuation. Maybe you can enter some kind of average margin based on historical data?

                        Comment


                          #27
                          Originally posted by NinjaTrader_Bertrand View Post
                          No, unfortunately not, since the values I posted are relevant for the current valuation. Maybe you can enter some kind of average margin based on historical data?
                          ok......then it comes to my second question. Actually I can use a stop loss order to control it. I tried but it doesn't work. The ninja script as follows:

                          I ran the backtest and observe the chart, the strategy didn't cut loss at 2%.....

                          #region Using declarations
                          using System;
                          using System.ComponentModel;
                          using System.Diagnostics;
                          using System.Drawing;
                          using System.Drawing.Drawing2D;
                          using System.Xml.Serialization;
                          using NinjaTrader.Cbi;
                          using NinjaTrader.Data;
                          using NinjaTrader.Indicator;
                          using NinjaTrader.Gui.Chart;
                          using NinjaTrader.Strategy;
                          #endregion

                          // This namespace holds all strategies and is required. Do not change it.
                          namespace NinjaTrader.Strategy
                          {
                          /// <summary>
                          /// Trend Following 1
                          /// </summary>
                          [Description("Trend Following 1")]
                          public class TrendFollowing1 : Strategy
                          {
                          #region Variables
                          // Wizard generated variables
                          private int mAPeriod1 = 200; // Default setting for MAPeriod1
                          // User defined variables (add any user defined variables below)
                          #endregion

                          /// <summary>
                          /// This method is used to configure the strategy and is called once before any strategy method is called.
                          /// </summary>
                          protected override void Initialize()
                          {
                          SetStopLoss("SMALongEntry", CalculationMode.Percent, 2, false);
                          SetStopLoss("SMAShortEntry", CalculationMode.Percent, 2, false);

                          CalculateOnBarClose = true;
                          }

                          /// <summary>
                          /// Called on each bar update event (incoming tick)
                          /// </summary>
                          protected override void OnBarUpdate()
                          {
                          // Condition set 1
                          if (Close[0] > SMA(MAPeriod1)[0])
                          {
                          EnterLong(1, "SMALongEntry");
                          ExitShort("SMAShortExit", "SMAShortEntry");
                          }

                          // Condition set 2
                          if (Close[0] < SMA(MAPeriod1)[0])
                          {
                          EnterShort(1, "SMAShortEntry");
                          ExitLong("SMALongExit", "SMALongEntry");
                          }
                          }

                          #region Properties
                          [Description("first moving average")]
                          [Category("Parameters")]
                          public int MAPeriod1
                          {
                          get { return mAPeriod1; }
                          set { mAPeriod1 = Math.Max(1, value); }
                          }
                          #endregion
                          }
                          }

                          Comment


                            #28
                            Please enter 0.02 for a 2 percent stoploss, then it should take you out at this point.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by argusthome, 03-08-2026, 10:06 AM
                            0 responses
                            104 views
                            0 likes
                            Last Post argusthome  
                            Started by NabilKhattabi, 03-06-2026, 11:18 AM
                            0 responses
                            52 views
                            0 likes
                            Last Post NabilKhattabi  
                            Started by Deep42, 03-06-2026, 12:28 AM
                            0 responses
                            34 views
                            0 likes
                            Last Post Deep42
                            by Deep42
                             
                            Started by TheRealMorford, 03-05-2026, 06:15 PM
                            0 responses
                            38 views
                            0 likes
                            Last Post TheRealMorford  
                            Started by Mindset, 02-28-2026, 06:16 AM
                            0 responses
                            74 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Working...
                            X