Somehow multiple fills as drown on the chart are at levels where market never traded; chart is attached, 3 fills in question are highlighted. in the highlighted bars the fills are above the bars; when checking in data windows I see that the instrument never traded at the level where strategy orders were filled
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
NT8 - Starategy runing with real time data feed get feels outside of market
Collapse
X
-
NT8 - Starategy runing with real time data feed get feels outside of market
I am running a strategy in my window on live data feed.
Somehow multiple fills as drown on the chart are at levels where market never traded; chart is attached, 3 fills in question are highlighted. in the highlighted bars the fills are above the bars; when checking in data windows I see that the instrument never traded at the level where strategy orders were filledLast edited by astef; 02-08-2016, 06:59 PM.Tags: None
-
Yes
That was run with sample strategy cross over which follows.
I think that CrossAbove and CrossBelow functions do not work correctly.
When I use them on 1 min charts with tick replay all goes wrong.
I had to replace those functions with:
if (SMA(Fast)[0] > SMA(Slow)[0] && SMA(Fast)[1] <= SMA(Slow)[1])
and then when I print the last tick to identify when crossover occurs for the first time and printout the tick with triggered the condition, I see that ninja actualy did not traded at that level, but at some other level which is different; with crossover functions I get fills outside of market;
with checking of SMAs as above the fills in back testing with tick replay are also incorrect
,
...
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "MAStrategyCrossAbove";
Name = "MAStrategyCrossAbove";
Fast = 6;
Slow = 15;
Calculate = Calculate.OnEachTick;
RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
StopTargetHandling = StopTargetHandling.ByStrategyPosition;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
Slippage = 0;
StartBehavior = StartBehavior.AdoptAccountPosition;
TimeInForce = TimeInForce.Gtc;
TraceOrders = true;
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
BarsRequiredToTrade = Slow;
smaFast = SMA(Fast);
smaSlow = SMA(Slow);
smaFast.Plots[0].Brush = Brushes.Orange;
smaSlow.Plots[0].Brush = Brushes.Green;
AddChartIndicator(smaFast);
AddChartIndicator(smaSlow);
SetProfitTarget(CalculationMode.Ticks, Target);
SetStopLoss(CalculationMode.Ticks, Stop);
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
if (CrossAbove(smaFast, smaSlow, 1))
EnterLong();
else if (CrossBelow(smaFast, smaSlow, 1))
EnterShort();
}
#region Properties
[Range(1, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = "Fast", GroupName = "MA", Order = 0)]
public int Fast
{ get; set; }
[Range(1, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = "Slow", GroupName = "MA", Order = 1)]
public int Slow
{ get; set; }
[Range(0, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = "Target", GroupName = "Limits", Order = 1)]
public int Target
{ get; set; }
[Range(0, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = "Stop", GroupName = "Limits", Order = 1)]
public int Stop
{ get; set; }
#endregion
}
}
Comment
-
installed 8 beta 10
this is far worse then previous version
tick replay simply does not work
note the following code which will print all bars and all ticks
when running in tick reply mode i only get one tick for each 1 minute bar
previously it did work correctly and i could observe multiple ticks in tick replay mode
your charts and fills were incorrect, but i was able to capture entry criteria and was able to calculate p/l for each trade; now i can not do anything as i just get one tick regardless
//
// Copyright (C) 2015, NinjaTrader LLC <www.ninjatrader.com>.
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
//
#region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.Indicators;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
//This namespace holds strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class MACrossOverTick : Strategy
{
private SMA smaFast;
private SMA smaSlow;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "MACrossOverTick";
Name = "MACrossOverTick";
Fast = 10;
Slow = 25;
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
}
else if (State == State.Configure)
{
smaFast = SMA(Fast);
smaSlow = SMA(Slow);
smaFast.Plots[0].Brush = Brushes.Orange;
smaSlow.Plots[0].Brush = Brushes.Green;
AddChartIndicator(smaFast);
AddChartIndicator(smaSlow);
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
if (IsFirstTickOfBar)
{
Print(" BAR "
+ (State == State.Historical ? " H " : "R ")
+ " " + Time[0].ToString()
+ " Close[0]:" + Close[0].ToString()
+ " High[0]:" + High[0].ToString("N2")
+ " Low[0]:" + Low[0].ToString("N2")
);
}
Print(" TICK "
+ (State == State.Historical ? " H " : "R ")
+ " " + Time[0].ToString()
+ " Close[0]:" + Close[0].ToString()
+ " High[0]:" + High[0].ToString("N2")
+ " Low[0]:" + Low[0].ToString("N2")
);
/* CROSSOVER DOES NOT WORK
if (CrossAbove(smaFast, smaSlow, 1))
EnterLong();
else if (CrossBelow(smaFast, smaSlow, 1))
EnterShort();
*/
if (SMA(Fast)[0] > SMA(Slow)[0] && SMA(Fast)[1] <= SMA(Slow)[1])
{
Print(">>>>> GOLONG "
+ (State == State.Historical ? " H " : "R ")
+ " " + Time[0].ToString()
+ " Close[0]:" + Close[0].ToString()
);
EnterLong();
}
if (SMA(Fast)[0] < SMA(Slow)[0] && SMA(Fast)[1] >= SMA(Slow)[1])
{
Print(">>>>> GOSHORT "
+ (State == State.Historical ? " H " : "R ")
+ " " + Time[0].ToString()
+ " Close[0]:" + Close[0].ToString()
);
EnterShort();
}
}
#region Properties
[Range(1, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = "Fast", GroupName = "NinjaScriptStrategyParameters", Order = 0)]
public int Fast
{ get; set; }
[Range(1, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = "Slow", GroupName = "NinjaScriptStrategyParameters", Order = 1)]
public int Slow
{ get; set; }
#endregion
}
}
Comment
-
I also see this too!!! NT8B10 with your script.
This was on a 5 minutes chart. If you go here and do a full tick replay on current day only, you can get multiple prints but only displays the 5 minute bar time?
Last edited by sledge; 04-09-2016, 12:35 PM.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by techgetgame, Yesterday, 11:42 PM
|
0 responses
8 views
0 likes
|
Last Post
by techgetgame
Yesterday, 11:42 PM
|
||
Started by sephichapdson, Yesterday, 11:36 PM
|
0 responses
2 views
0 likes
|
Last Post Yesterday, 11:36 PM | ||
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,613 views
0 likes
|
Last Post
by aligator
Yesterday, 07:22 PM
|
||
Started by jaybedreamin, Yesterday, 05:56 PM
|
0 responses
10 views
0 likes
|
Last Post
by jaybedreamin
Yesterday, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
20 views
0 likes
|
Last Post
by DJ888
Yesterday, 05:12 PM
|
Comment