This thread is closed.
Trade Manager EA with partial close take profit 17 replies
Looking for EA to close at candle close with profit 0 replies
Profit From Profit-Taking —Scalping the Session Close 21 replies
#property strict #include <stdlib.mqh> input double inp_min_target = 1.00; //Profit Target Minimum input int inp_magic = 0; //Magic number or "0" for ALL of this symbol void OnTick() { if (!close_at_target(inp_min_target)) Print("<!!!> ", ErrorDescription(GetLastError())); } bool close_at_target(double target) { RefreshRates(); for (int i=OrdersTotal()-1; i>=0; --i) { if (order_select(i)) { double profit = OrderProfit() + OrderSwap() + OrderCommission(); if (profit >= inp_min_target) { bool closed = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 10); if (closed) return close_at_target(target); return false; } } } return true; } bool order_select(int index) { bool is_selected = ( OrderSelect(index, SELECT_BY_POS) && OrderSymbol() == Symbol() && (inp_magic == 0 || OrderMagicNumber() == inp_magic) ); return is_selected; }
DislikedTry this #property strict #include <stdlib.mqh> input double inp_min_target = 1.00; //Profit Target Minimum input int inp_magic = 0; //Magic number or "0" for ALL of this symbol void OnTick() { if (!close_at_target(inp_min_target)) Print("<!!!> ", ErrorDescription(GetLastError())); } bool close_at_target(double target) { RefreshRates(); for (int i=OrdersTotal()-1; i>=0; --i) { if (order_select(i)) { double profit = OrderProfit() + OrderSwap() + OrderCommission(); if (profit >= inp_min_target) { bool closed = OrderClose(OrderTicket(), OrderLots(),...Ignored