Ken
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Backtesting exits at 12am
Collapse
X
-
Backtesting exits at 12am
Am backtesting a multi-time frame strategy. The entries are working according to the code. It closes the position at 5:15pm which is great. However, the exits on close at 12am are strange. I have nothing in the code to tell it to exit at 12am. Sometimes it shows an exit on close at 12am and sometimes it holds the position thru 12am. Any thoughts? I am perplexed.
KenTags: None
-
Cal,
In response to your questions, using the Emini 03-14. Time frames are 5 min and daily. . Testing from 1.1.14 until today. Session template is the use the instument settings( which I assume is the 03-14 contract) and exit on close is set to true.
Ken
Comment
-
Ken,
Can you attach your script so that I can review it and test this on my end?
Additionally can you provide a screenshot of the backtest and the settings you used for your strategy?
To attach items, Reply -> Go Advanced -> Select the paperclip in the top tool barCal H.NinjaTrader Customer Service
Comment
-
Cal,
Here is a copy of my code. I have also attached the settings and the trades that executed in backtesting during 2014. I really appreciate your assistance.
#region Variables
// Wizard generated variables
private int profitTarget = 55; // Default setting for ProfitTarget
private int stopLoss = 21; // Default setting for StopLoss
private bool barDown = true; // Default setting for BarDown
private int rSIlimit = 30; // Default setting for RSIlimit
private int aDXlimit = 50; // Default setting for ADXlimit
private int BarsRequired = 30;
// 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()
{
// Add a 5 minute Bars object to the strategy
Add(PeriodType.Minute, 5);
// Add a 15 minute Bars object to the strategy
Add(PeriodType.Day, 1);
Add (AaMACD(7, 25, 30));
Add (ADX(8));
Add (RSI(8,3));
SetProfitTarget("AaMacdShort", CalculationMode.Ticks, ProfitTarget);
SetStopLoss("AaMacdShort", CalculationMode.Ticks, StopLoss, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (BarsInProgress == 0)
{
if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
return;
if (AaMACD(BarsArray[2],7, 25, 30).FastMacdRising.ContainsValue(0))
//|| AaMACD(BarsArray[2],7, 25, 30).FastMacdFalling.ContainsValue(0))
return;
if (AaMACD(BarsArray[2],7, 25, 30).FastMacdFalling.ContainsValue(0)
//(AaMACD(BarsArray[2],7, 25, 30).FastMacdFalling[0] < AaMACD(BarsArray[2],7, 25, 30).FastMacdFalling[1]
&& (RSI(BarsArray[2],8, 3).Avg[0] > 30)
&& (RSI(BarsArray[1],8, 3).Avg[0] > 30)
&& (CrossBelow(AaMACD(BarsArray[1], 7, 25, 30).FastMacdFalling, 0, 1)))
{
EnterShort(DefaultQuantity, "AaMacdShort");
}
The exits are just the profit targets. I can also send to you the AaMacd code which is an indicator I found on Big Mike's Trading Forum.
Ken
Comment
-
Kenny,
I would like to test this out on my end.
If you could please export the script and attach the .ZIP I will be able to import it and run some backtests.
1. From the Control Center window select the menu File > Utilities > Export NinjaScript to open the "Export NinjaScript" dialog window
2. Select the option "Export selected source files"
3. Enter a user defined file name
4. Select all of the files that you want to export and either double click on them or press the ">" button
5. A list of all files that will be exported
6. Press the "Export" button to export the selected files
7. A NinjaScript Archive File (.zip) file will be created in My Documents\<NinjaTrader Folder>\bin\Custom\ExportNinjaScriptCal H.NinjaTrader Customer Service
Comment
-
Hi Cal,
My father, kennyb59, is having difficulty exporting from his ninjatrader. So I will import it from my end. It includes the indicator needed.
The problem my father is having hasn't been happening on my computer. It wasn't until I compared our back test results that I noticed that his system was closing on some dates as a close on exit at 12 am. Which our close on exit is supposed to be at 5:14pm.
Thanks,
SamAttached Files
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Rapine Heihei, Today, 08:19 PM
|
1 response
8 views
0 likes
|
Last Post Today, 08:30 PM | ||
Started by Rapine Heihei, Today, 08:25 PM
|
0 responses
6 views
0 likes
|
Last Post Today, 08:25 PM | ||
Started by f.saeidi, Today, 08:01 PM
|
1 response
9 views
0 likes
|
Last Post Today, 08:17 PM | ||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Today, 07:51 PM
|
0 responses
8 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
5 responses
98 views
1 like
|
Last Post
by caryc123
Today, 07:47 PM
|
Comment