Dukascopy
 
 
Wiki JStore Search Login

ORDER_CLOSED_BY_SL IN VJF
 Post subject: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Thu 15 Dec, 2016, 13:35 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Greetings Support.

Have you any Idea how to implement this
if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_SL)){}
in VJF ?
Thanks in advance.


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Thu 15 Dec, 2016, 16:53 
Visual JForex expert at Dukascopy
User avatar

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

Well, catching this from the messages (Trade Event) is not feasible currently. I believe you can do it by catching the SL price when the order is submitted then implementing a condition to check if any order was filled at this price. Or if are sure that your positions can be only closed by SL then you can check the position P&L whether negative or not.


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Fri 16 Dec, 2016, 09:31 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Thanks Amine for quick respond.

It's good to see you again! :)

That is a trap over there, because I need this together with BreakEven function. Some closed position will be also positive, and difficult to get this by P/L catcher for different instrument because of slippage and spread.

Anyway it's easy to get if to edit a source code and write some If block and insert a line:

" if(message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_SL)){} . "

Maybe in the future we will get this solution.

By the way, today and 2 days in a row I found that all variables in VJF backtesting that I want to see is NaN

Image


Attachments:
Безымянный.png [82.16 KiB]
Downloaded 309 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: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Fri 16 Dec, 2016, 12:24 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Thanks Illya !
We'll fix this asap ..


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Fri 16 Dec, 2016, 14:19 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Thanks Amine!)


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Fri 16 Dec, 2016, 15:29 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Try this ...
Image


Attachments:
TradeClosedBySL.JPG [80.27 KiB]
Downloaded 306 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: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Fri 16 Dec, 2016, 18:51 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Oh my.

So simple and so great.

I thought to use if P/L > BreakEven_step, to consider a slippage and spread! But this one is much better!

Thanks again Amine!
Have a good weekends! :)


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Sat 17 Dec, 2016, 10:22 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Hello Amin.

I just thought, if last closed position is "My position" therefor LastTradeEvent.SL will be equal to MyPos.SL by any reason, even if it closed by TP.


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Mon 19 Dec, 2016, 11:15 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Oh yes, you're right. Unfortunately my idea is not sufficient :)
You may need to work on SL price Vs Close price and consider slippage :(


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Mon 19 Dec, 2016, 12:10 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Hey Amine!

I found a solution for BE_SL_price

Image
And for regular SL I'll use as you adviced an if block to check negative condition of P/L !

Thanks Amine!

HAve a good day! :)


Attachments:
EMA.png [56.5 KiB]
Downloaded 157 times
BE.png [30.24 KiB]
Downloaded 312 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: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Mon 19 Dec, 2016, 12:23 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Sounds good !
Thanks for the heads-up !


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Mon 19 Dec, 2016, 14:15 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Previous message edited.


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Mon 19 Dec, 2016, 17:00 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
I see, and how BE_Step variable is defined ?


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Mon 19 Dec, 2016, 21:27 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Beg your pardon!

Be_Step (BreakEven_Step) means value in pips. If BE_Step is 0 means BE_price=Postion.OpenPrice
If BE_step= 5 pips, means shift a SL in a +5 pips P/L distance from Postion.OpenPrice .

So Every position that close with P/L <= BE_step in pips means closed by SL.


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Tue 20 Dec, 2016, 14:44 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
I think I got the idea.. just need to see the strategy in vfs format ..
it is actually more or less equivalent to :

catching the SL price when the position is opened, then defining a range of +/- 5pips (slippage risk) around the submitted SL price, then once the position is closed, you check if the execution price is within the previous range.


 
 Post subject: Re: ORDER_CLOSED_BY_SL IN VJF Post rating: 0   New post Posted: Wed 21 Dec, 2016, 14:41 
User avatar

User rating: 6
Joined: Wed 05 Mar, 2014, 12:00
Posts: 116
Location: Ukraine, Odessa
Hi Amine!

It's a some part of one strategy. The method is replicated in TradeEvent section.


Attachments:
part of strategyl.vfs [73.82 KiB]
Downloaded 158 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.
 

Jump to:  

  © 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