Dukascopy
 
 
Wiki JStore Search Login

Changes to Strategy to make it work in Multiple Strategy Environment
 Post subject: Changes to Strategy to make it work in Multiple Strategy Environment Post rating: 0   New post Posted: Mon 21 Mar, 2016, 14:18 
User avatar

User rating: 0
Joined: Wed 10 Jul, 2013, 12:42
Posts: 30
Location: FranceFrance
Hello
I have a template running nicely in historical backtest but I have an issue that I don't know how to resolve when running the strategy in a live test.

I would like to run the strategy across 2-6 currency pairs concurrently for live testing. To do this currently I change the currencypair to create a new strategy, save/build and run all of the strategies, differing only by currency pair, inside Jforex.

The issue relates to the code I have around OpenPositions.PositionsAmount.
As I only want One trade open at any one time on a currently pair, not multiple longs/shorts nor longs and shorts concurrently, entry is set when OpenPositions.PositionsAmount =0
I also have OpenPositions.PositionsAmount used in my criteria to move Stop Loss to Break Even / Open price.

In a multi-strategy environment of course, only the 1st trade across all pairs running the strategy gets opened. What I would like to occur is all the valid EURUSD trades occur in parallel to the GBPUSD, AUDUSD etc so the strategies work independently.

I have tried using a Position Variable and Boolean Variable to be a check to replace OpenPositions.PositionsAmount but I'm either on the wrong track or on the right one but just plain writing it incorrectly, and I'm not knowledgeable enough in .vfs yet to know which.

Can someone have a look at the attached Template and point me in the right direction to replace the OpenPositions.PositionsAmount code so it can work in a strategy-independent way? I couldn't find any references to this particular issue in the forum.

** edit ** I'm not sure attachments are working.
Here is a link to the .vfs file on OneDrive:
https://onedrive.live.com/redir?resid=B ... file%2cvfs

Thanks
LD


 
 Post subject: Re: Changes to Strategy to make it work in Multiple Strategy Environment Post rating: 0   New post Posted: Tue 22 Mar, 2016, 07:49 
User avatar

User rating: 0
Joined: Wed 10 Jul, 2013, 12:42
Posts: 30
Location: FranceFrance
I have a working solution for the issue which I will document here.

I created a new variable (Trade_Count). Before the BUY and Sell Blocks I implemented an If check. If Trade_Count and 0. If = 0 then flow to Open at Market Block

After the Buy and Sell block, attached to the 4th arrow I created a calculation:
First Parameter, Trade_Count, Second Parament 1, Output Trade_Count, Settings Sum

The third piece I wrote was to attach code to TradeEvent, to reset Trade_count. If LastTradeEvent.TradeMessage is PositionClose is True, Assign 0 to Trade_Count.

I don't know if this is the best way of achieving the result but it seems to work on my initial tests. If anyone has comment to achieve this in a better way please let me know.

** Edit ** .vfs with changes here: https://onedrive.live.com/redir?resid=B ... file%2cvfs

I am not sure my LastTradeEvent.TradeMessage PositionClose is working, as messages are like the following: Take Profit Sell, Stop Loss Sell, Order Filled - all of which are closed positions but may not be encompassed by TradeMessage PositionClose. Something further to look or if anyone has a comment that would be appreciated.

LD


 
 Post subject: Re: Changes to Strategy to make it work in Multiple Strategy Environment Post rating: 0   New post Posted: Mon 28 Mar, 2016, 14:24 
Visual JForex expert at Dukascopy
User avatar

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

The way you built your strategy to limit the number of open positions without getting stuck with "OPen Positions" variable is the best way. The only minor mistake there is that you need to assign a start value to your variable "Trade count" as it is an integer that is used in a logical comparison and should get a start value (0 in your case).
The trade event will be updated accordingly once the position is closed and there no worries at this level.

Cheers


 
 Post subject: Re: Changes to Strategy to make it work in Multiple Strategy Environment Post rating: 0   New post Posted: Tue 29 Mar, 2016, 10:01 
User avatar

User rating: 0
Joined: Wed 10 Jul, 2013, 12:42
Posts: 30
Location: FranceFrance
Thanks for reviewing Amine. I'll implement the change.

LD


 

Jump to:  

  © 1998-2025 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