I'm using MultiCharts .NET64 Version 8.8 Release (Build 9191), and am trying to have a callback fire in my study when I place an order in the DOM. The study is attached to the same instrument as I am placing the order in, although I would like it to fire regardless of what instrument the order is placed in. Just whenever the order set changes.
Following is the code, as bare as I can possibly make it. Compile it, attach it to the chart of instrument X, place an order in the instrument X through the DOM. Nothing is printed in the Output window.
What am I doing wrong?
Bonus question: once the callback issue is sorted, can you tell me how to make the study recalculate immediately?
Thank you.
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;
namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Enabled)]
public class MT_FinishChangingTest : SignalObject
{
public MT_FinishChangingTest(object _ctx):base(_ctx){}
protected override void Create()
{
}
protected override void StartCalc()
{
TradeManager.TradingData.Orders.Added += this.Orders_Added;
TradeManager.TradingData.Orders.Changed += this.Orders_Changed;
TradeManager.TradingData.Orders.Deleted += this.Orders_Deleted;
TradeManager.TradingData.Orders.FinishChanging += this.Orders_FinishChanging;
}
protected override void CalcBar()
{
Output.WriteLine( DateTime.UtcNow.ToString(" yyyy-MM-dd HH:mm:ss.fff" ) + " CalcBar()" );
}
private void Orders_FinishChanging( object sender, EventArgs e )
{
Output.WriteLine( DateTime.UtcNow.ToString(" yyyy-MM-dd HH:mm:ss.fff" ) + " Orders_FinishChanging()" );
}
private void Orders_Added( TradeManager.Order[] items )
{
Output.WriteLine( DateTime.UtcNow.ToString(" yyyy-MM-dd HH:mm:ss.fff" ) + " Orders_Added()" );
}
private void Orders_Changed( TradeManager.Order[] items )
{
Output.WriteLine( DateTime.UtcNow.ToString(" yyyy-MM-dd HH:mm:ss.fff" ) + " Orders_Changed()" );
}
private void Orders_Deleted( TradeManager.Order[] items )
{
Output.WriteLine( DateTime.UtcNow.ToString(" yyyy-MM-dd HH:mm:ss.fff" ) + " Orders_Deleted()" );
}
}
}