Tool to autoclose open orders

 
Is there a tool that will allow me to have open orders closed automatically based on their profit value?  I am looking to have any open orders closed at -$50, for example, to protect during a major turn in one direction or the other.  
 
jbouton176: Is there a tool that will allow me to have open orders closed automatically based on their profit value?  I am looking to have any open orders closed at -$50, for example, to protect during a major turn in one direction or the other.  

Yes! Look in the CodeBase or the Market. Search and you shall find it there.

However, you can do that with a normal stop-loss when you place your order. Simply calculate the stoploss size based on the tick value and the volume you wish to use.

 


Fernando Carreiro #:

Yes! Look in the CodeBase or the Market. Search and you shall find it there.

However, you can do that with a normal stop-loss when you place your order. Simply calculate the stoploss size based on the tick value and the volume you wish to use.


I was pretty specific that I want something that will close an order based on the value of the "Profit" column.  I use an EA that trades numerous pairs, so I need a more broad stroke solution than calculating PIP stop losses for each pair and order.  I did look in the market and got quite overwhelmed.
 
Fernando Carreiro #: Simply calculate the stoploss size based on the tick value and the volume you wish to use.

Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk. Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

  1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce, the stop goes below the support.

  2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/PIP but it takes account of the exchange rates of the pair vs. your account currency.)

  3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
              MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum (2017)
              Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
              Lot value calculation off by a factor of 100 - MQL5 programming forum (2019)

  4. You must normalize lots properly and check against min and max.

  5. You must also check FreeMargin to avoid stop out

  6. For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)

Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

 
William Roeder #:

Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk. Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

  1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce, the stop goes below the support.

  2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/PIP but it takes account of the exchange rates of the pair vs. your account currency.)

  3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
              MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum (2017)
              Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
              Lot value calculation off by a factor of 100 - MQL5 programming forum (2019)

  4. You must normalize lots properly and check against min and max.

  5. You must also check FreeMargin to avoid stop out

  6. For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)

Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.

That has nothing to do with my question, but you got your participation trophy.
 
jbouton176 #: That has nothing to do with my question, but you got your participation trophy.

Actually, it has a lot to do with your question. How do you thing that profit or loss is calculated for an open position?

That is why I said that you can easily get the equivalent of closing a position when a certain amount of profit (or loss) in money value is reached. The same is accomplished when dealing with a batch of positions too by calculating the net position for all the open positions.

However, as I have stated before, there are several implementations of such a tool already present in the CodeBase and the Market. Have a look at each one and see which one best fits your needs.

We cannot recommend Market products, but here are two very similar examples from the CodeBase, but there are several more, so do some research:

 
Fernando Carreiro #:

Actually, it has a lot to do with your question. How do you thing that profit or loss is calculated for an open position?

That is why I said that you can easily get the equivalent of closing a position when a certain amount of profit (or loss) in money value is reached. The same is accomplished when dealing with a batch of positions too by calculating the net position for all the open positions.

However, as I have stated before, there are several implementations of such a tool already present in the CodeBase and the Market. Have a look at each one and see which one best fits your needs.

We cannot recommend Market products, but here are two very similar examples from the CodeBase, but there are several more, so do some research:

No, it has nothing to do with my question.  I didn't ask to be educated on something I already understand. I asked if there was a tool that did a specific task and the other guy decided to espouse his wisdom instead of answer a direct question.  Such is the way of the internet, everyone wants to speak but few actually listen.  Thanks for the tips you provided, you were most helpful.
 
jbouton176 #: No, it has nothing to do with my question.  I didn't ask to be educated on something I already understand. I asked if there was a tool that did a specific task and the other guy decided to espouse his wisdom instead of answer a direct question.  Such is the way of the internet, everyone wants to speak but few actually listen.  Thanks for the tips.

I would have to agree and say that you fall into the same category, but you are free to disagree with that statement.

You also stated that you could not find such tools in the CodeBase nor Market, and complained that it was "overwhelming", and so I provided examples (from a 5 second search), yet you don't seem to have tested them out.

So, given that you "already understand" and don't require further education, I will leave it up to you to resolve the issue on your own.

 
jbouton176 #:
No, it has nothing to do with my question.  I didn't ask to be educated on something I already understand. I asked if there was a tool that did a specific task and the other guy decided to espouse his wisdom instead of answer a direct question.  Such is the way of the internet, everyone wants to speak but few actually listen.  Thanks for the tips you provided, you were most helpful.

Never dismiss anyone who tells you what you may well already know. We can always be better at what we do, you could be the worlds leading expert on something but I always listen to other people, as they may well have a fresh perspective on how to finesse your craft better. 

 
TheHonestPrussian #:

Never dismiss anyone who tells you what you may well already know. We can always be better at what we do, you could be the worlds leading expert on something but I always listen to other people, as they may well have a fresh perspective on how to finesse your craft better. 

I dismiss anyone who can't answer a direct question.  Stay on topic or don't respond.
 
jbouton176 #: I dismiss anyone who can't answer a direct question.  Stay on topic or don't respond.

Ok, then here is a totally on topic and direct answer to your query, with no extras.

jbouton176: Is there a tool that will allow me to have open orders closed automatically based on their profit value?  I am looking to have any open orders closed at -$50, for example, to protect during a major turn in one direction or the other.  

Yes!

Reason: