Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Set stop loss and take profit in MQL4
 Post subject: Set stop loss and take profit in MQL4 Post rating: 0   Post Posted: Wed 03 Nov, 2010, 16:24 

User rating: -
Hi I was using this helpful script in MT4 to manage my take profit and stop losses. I attempted to convert to Jforex, it does close the order when the first take profit is hit, but closes the entire position rather than just a portion of it, and therefore i do not know if the second take profit or the second stop loss ever works since entire position is closed at first target. Any assistance would be appreciated. There really is not a whole lot of material or examples out there so i am having trouble sorting this one out.

Thanks


Attachments:
ManageTPv2_4.mq4 [5.63 KiB]
Downloaded 370 times
ManageTPv2_4.java [6.78 KiB]
Downloaded 371 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: JFOREX-2602 Set stop loss and take profit Post rating: 0   Post Posted: Thu 18 Aug, 2011, 11:07 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Working on it


 
 Post subject: Re: JFOREX-2602 Set stop loss and take profit Post rating: 0   Post Posted: Fri 19 Aug, 2011, 14:43 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We tested your strategy. In all cases when the order close was called, the close amount matched the order total amount, so consequently full position was closed. We also verified that partial close works - by passing only half of the amount to the OrderClose.
Could you please provide a precise case when full close happens instead of a partial close? Please do compare beforehand what is the total amount of the order and what is the close amount.
If you wish to do the partial close in JForex API approach, consider the following snippet:
//partial close all filled orders with half of their amount
for(IOrder order : engine.getOrders()){
   if(order.getState() == IOrder.State.FILLED){
      order.close(order.getAmount() / 2.0);
   }
}
See more in JForex wiki:
https://www.dukascopy.com/wiki/index.php ... ose_Orders


 

Jump to:  

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