I'd like to be able to receive an immediate notification via callback when an order is executed.
It would also be great to be able to register a time of day callback. i.e. At 2pm EST everyday a callback fires.
Are there examples for different types of events/callbacks available?
events or callbacks once order is filled
Re: events or callbacks once order is filled
TradeManager has events that you can subscribe to.
https://www.multicharts.com/downloads/M ... e-v1.0.pdf
Here's a quick example. It outputs when an order is added. A few points to note:
https://www.multicharts.com/downloads/M ... e-v1.0.pdf
Here's a quick example. It outputs when an order is added. A few points to note:
- The orders collection is only updated upon calling TradeManager.ProcessEvents(), so you need to call this from CalcBar.
- Enabling IOGMode is the best way to trigger the event asap after the collection changes.
- The entire orders array is passed to the callback, rather than the specific order that triggered the event.
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using System.Net;
using PowerLanguage.Function;
using PowerLanguage.TradeManager;
using ATCenterProxy.interop;
using Newtonsoft.Json;
namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Enabled)]
public class CallbackExample : SignalObject
{
public CallbackExample(object _ctx) : base(_ctx)
{
}
protected override void Create()
{
}
protected override void StartCalc()
{
this.Output.Clear();
this.TradeManager.TradingData.Orders.Added += (orders) =>
{
this.Output.WriteLine("Order Added");
};
}
protected override void CalcBar()
{
this.TradeManager.ProcessEvents();
}
}
}
- Vlada MultiCharts
- Posts: 293
- Joined: 22 Apr 2020
- Has thanked: 8 times
- Been thanked: 76 times
Re: events or callbacks once order is filled
Hello,
You can enable the option Recalculate on Broker Events -> Order Filled by going Format -> Strategy Properties -> Auto Trading Tab (check the attached screenshot).
If you'd like to perform calculations at a specific time, you can use a keyword RecalcLastBarAfter.
You can enable the option Recalculate on Broker Events -> Order Filled by going Format -> Strategy Properties -> Auto Trading Tab (check the attached screenshot).
If you'd like to perform calculations at a specific time, you can use a keyword RecalcLastBarAfter.
- Attachments
-
- Auto Trading Settings_MultiCharts.png
- (24.64 KiB) Not downloaded yet