Trade FOREX with FXCM

  • Award-Winning Platform
  • 24/7 Customer Support
  • Trade Directly on Charts
  • Free $50K Practice Account
Register


Results 1 to 5 of 5

Thread: How to set up 2 trade entries with 2 stops one for each entry?

  1. #1
    peterNZ is offline Member
    Join Date
    Dec 2008
    Posts
    35

    How to set up 2 trade entries with 2 stops one for each entry?

    Hello team,

    I'm currently building my 1st "TREND" trading script and am a little confused by what looks like a lobsided trade entry system. It looks like the opposite to a Buy is NOT Sell but a SellShort and the opposite to a Sell is a BuyToCover. Anyway the whole set of options has left me totally bewildered.

    I've had a go using "Buy" and "SellShort" and these work well the SellShort closes all the buys AND enters the short trades and the Buy does the exact opposite. I've backtested it and got good results from the awsome backtesting and optimization tools that come with Strategy Trader (unbelievable - going through a whole set of input permutations and instantly revealing things that would have taken months to figure.)

    I now need to look at limiting the losses to further improve the result. The good trades are triggered all along the trending price action and have a max drawdown of less than 20pips so I now need to be able to place a stop behind each entry of say 25 - 30 pips which hopefully will not disturb the bread and butter trades and limit the losses on the losing ones.

    Looking through the the forum it looks as though there are multiple ways to do this, one that looks good is to define an exit which refers to the particular entry by name.
    example given:-

    exit1=OrdersFactory.CreateStop(new OrdersCreateParams(Lots.Variable, OrderAction.Sell, ExitInfo.FromEntry(buy_order)));
    exit2=OrdersFactory.CreateStop(new OrdersCreateParams(Lots.Variable, OrderAction.Sell, ExitInfo.FromEntry(buy_order2)));

    But I'm getting into a real mess trying to get this to work.
    Given that my naming will be "T1_buy1", "T1_buy2" and "T1_sellShort1", "T1_sellShort2" how do I declare and set this up, a nice simple example showing 2 buy trades for example each with a 20pip stop would be of immense help for me.

    Also for efficiency I am trying to put as much code as possible on the LAST tick of a bar only, Will this have any effect on the trades entries and stops?

    Many Thanks
    Peter

  2. #2
    jimmylmh is offline FXCM Automated Platform Specialist
    Join Date
    Dec 2010
    Posts
    964
    Hi Peter,

    Thank you for posting on the forum.

    You might want to construct your orders like this:
    Code:
    			buy_order = OrdersFactory.CreateMarketNextBar(new OrdersCreateParams(Lots.Variable, OrderAction.Buy));
    			buy_order2 = OrdersFactory.CreateMarketNextBar(new OrdersCreateParams(Lots.Variable, OrderAction.Buy));
    			
    			ss_order = OrdersFactory.CreateMarketNextBar(new OrdersCreateParams(Lots.Variable, OrderAction.SellShort));
    			ss_order2 = OrdersFactory.CreateMarketNextBar(new OrdersCreateParams(Lots.Variable, OrderAction.SellShort));
    			
    			exitbuy1=OrdersFactory.CreateStop(new OrdersCreateParams(Lots.Variable, OrderAction.Sell, ExitInfo.FromEntry(buy_order)));
    			exitbuy2=OrdersFactory.CreateStop(new OrdersCreateParams(Lots.Variable, OrderAction.Sell, ExitInfo.FromEntry(buy_order2)));
    			
    			exitsell1=OrdersFactory.CreateStop(new OrdersCreateParams(Lots.Variable, OrderAction.BuyToCover, ExitInfo.FromEntry(ss_order)));
    			exitsell2=OrdersFactory.CreateStop(new OrdersCreateParams(Lots.Variable, OrderAction.BuyToCover, ExitInfo.FromEntry(ss_order2)));
    Please keep in mind that since the orders are constructed as Lots.Variable, lot sizes have to be specified when you call the Generate method for those orders.

    Also for efficiency I am trying to put as much code as possible on the LAST tick of a bar only, Will this have any effect on the trades entries and stops?

    I am not quite sure what you mean by this, how do you manage to accomplish this? And do you have IntraBar Order Generation enabled?

    Let us know if it helps.

    Regards,
    Jimmy

  3. #3
    peterNZ is offline Member
    Join Date
    Dec 2008
    Posts
    35
    Hello Jimmy,
    Thanks for the reply (nb I keep messing up the reply this is my 3rd attempt I hope you are only receiving one reply).

    I could not find where to put the price value for the stop, it looks like this may be a direct command from the strategy to exit the trade at the current level. I would be more comfortable being able to place each stop on the chart at the appropriate level for each order and have each one last for the same time as the corresponding order.
    For example with FXCM MarketScope 2.0 I can place 3 separate buy orders along with a stop and limit for each order, then log out turn off my computer and walk away with the trades, stops and limits still active.

    Can this be done here?
    Peter

  4. #4
    jimmylmh is offline FXCM Automated Platform Specialist
    Join Date
    Dec 2010
    Posts
    964
    Hi Peter,

    Thank you for posting on the forum.

    Suppose you have constructed the order with the above code, you can call them in the Execute method like this:
    Code:
    exitbuy1.Generate(<stop rate>, <lots>);
    exitbuy2.Generate(<stop rate>, <lots>);
    exitsell1.Generate(<stop rate>, <lots>);
    exitsell2.Generate(<stop rate>, <lots>);
    They will be generated as OCO orders.

    Please note that in Strategy Trader, the stop and limit orders are not dedicated to any specific positions. Limit and Stop orders are generated as OCO entry orders.

    Let us know if you have further questions.

    Regards,
    Jimmy

  5. #5
    peterNZ is offline Member
    Join Date
    Dec 2008
    Posts
    35
    Thanks Jimmy, i think that's enough now for me to start playing around with them to see how they operate.

    Many thanks
    Peter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Disclaimer: Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with foreign exchange trading, and seek advice from an independent financial advisor if you have any doubts. Any opinions, news, research, analyses, prices, or other information contained on this website is provided as general market commentary and does not constitute investment advice. Forex Capital Markets LLC. will not accept liability for any loss or damage, including without limitation to, any loss of profit, which may arise directly or indirectly from use of or reliance on such information.