I'm checking how long it takes to an order from the entry to execution in simulation mode
With my Pc Win 10 i5 8gb ram I've have an average time of about 200ms
Is it a good time?
It seems a bit low for me
This is my code
#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.Gui.Tools;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.Indicators;
using NinjaTrader.NinjaScript.DrawingTools;
using System.Diagnostics;
#endregion
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class TestTempiEsecuzioneordine : Strategy
{
bool Go= true;
Stopwatch st = new Stopwatch();
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"TestExecutionTime";
Name = "Test";
Calculate = Calculate.OnPriceChange;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = false;
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.ByStrategyPosition;
BarsRequiredToTrade = 1;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
if (IsFirstTickOfBar)
{
Go= true;
}
if (bEsegui)
{
if (Close[0] >= High[1])
{
if (Position.MarketPosition != MarketPosition.Long)
{
st.Reset();
st.Start();
EnterLong(Convert.ToInt32(DefaultQuantity), @"E");
Go= false;
}
}
else if (Close[0] <= Low[1])
{
if (Position.MarketPosition != MarketPosition.Short)
{
st.Reset();
st.Start();
ExitLong(Convert.ToInt32(DefaultQuantity));
Go= false;
}
}
}
}
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
{
if (order.OrderState == OrderState.Filled)
{
st.Stop();
double microseconds = (1000000.0 / Stopwatch.Frequency) * st.ElapsedTicks;
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"C:\nj\Test.txt", true))
{
sw.WriteLineAsync(microseconds.ToString());
sw.Close();
}
Go= true;
}
}
}
}
Comment