Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Unable to run backtest...
Collapse
X
-
-
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?Originally posted by NinjaTrader_Bertrand View PostCorrect 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
-
The overnite margin is 80%....which I can'y input to the system......Originally posted by NinjaTrader_Bertrand View PostSimFeedStartingPrice 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
-
1. Do i have to input 17340 or it will get from my historical data?Originally posted by NinjaTrader_Bertrand View PostOvernight initial would be 17340 and overnight maintenance 13872 (= 80%) for the MHI. Intraday would be normally half those values depending on your broker.
2. Do the system keep this margin ratio throughout the whole backtesting process? Even the contract priced at 3000 but not 17340?
Comment
-
My question maybe trivial but I have to know the underlying mechanism inside out so that I can produce an accurate result....Originally posted by NinjaTrader_Bertrand View Post1. 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.
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
-
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:Originally posted by NinjaTrader_Bertrand View PostNo, 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?
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
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
104 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
52 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
34 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
38 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
74 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment