Quaisquer perguntas de recém-chegados sobre MQL4 e MQL5, ajuda e discussão sobre algoritmos e códigos - página 1943
Você está perdendo oportunidades de negociação:
- Aplicativos de negociação gratuitos
- 8 000+ sinais para cópia
- Notícias econômicas para análise dos mercados financeiros
Registro
Login
Você concorda com a política do site e com os termos de uso
Se você não tem uma conta, por favor registre-se
função
Estas são tarefas diferentes, em pares diferentes e no mesmo. Em um, com o mesmo lote 2 ordens/posições têm opções divergentes não cruzadas, e cruzadas. preço entre as não cruzadas é perda para ambas, as cruzadas têm lucro somente entre ordens. Acima da abaixo que é perda ou lucro, dependendo da distância para as ordens. Para uma direção entre, um em lucro e outro em prejuízo, acima tanto em lucro quanto em prejuízo.
Deve ser definido de acordo com suas preferências. Se o volume for o mesmo, você deve fechar o mesmo volume. Se não for o mesmo, você deve calcular a quantidade de dinheiro em lucro, a quantidade de perda no dinheiro, calcular a relação entre lucro e perda, multiplicar esta relação pelo número de lotes de uma posição perdedora e fechar esta parte.
É isso mesmo) É exatamente o que eu quero. Para calcular e fechar a parte perdida.
Algum exemplo?
Eu tentei enquanto, fiquei confuso e falhei.
função
É isso mesmo) É exatamente o que eu quero. Calcule e feche a parte perdida.
Algum exemplo?
Experimentei enquanto, fiquei confuso, não funcionava.
Se não estou enganado, estas funções se sobrepõem em uma direção, ou seja, comprar ou vender. Em resumo, precisamos modificá-lo.
//=========================================================================================================================================// // Функция расчета текущего состояния по открытым ордерам // //=========================================================================================================================================// //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double CurrentCondition(string OrdType, string inf) { int Pos = 0; double result = 0, Count = 0, AveragePrice = 0, profit = 0; double LastPriceBuy, LastPriceSell, ProfitBuy, ProfitSell, SumProfit; for(int cnt = 0; cnt < OrdersTotal(); cnt++) { if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) { if(OrderSymbol() == Symbol() && (OrderMagicNumber() == MagicNumber || MagicCheck())) { if(OrderType() == OP_SELL || OrderType() == OP_BUY) { if(inf == "Lpos") { profit = OrderProfit() ; Pos = OrderTicket() ; if(profit > 0 && profit > Lprofit) { Lprofit1 = Lprofit ; Lpos1 = Lpos ; Lprofit = profit ; //макс значение Lpos = Pos ; } if(profit < 0 && profit < Cprofit) { Cprofit = profit ; //мин значение Cpos = Pos ; } } SumProfit += OrderProfit() + OrderSwap() + OrderCommission() ; if(inf == "CurrentDrawdown") result = MathMax((AccountBalance() + AccountCredit() - AccountEquity()) / (AccountBalance() + AccountCredit()) * 100, 0); if(inf == "CurrentUrov" && AccountMargin() > 0) result = AccountEquity() / AccountMargin() * 100 ; if(inf == "TotalOrd") result++ ; if(OrdType == "Buy") { if(OrderType() == OP_BUY) { if(inf == "TotalBuy") result++ ; if(inf == "LastLotBuy") result = OrderLots() ; if(inf == "SumLotBuy") result += OrderLots() ; AveragePrice += OrderOpenPrice() * OrderLots() ; Count += OrderLots() ; LastPriceBuy = OrderOpenPrice() ; ProfitBuy += OrderProfit() + OrderSwap() + OrderCommission() ; if(AveragePrice > 0 && Count > 0) { if(inf == "CalculateAveragePriceBuy") return(NormalizeDouble(AveragePrice / Count, Digits)); } else return(0); } } if(OrdType == "Sell") { if(OrderType() == OP_SELL) { if(inf == "TotalSell") result++ ; if(inf == "LastLotSell") result = OrderLots() ; if(inf == "SumLotSell") result += OrderLots() ; AveragePrice += OrderOpenPrice() * OrderLots() ; Count += OrderLots() ; LastPriceSell = OrderOpenPrice() ; ProfitSell += OrderProfit() + OrderSwap() + OrderCommission(); if(AveragePrice > 0 && Count > 0) { if(inf == "CalculateAveragePriceSell") return(NormalizeDouble(AveragePrice / Count, Digits)); } else return(0); } } } } } } if(inf == "Lpos") return(Lpos) ; //Ордер с наибольшим профитом if(inf == "Cpos") return(Cpos) ; //Ордер с наименьшим профитом if(inf == "LastPriceBuy") return(NormalizeDouble(LastPriceBuy, Digits)) ; if(inf == "LastPriceSell") return(NormalizeDouble(LastPriceSell, Digits)) ; if(inf == "ProfitBuy") return(NormalizeDouble(ProfitBuy, 2)) ; if(inf == "ProfitSell") return(NormalizeDouble(ProfitSell, 2)) ; if(inf == "SumProfit") return(NormalizeDouble(SumProfit, 2)) ; return(result) ; } //=========================================================================================================================================// // Перекрытие ордеров // //=========================================================================================================================================// //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CheckOverlapping() { Lpos = 0; Cpos = 0; Lprofit = 0; Cprofit = 0; Lpos = CurrentCondition("", "Lpos"); Cpos = CurrentCondition("", "Cpos"); if(totalord >= LeadingOrder) { if(Lprofit > 0 && Lprofit1 <= 0 && Cprofit < 0) { if(Lprofit + Cprofit > 0 && (Lprofit + Cprofit) * 100 / Lprofit > ProfitPersent) { Lpos1 = 0; CloseSelectOrder(); } } else if(Lprofit > 0 && Lprofit1 > 0 && totalord > LeadingOrder && Cprofit < 0) { if(Lprofit + Lprofit1 + Cprofit > 0 && (Lprofit + Lprofit1 + Cprofit) * 100 / (Lprofit + Lprofit1) > SecondProfitPersent) CloseSelectOrder(); } } } //=========================================================================================================================================// // Перекрытие ордеров // //=========================================================================================================================================// //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int CloseSelectOrder() { if(Info) Print("Функция перекрытия ордеров."); int error = 0; int error1 = 0; int error2 = 0; int Result = 0; int Slippage = 2 * MarketInfo(Symbol(), MODE_SPREAD); // ---------------------- последний ----------------------- while(error1 == 0) { RefreshRates(); int i = OrderSelect(Lpos, SELECT_BY_TICKET, MODE_TRADES); if(i != 1) { Print("Ошибка! Невозможно выбрать ордер с наибольшим профитом. Выполнение перекрытия отменено."); return (0); } if(OrderSymbol() == Symbol() && (OrderMagicNumber() == MagicNumber || MagicCheck())) { if(OrderType() == OP_BUY) { error1 = (OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid, Digits), Slippage, Blue)); if(error1 == 1) { if(Info) Print("Лидирующий ордер закрыт успешно."); Sleep(500); } else { Print("Ошибка закрытия лидирующего ордера, повторяем операцию. "); } } // ----------------------------------------------------- if(OrderType() == OP_SELL) { error1 = (OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), Slippage, Red)); if(error1 == 1) { if(Info) Print("Лидирующий ордер закрыт успешно"); Sleep(500); } else { Print("Ошибка закрытия лидирующего ордера, повторяем операцию. "); } } } } // ---------------------- пред последний ----------------------- if(Lpos1 != 0) { while(error2 == 0) { RefreshRates(); i = OrderSelect(Lpos1, SELECT_BY_TICKET, MODE_TRADES); if(i != 1) { Print("Ошибка! Невозможно выбрать пред ордер с наибольшим профитом. Выполнение перекрытия отменено."); return (0); } if(OrderSymbol() == Symbol() && (OrderMagicNumber() == MagicNumber || MagicCheck())) { if(OrderType() == OP_BUY) { error2 = (OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid, Digits), Slippage, Blue)); if(error2 == 1) { if(Info) Print("Пред Лидирующий ордер закрыт успешно."); Sleep(500); } else { Print("Ошибка закрытия пред лидирующего ордера, повторяем операцию. "); } } // ----------------------------------------------------- if(OrderType() == OP_SELL) { error2 = (OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), Slippage, Red)); if(error2 == 1) { if(Info) Print("Пред Лидирующий ордер закрыт успешно"); Sleep(500); } else { Print("Ошибка закрытия Пред лидирующего ордера, повторяем операцию. "); } } } } } // ----------- выбранный (обычно с наименьшим профитом ) ----------- while(error == 0) { RefreshRates(); i = OrderSelect(Cpos, SELECT_BY_TICKET, MODE_TRADES); if(i != 1) { Print("Ошибка! Невозможно выбрать ордер с наименьшим профитом. Выполнение перекрытия отменено."); return (0); } if(OrderSymbol() == Symbol() && (OrderMagicNumber() == MagicNumber || MagicCheck())) { if(OrderType() == OP_BUY) { error = (OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid, Digits), Slippage, Blue)); if(error == 1) { if(Info) Print("Перекрываемый ордер закрыт успешно."); Sleep(500); } else { Print("Ошибка закрытия перекрываемого ордера, повторяем операцию. "); } } // -------------------------------------------------- if(OrderType() == OP_SELL) { error = (OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), Slippage, Red)); if(error == 1) { if(Info) Print("Перекрываемый ордер закрыт успешно."); Sleep(500); } else { Print("Ошибка закрытия перекрываемого ордера, повторяем операцию. "); } } } } Result = 1; return (Result); }É isso mesmo) É exatamente o que eu quero. Calcule e feche a parte perdida.
Algum exemplo?
Tentou enquanto, ficou confuso, não funcionou.
O que há de errado com o véu? Você precisa do código. Eu simplesmente não tenho tais problemas e, francamente, não acho que tal abordagem à administração do dinheiro seja sensata.
Por favor, informe como carregar 2 indicadores iguais com as mesmas intenções em uma janela no MT5. Eu tentei INDICATOR_SHORTNAME, eu deveria mudá-lo cada vez que o inicio. Talvez haja outra maneira?
Obtenha outro input inútil e mude-o.
Por que você precisa de um véu? O que há de errado com ele? Você precisa de um código. Eu simplesmente não tenho este tipo de problema. e francamente não acho que esta abordagem seja sábia para um gerente de dinheiro.
Boa tarde. Eu li sobre o vail. Não posso acrescentar ou subtrair.
Não posso dizer nada sobre gestão de dinheiro. Ainda não experimentei.
Anexei a versão mais recente. Mas eu já estraguei tudo para mim)
Order1(2) the selected order's profit
Order1(3) the selected order's lot
Obtenha outro input inútil e mude-o.
E sem intervenção manual? No mt4 eu tenho indicadores que são colocados um em cima do outro, e não sei por quê. Eu gostaria que fosse o mesmo no mt5, e em geral gostaria de entender do que depende.
E sem intervenção manual? No mt4 eu tenho indicadores que se sobrepõem e não sei por quê. Eu gostaria de fazer o mesmo no mt5, e em geral gostaria de entender do que depende.
Foi ainda mais interessante no MT3. Eu tenho a distribuição, você a quer?