Dukascopy
 
 
Wiki JStore Search Login

Multiple strategy instances mixed up
 Post subject: Multiple strategy instances mixed up Post rating: 0   New post Posted: Wed 18 Oct, 2017, 05:10 
User avatar

User rating: 1
Joined: Fri 27 Jul, 2012, 07:04
Posts: 71
Location: Spain, Paracuellos de Jarama
Hello, I have a Visual JForex strategy that modifies the SL of the positions that are open when the hour changes to 21h GMT using last daily high or low as the new SL. This strategy uses a global variable: UniqueComment to identify the positions that has to manage.

When using a single instance of the strategy everything runs fine. But when I have two instances running locally, strategy instance1 for EURUSD and strategy instance2 for GBPUSD with different UniqueComment values then the SL modifications are mixed up:

Yesterday I had open two short postions:

Position 143782485 (GBPUSD) SL=1.33072
Position 143784641 (EURUSD) SL=1.18379

If working correctly position 143782485 (GBPUSD) that had previously SL = 1.33072 should be changed to the high of yesterday candle 1.32869 and Position 143784641 (EURUSD) that had previously SL = 1.18379 should be changed to the high of yesterday candle 1.18

But what happened was that the GBPUSD position was not modified and the EURUSD position was modified twice:

First the EURUSD position SL was changed to the GBPUSD High of yesterday candle (1.32869) and then it was changed again to the EURUSD high of yesterday candle (1.18).

21:00:00 Position 143784641 STOP LOSS #549013943 price changed from 1.18379 to 1.32869
21:00:00 Position 143784641 STOP LOSS #549013943 price changed from 1.32869 to 1.18


Please can you help me?


 
 Post subject: Re: Multiple strategy instances mixed up Post rating: 1   New post Posted: Thu 19 Oct, 2017, 14:41 
Visual JForex expert at Dukascopy
User avatar

User rating: 287
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Hi there,

Can you try this :


Image


Attachments:
SL_PerInst.JPG [118.58 KiB]
Downloaded 145 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Multiple strategy instances mixed up Post rating: 0   New post Posted: Wed 25 Oct, 2017, 04:24 
User avatar

User rating: 1
Joined: Fri 27 Jul, 2012, 07:04
Posts: 71
Location: Spain, Paracuellos de Jarama
Hello and thanks for your help,

Originally the position loop selected the open position to modify with an IF block using the comment parameter in the operation as each strategy instance is setup with a different one (StrategyName_EURUSD,StrategyName_EURGBP, ...) .

Image




After your suggestion I added another IF block to select only open operations where the Instrument parameter in the operation was equal to the DefaultInstrument as each strategy instance is setup with a different one EUR/USD, EUR/GBP,...

Image

But anyway the EUR/GBP active position take profit ended modified with the EUR/JPY yesterday High:

21:00:01 Position 144003406 TAKE PROFIT #550182590 price changed from 0.89752 to 134.192

Best regards

Francisco


 
 Post subject: Re: Multiple strategy instances mixed up Post rating: 1   New post Posted: Mon 30 Oct, 2017, 16:53 
Visual JForex expert at Dukascopy
User avatar

User rating: 287
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
I see,
What if you don't use "DefaultInstrument" but rather input a dedicated instrument in the block like I showed in my previous screenshot ?
(Click on the second input filed and select instrument from the drop-down list)


 
 Post subject: Re: Multiple strategy instances mixed up Post rating: 0   New post Posted: Tue 07 Nov, 2017, 22:46 
User avatar

User rating: 1
Joined: Fri 27 Jul, 2012, 07:04
Posts: 71
Location: Spain, Paracuellos de Jarama
Thanks for your answer, while testing your idea, I've found some serious unrelated problems in my strategy, so I'll need to rewrite (redraw?) it. I'll need a while to do it. I'll come back if the error modifying posts happens again.


 

Jump to:  

cron
  © 1998-2011 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com