Hello Apprentice,
Okay my method failed so am trying to implement your suggestion but am having trouble calling open time for order from table. this is what I have created.
Startegy already has loop that checks for conditions every second now within the loop I implemented your suggestions that calls upon the opetime of previous trades like so:
- Code: Select all
if UseCOexpiry then
local opentime;
opentime = getOpenTime("OCO");
-- Delete CO1 after set CO expiry Logic
if haveTrades(nil, "OCO") and haveOrders(nil, "CO1") and currentTime >= (opentime(nil,"OCO") + COxTimer) then
core.host:trace("Deleting CO1 Time Expired. "..message)
logger:info(" Deleting CO1 Time Expired. "..message);
deleteOrders();
end
end
So logic calls upon the getOpenTime function but am certain i am calling on the wrong information by using "open"
- Code: Select all
-- returns open time of trade if ctxtadd matches trade's StoredValueCustomTXT
function getOpenTime(ctxtadd)
local enum, row;
local found = false;
local opentime;
enum = core.host:findTable("trades"):enumerator();
row = enum:next();
while (not found) and (row ~= nil) do
if row.AccountID == Account and
row.OfferID == Offer and
getRawCustomTXT(row.QTXT) == getRawCustomTXT(CustomTXT) and
getStoredValueCustomTXT(row.QTXT) == ctxtadd then
found = true;
opentime = row.Open
end
row = enum:next();
end
return opentime;
end
any suggestions?
Best
Ron