I am trying to subscribe to events so that I can trace stoploss and other things.
I have a strategy that has been doing this for a long time now without difficulty although it needs some improvement to monitor the CustomID/QTXT so that I avoid interference with any other strategy or manual intervention.
But for some reason I cannot trace the events.
Here is a totally stripped down strategy that doesn't actually trade but should report the events via AsyncOperationFinished:
- Code: Select all
function Init()
strategy:name("Skeleton")
strategy:description("No flesh")
end
local TRADE_EVENT = 1001
local ORDER_EVENT = 1002
local OFFER_EVENT = 1003
local host = core.host
local period = 0
function Prepare(onlyName)
instance:name(profile:id() .. "(" .. instance.bid:instrument() .. ")")
if onlyName then return end
host:execute("subscribeTradeEvents", OFFER_EVENT , "offers")
host:execute("subscribeTradeEvents", ORDER_EVENT , "orders")
host:execute("subscribeTradeEvents", TRADE_EVENT , "trades")
end
function Update()
period = period + 1
xprint("Update entered "..period)
end
function AsyncOperationFinished(cookie, success, message)
xprint("AOF entered with cookie "..cookie.." success "..success.." message "..message)
end
function xprint(txt)
host:trace(txt)
end
As I said, very simple. I can import this and run it.
There are no error messages in the event logger other than the message from Update - ie I do not see a message "AOF entered..... " at all which should occcur whenever an offer, order or trade is made on the instrument.
This occurs on two PCs so I don't think it is a PC setting at all and previously it was working perfectly well.