Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

Multiple strategy instances mixed up
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=141&t=55626
Page 1 of 1

Author:  frangonve [ Wed 18 Oct, 2017, 05:10 ]
Post subject:  Multiple strategy instances mixed up

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?

Author:  amine_chourou [ Thu 19 Oct, 2017, 14:41 ]
Post subject:  Re: Multiple strategy instances mixed up

Hi there,

Can you try this :


Image

Attachments:
SL_PerInst.JPG [118.58 KiB]
Downloaded 523 times

Author:  frangonve [ Wed 25 Oct, 2017, 04:24 ]
Post subject:  Re: Multiple strategy instances mixed up

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

Author:  amine_chourou [ Mon 30 Oct, 2017, 16:53 ]
Post subject:  Re: Multiple strategy instances mixed up

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)

Author:  frangonve [ Tue 07 Nov, 2017, 22:46 ]
Post subject:  Re: Multiple strategy instances mixed up

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.

  Page 1 of 1