Trade ID Help

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

Trade ID Help

Postby ronald3rg » 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.

Code: Select all
function enter(BuySell)
-- code
 valuemap.OrderType = "OM";
    valuemap.OfferID = Offer;
    valuemap.AcctID = Account;
   if Parameters["UseAutoLotSize"] then
      valuemap.Quantity = LotSize();
      valuemap.Quantity = Amount * BaseSize;
    valuemap.BuySell = BuySell;
    valuemap.CustomID = CustomTXT.."OCO";
-- more code

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

         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")

             --more code

Right place at the right time

Posts: 40
Joined: Tue Oct 18, 2011 6:12 pm
Location: New York

Re: Trade ID Help

Postby Apprentice » Tue Feb 28, 2017 4:52 am

Can you share your code.
Will fix it for you.
User avatar
FXCodeBase: Confirmed User
Posts: 21641
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Return to Discussions

Who is online

Users browsing this forum: No registered users and 1 guest