"artificial order" partial closing question.

 

Hello MQL4 community,

I am trying to conjure up a solution to create an "artificial order" and partially close this artificial order just as my EA would partially close a real order.

I want to do this because I wish to see if the last "artificial order" closed in netted profit or netted loss, so I can decide if a real order should be submitted next via my EA.

Has any coder had experience with this?

Does any coder have any thoughts or ideas that he/she wishes to share regarding this task?

Thank you.

 
WhooDoo22:

Hello MQL4 community,

I am trying to conjure up a solution to create an "artificial order" and partially close this artificial order just as my EA would partially close a real order.

I want to do this because I wish to see if the last "artificial order" closed in netted profit or netted loss, so I can decide if a real order should be submitted next via my EA.

Has any coder had experience with this?

Does any coder have any thoughts or ideas that he/she wishes to share regarding this task?

Just keep track of what Order you would have placed and at what price  . . .  then when you would theoretically have closed it you can calculate what the profit or loss would have been.
 

I figured it out in my head. It took me a little while, but I figured it out.

I would simply store all values where iMA crosses would occur, subtract or add the values according to where they were plotted on the chart (above or below the iMA crossover where i would originally open sell or buy) throw in the spread with the calculations and *poof* I now know if the order would have profited or lost.

Thank you Simon.

 
Most brokers have variable spreads. Better remember the open price (Ask/Bid) and the close price (Bid/Ask)
 

William,

If this is the case, a variable spread value would be used in the calculations instead of a fixed value.

Makes nough' sense to me. What do you think?

Thank you.

Reason: