OrderModify error 4108 after partial profit taking - page 2

 
Daniel Cioca #: Not necessary… should be unique for the order… MN should be computed in the EA code … like for example use instrument name to compute MN … 

If you make the magic number unique to each order then you defeat the purpose of the magic number to allow the EA to track its own orders even after it restarts or crashes.

Anyway, the best solutions have already been given —

  • modify the stops before the partial close, or ...
  • multiple orders with different profit targets.
 
Fernando Carreiro #:


Anyway, the best solutions have already been given —

  • modify the stops before the partial close, or ...
  • multiple orders with different profit targets.
Or…
Use a Magic Number …. 😁
 
Daniel Cioca #: Or… Use a Magic Number …. 😁
No, we have already explained that is not an appropriate solution, because of your misunderstanding of the proper use of the magic number. Please don't insist.
 
Fernando Carreiro #:
No, we have already explained that is not an appropriate solution, because of your misunderstanding of the proper use of the magic number. Please don't insist.
Ok… so if I compute a MN for the instrument, and timeframe and make it unique for the order and EA will be able to recognize only orders sent from this chart, would you agree that is better?Because is unique , it is computed one time, and this code can be used every time . And using this MN can I take 1000 partials if I want? Yes I can , because my EA will search for that MN and do with that order whatever I want … would that be acceptable to you? If I move the stops once… and I want another partial… what do I do? Move again the stops? Or if I want move the stops based on ATR… and then take partials… what do I do? My question is, what do I do to call and modify that EA any time I want? I want to take partials at closed bar, but I want to keep the stops where they are … ?? Thanks 
 
Daniel Cioca #Ok… so if I compute a MN for the instrument, and timeframe and make it unique for the order and EA will be able to recognize only orders sent from this chart, would you agree that is better?Because is unique , it is computed one time, and this code can be used every time . And using this MN can I take 1000 partials if I want? Yes I can , because my EA will search for that MN and do with that order whatever I want … would that be acceptable to you? If I move the stops once… and I want another partial… what do I do? Move again the stops? Or if I want move the stops based on ATR… and then take partials… what do I do? My question is, what do I do to call and modify that EA any time I want? I want to take partials at closed bar, but I want to keep the stops where they are … ?? Thanks 

Lets see. My solution:

  • Simply swaps the lines of code. No hassle, no fuss. Just swap the blocks.

Your solution:

  • More code to calculate special magic number.
  • More code to loop over all open orders to find specific magic number.
  • If the EA crashes, you no longer have the variable so you no longer know it, so ...
  • More code to save it to global terminal variable and more code to retrieve it in case of crash.

So, you ask — is that acceptable to me?

No, obviously not! It is inefficient, and needs much more code.

Why convolute and complicate things when something else is so much simpler?

 
Fernando Carreiro #:

Lets see. My solution:

  • Simply swaps the lines of code. No hassle, no fuss. Just swap the blocks.

Your solution:

  • More code to calculate special magic number.
  • More code to loop over all open orders to find specific magic number.
  • If the EA crashes, you no longer have the variable so you no longer know it, so ...
  • More code to save it to global terminal variable and more code to retrieve it in case of crash.

So, you ask — is that acceptable to me?

No, obviously not! It is inefficient, and needs much more code.

Why convolute and complicate things when something else is so much simpler?

  An you take 10 partials like this? 
 
Daniel Cioca # An you take 10 partials like this? 

Yes, no problem! Several of my EAs, use multiple partial closes proportional to how the position progresses, with just a single magic number for all orders for that EA.

How do I do it? By simply applying normal logic and maths about the open positions (individually and as a batch), according to the strategy being used.

The art of efficiency is doing things in simple terms. Just keep things simple and clean.

 
Fernando Carreiro #:

Yes, no problem! Several of my EAs, use multiple partial closes proportional to how the position progresses, with just a single magic number for all orders for that EA.

How do I do it? By simply applying normal logic and maths about the open positions (individually and as a batch), according to the strategy being used.

The art of efficiency is doing things in simple terms. Just keep things simple and clean.

👍
Reason: