Any help would be greatly appreciated.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Problem with running Replay or my Strategy?
Collapse
X
-
Problem with running Replay or my Strategy?
I created several strategies using the wizard, I have been trying to test them using the Market Replay. While I'm testing it I have the an order quantity that i'm using of 30,000. The strategy will start buying and selling the whole quantity as it is supposed to. Then all of the sudden, it will break up the order. It begins to make orders by splitting the transaction between 29,999 and 1. Then for some reason, when the strategy hits its profit target, it will just keep closing out 1 quantity over and over.
Any help would be greatly appreciated.Tags: None
-
Sorry, I am pretty new to this and I don't follow what you are saying. I tried to use the replay connection with a quantity of three and that didn't help. It still splits up the position.
Here is a copy of the code Im using, if that helps. It was made with the Wizard.
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// SMA -first
/// </summary>
[Description("SMA -first")]
public class SMA33 : Strategy
{
#region Variables
// Wizard generated variables
private int fast = 7; // Default setting for Fast
private int slow = 21; // Default setting for Slow
private int profitTarget = 24; // Default setting for ProfitTarget
private int stopLoss = 13; // Default setting for StopLoss
private int medium = 14; // Default setting for Medium
private int qTY = 30000; // Default setting for QTY
// 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(SMA(Fast));
Add(SMA(Slow));
Add(SMA(Fast));
Add(SMA(Medium));
Add(SMA(Fast));
Add(SMA(Medium));
SetProfitTarget("", CalculationMode.Ticks, ProfitTarget);
SetStopLoss("", CalculationMode.Ticks, StopLoss, true);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(SMA(Fast), SMA(Slow), 1)
&& CrossAbove(SMA(Fast), SMA(Medium), 1))
{
EnterLong(QTY, "");
}
// Condition set 2
if (CrossBelow(SMA(Fast), SMA(Slow), 1)
&& CrossBelow(SMA(Fast), SMA(Medium), 1))
{
EnterShort(QTY, "");
}
}
#region Properties
[Description("fast period moving average")]
[GridCategory("Parameters")]
public int Fast
{
get { return fast; }
set { fast = Math.Max(1, value); }
}
[Description("slow period moving average")]
[GridCategory("Parameters")]
public int Slow
{
get { return slow; }
set { slow = Math.Max(1, value); }
}
[Description("profit target ticks")]
[GridCategory("Parameters")]
public int ProfitTarget
{
get { return profitTarget; }
set { profitTarget = Math.Max(1, value); }
}
[Description("stop loss ticks")]
[GridCategory("Parameters")]
public int StopLoss
{
get { return stopLoss; }
set { stopLoss = Math.Max(1, value); }
}
[Description("Medium Moving average")]
[GridCategory("Parameters")]
public int Medium
{
get { return medium; }
set { medium = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int QTY
{
get { return qTY; }
set { qTY = Math.Max(1, value); }
}
#endregion
}
}
Comment
-
Originally posted by Kspot View PostIf I have the strategy set to buy 30K when x happens, it will actually buy 1 and then buy 29,999. Then when a profit target is hit it will start selling my position, 1 by 1 instead of closing out the whole position.
Is your 1 and 29,999 at the same price or different?
You have "Enforce Immediate Fills" enabled? If so, yeah, sounds like a issue....
12-04-2012, 07:46 AM #8
NinjaTrader_Jason
NinjaTrader Customer Service
Hello sledge,
You can enable 'Enforce immediate fills' at Control Center-->Tools-->Options-->Simulator-tab. This will cause orders to fill right away.
Jason
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,610 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
9 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
19 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
6 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
22 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
Comment