Dukascopy
 
 
Wiki JStore Search Login

Need help with a position handling strategy
 Post subject: Need help with a position handling strategy Post rating: 0   New post Posted: Tue 21 Nov, 2017, 16:45 

User rating: 0
Joined: Tue 21 Nov, 2017, 03:27
Posts: 10
Location: ChinaChina
Dear support team,

I'm writing a strategy with VJF. The logic is to handle the existing positions which are opened manually.

I want to close half of the open positions of a certain instrument when price is lower the last candle low.

Please find attached VJF screenshot. The strategy just doesn't work. Please help me check what is the problem.

Thank you very much.
Image


Attachments:
LongTrStop.jpg [100.41 KiB]
Downloaded 387 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: Need help with a position handling strategy Post rating: 0   New post Posted: Tue 21 Nov, 2017, 17:29 
User avatar

User rating: 5
Joined: Thu 04 Aug, 2016, 04:51
Posts: 61
Location: CanadaCanada
Hello Imadrock,

The first thing you need to do is to use another IF block before the IF block of "LastAskCandle:CandleInstrument" to sort out the Candle Period you wish to use for collecting the low price from it. Something like the following screenshot:

Image


Should you still have any issue, then please post below.


 
 Post subject: Re: Need help with a position handling strategy Post rating: 0   New post Posted: Wed 22 Nov, 2017, 02:36 

User rating: 0
Joined: Tue 21 Nov, 2017, 03:27
Posts: 10
Location: ChinaChina
Thank you for your help. Your attached pic is not showing, could you please repost it?


 
 Post subject: Re: Need help with a position handling strategy Post rating: 0   New post Posted: Wed 22 Nov, 2017, 06:49 

User rating: 0
Joined: Tue 21 Nov, 2017, 03:27
Posts: 10
Location: ChinaChina
I tried to add an if block to check the time frame. It seems work. However the position closed was not right. I had 2 long positions of 100000 and 60000 for USD/JPY, it closed 100000 position instead of 80000 according to the VJF strategy. There must be something wrong about the position handling blocks. Could you please help check if it is right.


 
 Post subject: Re: Need help with a position handling strategy Post rating: 0   New post Posted: Wed 22 Nov, 2017, 08:04 

User rating: 0
Joined: Tue 21 Nov, 2017, 03:27
Posts: 10
Location: ChinaChina
imadrock wrote:
I tried to add an if block to check the time frame. It seems work. However the position closed was not right. I had 2 long positions of 100000 and 60000 for USD/JPY, it closed 100000 position instead of 80000 according to the VJF strategy. There must be something wrong about the position handling blocks. Could you please help check if it is right.


Please find the attached screen shot of the system message. It looks like the strategy send 2 closing orders.

Image
Image


Attachments:
QQ截图20171122135645.jpg [21.95 KiB]
Downloaded 370 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: Need help with a position handling strategy Post rating: 1   New post Posted: Wed 22 Nov, 2017, 14:30 
Visual JForex expert at Dukascopy
User avatar

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

You should be able to achieve that using the field "Amount" in the block "Close / Cancel position". this field is dedicated to partial close command.
So first you sum up your traded amounts per side and instrument then you close the sum / 2

Would be good to have your strategy in VFS format


 
 Post subject: Re: Need help with a position handling strategy Post rating: 0   New post Posted: Thu 23 Nov, 2017, 02:22 

User rating: 0
Joined: Tue 21 Nov, 2017, 03:27
Posts: 10
Location: ChinaChina
Thank you for your reply, please find attached VFS file.


Attachments:
LongTrStopJPY.vfs [28.9 KiB]
Downloaded 180 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: Need help with a position handling strategy Post rating: 1   New post Posted: Thu 23 Nov, 2017, 16:34 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Hi,
Here is an example. Your error is actually related to the use of the variable "Position Amount" which is the number of open positions and not the traded amount.
In this example I have used "Trade event" which can be very interesting as it catches the last fill message and then I divide the position traded amount / 2 to proceed. You can insert your exit conditions in-between obviously.



This is a test log snippet:
15:28:10 Order #555264640 FILLED at 1.18455 (#555264640 SELL 0.03 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #144992941.
15:28:10 Order #555264639 FILLED at 1.18455 (#555264639 SELL 0.05 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #144992940.
15:28:10 Order ACCEPTED: #555264640 SELL 0.03 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005 - Position #144992941
15:28:10 Order ACCEPTED: #555264639 SELL 0.05 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005 - Position #144992940
15:28:10 Order #555264636 FILLED at 1.18458 (#555264636 BUY 0.06 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #144992941.
15:28:10 Order #555264635 FILLED at 1.18458 (#555264635 BUY 0.1 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005) - Position #144992940.
15:28:10 Order ACCEPTED: #555264636 BUY 0.06 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005 - Position #144992941
15:28:10 Order ACCEPTED: #555264635 BUY 0.1 mil. EUR/USD @ MKT MAX SLIPPAGE 0.0005 - Position #144992940


Cheers


Attachments:
PartialClose.vfs [33.75 KiB]
Downloaded 187 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: Need help with a position handling strategy Post rating: 0   New post Posted: Fri 24 Nov, 2017, 03:51 

User rating: 0
Joined: Tue 21 Nov, 2017, 03:27
Posts: 10
Location: ChinaChina
Thank you for your reply. If I have multiple instruments positions, how do I calculate the certain instrument position?


 
 Post subject: Re: Need help with a position handling strategy Post rating: 1   New post Posted: Fri 24 Nov, 2017, 14:43 
Visual JForex expert at Dukascopy
User avatar

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

The function implemented is based on Trade Event --> So it catches whatever "FILLED" message received regardless of the traded instrument and retrieves the traded amount then devide it by 2.


 

Jump to:  

cron
  © 1998-2024 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