Trade ID Help
Posted: Mon Feb 13, 2017 1:01 am
Hello Developers,
Need a little help or if you would point me in the right direction.
Strategy: Opens orders based on given signal/indicator, then it creates a contingent order in opposite direction at set parameters set by user.
Now issue is that it creates the orders but it seems to always create the contingent order based on the original/ first position entered instead of adapting to each new order and placing them at desired location from that order.
Currently when system creates a New BuySell order I have add CustomTXT to let contingent orders be placed. Strategy works very well if only treading one order/position at a time but I can't seem to figure out a way to get it to work when it opens multiple positions.
On this section I am able to track if the original order was placed but need a way to pass on individual trades so the strategy can properly set and delete orders if the preceding orders/positions no longer exist.
Best
Ron
Need a little help or if you would point me in the right direction.
Strategy: Opens orders based on given signal/indicator, then it creates a contingent order in opposite direction at set parameters set by user.
Now issue is that it creates the orders but it seems to always create the contingent order based on the original/ first position entered instead of adapting to each new order and placing them at desired location from that order.
Currently when system creates a New BuySell order I have add CustomTXT to let contingent orders be placed. Strategy works very well if only treading one order/position at a time but I can't seem to figure out a way to get it to work when it opens multiple positions.
- Code: Select all
function enter(BuySell)
-- code
valuemap.OrderType = "OM";
valuemap.OfferID = Offer;
valuemap.AcctID = Account;
if Parameters["UseAutoLotSize"] then
valuemap.Quantity = LotSize();
else
valuemap.Quantity = Amount * BaseSize;
end
valuemap.BuySell = BuySell;
valuemap.CustomID = CustomTXT.."OCO";
-- more code
end
On this section I am able to track if the original order was placed but need a way to pass on individual trades so the strategy can properly set and delete orders if the preceding orders/positions no longer exist.
- Code: Select all
-- contingent order 1 logic
--Code
if haveTrades("B", "OCO") then
createContingentOrder("S", lotsize, openprice, ContingentOrder1Offset, ContingentOrder1Stop, ContingentOrder1Limit, "1")
elseif haveTrades("S", "OCO") then
createContingentOrder("B", lotsize, openprice, ContingentOrder1Offset, ContingentOrder1Stop, ContingentOrder1Limit, "1")
end
--more code
--
Best
Ron