What does this mean? Is this another parameter that can be enumerated and grabbed with row.TrlRate? Why isn't there a separate listing for it if this is the case? Why not just enumerate row.TrlMinMove?
I want to be able to detect whether there is a dynamic trailing stop on trades, but this isn't very clear. Could someone explain how this is to be tested for, please?
Here is a fragment of the code I am working with. My strategy creates the trailing stop, but it doesn't remove the dynamic trailing when I want it to. The edit order command runs repeatedly, but it doesn't change the trailing mode.
(I know this is kind of messy, but I've been throwing stuff at it trying to see how it works.)
- Code: Select all
local enum, row, orderid, rate;
local trailing = false;
enum = core.host:findTable("Orders"):enumerator();
while not netStop do
row = enum:next();
if row == nil then
break;
end
if row.OfferID == offer then
if row.NetQuantity == true then
netStop = true;
if row.QTXT == customID then
if row.TrlRate ~= 0 then
orderid = row.OrderID;
rate = row.Rate;
trailing = true;
end
end
end
end
end
--Remove trailing attribute from stop if at breakeven
if netStop and
trailing then
if (rate > avgOpen + 3 * pip and
direction == "B") or
(rate < avgOpen - 3 * pip and
direction == "S") then
valuemap = core.valuemap();
valuemap.Command = "EditOrder";
valuemap.OfferID = offer;
valuemap.AcctID = account;
valuemap.OrderID = orderid;
valuemap.TrailUpdatePips = 0;
success, msg = terminal:execute(105, valuemap);
if not success then
terminal:alertMessage(instance.bid:instrument(), instance.bid[NOW], "change order failed: " .. msg, instance.bid:date(NOW));
end
end
end