-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor - midnightcowboy: The problem is my take profit value is not in pips.SL/TP is always a price, never PIPs, and it has nothing to do with your want.
- midnightcowboy: i want to do is Move my stop loss to entry when take profit 1 is hit.You opened two orders. When you only have one opened, you know the other must have hit the TP. Move to BE.
-
int counted_bars=IndicatorCounted();
Indicators can not trade. Function fails on EAs.
-
OP = OrderOpenPrice();
You can not use any Trade Functions until you first select an order.
-
int i=0; i<limit; i++;
What do you think that line of code does? -
if(barstemp!=Bars) { barstemp = Bars;
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
New candle - MQL4 programming forum #3 2014.04.04I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum 2011.05.06 -
int obj_total=ObjectsTotal(); for(int i = obj_total - 1; i >= 0; i--) { string label = ObjectName(i); }
What do you think those lines of code do? -
OrderModify(OrderTicket(),OP,(OP + (10*Point())),OrderTakeProfit(),0,Purple);
Check your return codes, and report your errors.
Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Thank you for your comments, you have pointed me in the right direction and now the code does what i wanted it to.
I also made some other changes based on your suggestion, Thanks again man.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
My EA opens two trades, with different take profit values, everything else remains the same. Now what i want to do is Move my stop loss to entry when take profit 1 is hit. The problem is my take profit value is not in pips so i cannot just say to move stop loss to entry when after 50 pips.
takeprofitbuy = (Close[1] + (ATR * a));
So when i'm setting the rules to modify the order i stated that if the Ask price is greater than the Order Open Price + take profit then the order should be modified
and move the stop loss to breakeven. However, as soon as the trade is executed the stop loss moves to breakeven instead of waiting for the first position to close