Dukascopy
 
 
Wiki JStore Search Login

need expert closing all orders with specific profit
 Post subject: need expert closing all orders with specific profit Post rating: 0   New post Posted: Fri 16 Sep, 2016, 08:14 
User avatar

User rating: 0
Joined: Fri 16 Sep, 2016, 08:12
Posts: 2
Location: Egypt, tanta
dear,
i want an expert closing all open trades when all orders profit reach a specific amount like 200 $
can anyone help me with that.
thanks


 
 Post subject: Re: need expert closing all orders with specific profit Post rating: 0   New post Posted: Fri 16 Sep, 2016, 11:12 
Visual JForex expert at Dukascopy
User avatar

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

I've had a similar request in the past for a strategy that monitors profit and loss in percentage of the equity. The idea is to set the "Profit" and Loss in percentage when you start the strategy and once any of these levels reached, the strategy closes all the open positions.
Please test and let us know if any question araises
Cheers


Attachments:
Equitymonitoring.vfs [32 KiB]
Downloaded 207 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 expert closing all orders with specific profit Post rating: 0   New post Posted: Fri 16 Sep, 2016, 14:58 
User avatar

User rating: 0
Joined: Fri 16 Sep, 2016, 08:12
Posts: 2
Location: Egypt, tanta
amine_chourou wrote:
HI !

I've had a similar request in the past for a strategy that monitors profit and loss in percentage of the equity. The idea is to set the "Profit" and Loss in percentage when you start the strategy and once any of these levels reached, the strategy closes all the open positions.
Please test and let us know if any question araises
Cheers


thanks i will try it
but i have a question in strategy parameter default loss is 0.1 is this mean 0.1% of equity??
(ex if account balance is 1000 $ losses will be 1 $??)


 
 Post subject: Re: need expert closing all orders with specific profit Post rating: 0   New post Posted: Mon 19 Sep, 2016, 07:53 
Visual JForex expert at Dukascopy
User avatar

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


No, it is actually 10% & 15% for 0.1 and 0.15


 
 Post subject: Re: need expert closing all orders with specific profit Post rating: 0   New post Posted: Thu 22 Sep, 2016, 23:10 
User avatar

User rating: 0
Joined: Thu 05 Nov, 2015, 22:29
Posts: 15
Location: ItalyItaly
amine_chourou wrote:
HI !

I've had a similar request in the past for a strategy that monitors profit and loss in percentage of the equity. The idea is to set the "Profit" and Loss in percentage when you start the strategy and once any of these levels reached, the strategy closes all the open positions.
Please test and let us know if any question araises
Cheers


Hi to all! Hi Amine!
To my strategy I thought of a solution of this type:
Image
At TradeEvent level I created the "ProfitTarget" variable which i imposed the profit value and the variable "MyAmount" which is the sum of "Equity" and "ProfitTarget". Then there is a sequence that reaches the profit value closes all open positions and pending orders placed by my strategy so it should stop.
Unfortunately, the profit value reached is not detected and no position or pending order in progress will be canceled but the strategy continues his run as if nothing happened.
In fact I would like that the strategy would go in looping, which is that the achievement of ProfitTarget all open orders and pending were closed but that the strategy is not interrupted but automatically restart.

Can you help me?

Thanks to all!


 
 Post subject: Re: need expert closing all orders with specific profit Post rating: 0   New post Posted: Thu 02 Apr, 2020, 03:51 

User rating: 0
Joined: Thu 18 Oct, 2018, 15:37
Posts: 2
Location: Canada,
Hello to anyone finding this!

I had been looking for something exactly like this and was not familiar enough with Visual JForex to know if it was possible. It turns out to be pretty simple. This strategy posted here is for both loss and profit. I wanted positions closed and pending orders cancelled only if a profit target for the account was hit. My stop loss orders would take care of the losses. I modified the strategy to eliminate the loss monitoring and also to close all pending orders, not just open positions. That is straight forward enough, but I was curious as to why Amine had the logic of setting SOB to true when an order was closed and using that as trigger to set the new profit target on the next tick. I had posted this question but never got a response. For my purposes, that would have created some unwanted results. It also seems like it would have not worked until at least one position was closed, but I couldn't confirm this.

Anyway, I just wanted to let anyone else new that comes across this know what I did and that it works perfectly. He had the If block at the beginning flowing to the rest of the strategy if the number of open positions was zero or greater than zero. That seemed unnecessary since it will always be zero or greater than zero. I suspect he was using it differently at an earlier point, then eliminated some other logic and left the If block in there. I simply used that If block to set my profit target and eliminated the whole On Trade trigger and SOB variable completely. If there are no open positions On Tick, I take that opportunity to set the SOB_Equity to equal Equity at that point. If open positions are greater than zero, logic goes the other way to Position Viewer. Out of Position Viewer flows the calculation to get Profit_Equity_Level based on the Profit variable that you set when you start the strategy (0.1 for 10% profit, 0.01 for 1%, etc.). That's followed by the If block to determine when Equity reaches that target SOB_Equity that was set before any positions were opened. When it does, the final block is reached closing all positions and orders.

Most of you will know all this, but if someone comes across this someday like I did, hopefully this will help. I was thinking before I found this thread that I would need to monitor overall account P/L with Position Viewer. I'm still not sure if that is possible, but given my first week's experience, that wouldn't have been optimal. What happened is I had 8 different open positions. At one point, all 8 positions were negative. Hard to be that wrong! Finally, one hit its Stop Loss. In the original strategy posted in this thread, that would have reset my profit target lower. As it was, my original profit target stayed intact. The remaining positions then started to move positive. If I was only monitoring P/L as a percentage of Equity, my positions would have closed somewhere around break-even when the stopped out trade is considered. As it was, they continued higher in a spike and closed out with my original profit target for the week. This all happened in about 10 minutes while I was in the shower. The strategy worked exactly how I had wanted.


 

Jump to:  

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