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

Need help with a position handling strategy
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=146&t=55816
Page 1 of 1

Author:  imadrock [ Tue 21 Nov, 2017, 16:45 ]
Post subject:  Need help with a position handling strategy

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 390 times

Author:  FXRabbit [ Tue 21 Nov, 2017, 17:29 ]
Post subject:  Re: Need help with a position handling strategy

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.

Author:  imadrock [ Wed 22 Nov, 2017, 02:36 ]
Post subject:  Re: Need help with a position handling strategy

Thank you for your help. Your attached pic is not showing, could you please repost it?

Author:  imadrock [ Wed 22 Nov, 2017, 06:49 ]
Post subject:  Re: Need help with a position handling strategy

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.

Author:  imadrock [ Wed 22 Nov, 2017, 08:04 ]
Post subject:  Re: Need help with a position handling strategy

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 374 times

Author:  amine_chourou [ Wed 22 Nov, 2017, 14:30 ]
Post subject:  Re: Need help with a position handling strategy

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

Author:  imadrock [ Thu 23 Nov, 2017, 02:22 ]
Post subject:  Re: Need help with a position handling strategy

Thank you for your reply, please find attached VFS file.

Attachments:
LongTrStopJPY.vfs [28.9 KiB]
Downloaded 184 times

Author:  amine_chourou [ Thu 23 Nov, 2017, 16:34 ]
Post subject:  Re: Need help with a position handling strategy

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 190 times

Author:  imadrock [ Fri 24 Nov, 2017, 03:51 ]
Post subject:  Re: Need help with a position handling strategy

Thank you for your reply. If I have multiple instruments positions, how do I calculate the certain instrument position?

Author:  amine_chourou [ Fri 24 Nov, 2017, 14:43 ]
Post subject:  Re: Need help with a position handling strategy

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.

  Page 1 of 1