| -
Multiple Stop Combined Into One
Hi All,
I'm having an issue with managing my stops for a strategy that enters multiple positions at once. I would like to have individual stops and limits for each of the individual trades. To do this I wrote this code: Code: if(Math.Abs(StrategyInfo.MarketPosition) > 0)
{
for(int ii = 0; ii < CurrentPosition.OpenTrades.Count; ii++){
entryprice = CurrentPosition.OpenTrades[ii].Entry.Price;
if(StrategyInfo.MarketPosition > 0){
m_order4.Generate((entryprice - exitstoppips*Bars.Point*10),2);
m_order6.Generate((entryprice + exitlimitpips1*Bars.Point*10), 1);
m_order8.Generate((entryprice + exitlimitpips2*Bars.Point*10), 1);
}
if(StrategyInfo.MarketPosition < 0){
m_order3.Generate((entryprice + exitstoppips*Bars.Point*10),2);
m_order5.Generate((entryprice - exitlimitpips1*Bars.Point*10),1);
m_order7.Generate((entryprice - exitlimitpips2*Bars.Point*10),1);
}
}
} I would think this would go through each of my open trades and place orders for the stops and limits based on each of the individual trades entry prices. In backtesting, however, all the stops and limits are placed in relation to the entry price of the most recent trade as seen in this screen shot: 
Does anyone know whats going on?
Thanks,
Cory
-
Hi coryaitch,
Please remember that when entry order created by IPriceOrder are called twice, it won't generate two entry orders, instead, it will replace the old order will the new one. That' why all your position are all stop at one level.
Regards,
jpschan
-
Is there a solution?
jpschan -
How would one get around this issue then? I am trying to create a strategy that would generate multiple orders each with their own individual Stops and Limits, but am coming across the same issues as coryaitch.
I'm assuming using IPriceOrder won't be the way to go.
coryaitch -
did you fix the problem, and if so, how?
Many thanks
-
Hi marcusrjudge,
Thank you for posting.
Please refer to this thread http://forexforums.dailyfx.com/codin...ach-entry.html (How to set up 2 trade entries with 2 stops one for each entry?) for some guidelines on how to construct and generate orders with multiple stop loss.
Let us know if you have further questions.
Regards,
Jimmy
|
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
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.