Discussion of article "Using limit orders instead of Take Profit without changing the EA's original code" - page 5

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi dear
i try to find the way to defined the special Take Profit for my expert that i started to write it. your text was useful for me but i could not correct mine, so , if it is possible to you , please guide me. my TP plane is: when set the for example Buy in chart and it go in right way and profit, TP value move to maximum profit point, so when the trend turn change the straight to down way , TP value placed in 70 percent of maximum profit. below cod is the code which i write. please let me know m wrongs and help me to correct them.
double BuyPipsProfit,SellPipsProfit,BuyProfitLevel,SellProfitLevel;
double TP_Buy=0;
double TP_Sell=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
BuyPipsProfit= Ask-(double)OrderOpenPrice() ;
SellPipsProfit= (double)OrderOpenPrice()-Bid;
BuyProfitLevel= BuyPipsProfit*.7;
SellProfitLevel= SellPipsProfit*.7;
TP_Buy = (50*Point)+ ((OrderOpenPrice()+ BuyProfitLevel)*Point);
TP_Sell= (50*Point)+ ((OrderOpenPrice()+ SellProfitLevel)*Point);
}
}
Hello,
Don't work.
LimitTakeProfit.mqh error:
Thank you.
@MetaQuotes, thanks for this code!
I have found a bug in this function and give my humble solution:
If we have 2 TP and the first one have been closed, the second one will be WRONG closed here:
Why? Because when searching for the first TP in this function:
We change the selected position, so, in the loop:
We use the wrong position to evaluate second TP here:
Causing the second TP to be closed! My fix is:
Thanks again!
Did you use the original code or did you add the code to your advisor?
I've never made it work.
Good afternoon @Dmitriy Gizlyk, Could you help with this problem? I've tried a lot of things but I can't get out of this error. If you can help, thank you.
Hi, You can't use this file if you use manual trading. It is for use in EA.
Regards, Dmitry.
Thanks for replying Dmitriy! Do you know if there is another way to do manual trading?