I have tried writing my addon, it's just an add-on that connect if disconnect, and write a connection_status.txt
But now NT 8 doesnt open anymore, it keep looping on logo.
I can't go to NT to delete my addon, i have tried opening it in safe mode but there is no assemblies, and not addons. I have deleted the addon in bin/custom/addons, same problem. I have deleted the db folder, same problem.
How to remove the addon without going to NT?
This was my addon code:
using System;
using System.IO;
using System.Linq;
using System.Timers;
using NinjaTrader.Cbi;
using NinjaTrader.NinjaScript;
using NinjaTrader.NinjaScript.AddOns;
namespace NinjaTrader.NinjaScript.AddOns
{
public class ConnnectionTest : NinjaTrader.NinjaScript.AddOnBase
{
private Timer timer;
private string filePath = @"C:\ConnectionStatus.txt";
private Connection myConnection;
public ConnnectionTest()
{
// Create a timer with a 5-second interval
timer = new Timer(5000);
timer.AutoReset = true; // Set AutoReset to true for periodic execution
timer.Elapsed += OnTimerElapsed;
timer.Start();
// Connect to NinjaTrader if not connected
if (myConnection == null || myConnection.Status != ConnectionStatus.Connected)
{
myConnection = Connect("My NinjaTrader");
}
}
private void OnTimerElapsed(object sender, ElapsedEventArgs e)
{
// Get the connection status of the order feed
ConnectionStatus status = myConnection?.Status ?? ConnectionStatus.Disconnected;
// Write the connection status to the text file
File.WriteAllText(filePath, status.ToString());
// If connection status is not connected, try to reconnect
if (status != ConnectionStatus.Connected)
{
myConnection = Connect("My NinjaTrader");
}
}
private Connection Connect(string connectionName)
{
try
{
ConnectOptions connectOptions = null;
lock (Core.Globals.ConnectOptions)
connectOptions = Core.Globals.ConnectOptions.FirstOrDefault(o => o.Name == connectionName);
if (connectOptions == null)
{
NinjaTrader.Code.Output.Process("Could not connect. No connection found.", PrintTo.OutputTab1);
return null;
}
lock (Connection.Connections)
{
if (Connection.Connections.FirstOrDefault(c => c.Options.Name == connectionName) == null)
{
Connection connect = Connection.Connect(connectOptions);
// Only return connection if successfully connected
if (connect.Status == ConnectionStatus.Connected)
return connect;
else
return null;
}
}
return null;
}
catch (Exception error)
{
NinjaTrader.Code.Output.Process("Connect exception: " + error.ToString(), PrintTo.OutputTab1);
return null;
}
}
}
}

Comment