Cualquier pregunta de los recién llegados sobre MQL4 y MQL5, ayuda y discusión sobre algoritmos y códigos - página 276
Está perdiendo oportunidades comerciales:
- Aplicaciones de trading gratuitas
- 8 000+ señales para copiar
- Noticias económicas para analizar los mercados financieros
Registro
Entrada
Usted acepta la política del sitio web y las condiciones de uso
Si no tiene cuenta de usuario, regístrese
ZeroMemory (...) inicializa un array de tipo string con un valor NULL
Buenas tardes. Esta es la pregunta. Escrito un EA, adjuntado un trailing stop a él, compilado.......... no funciona:))))). He reiniciado mi ordenador, he ajustado el código fuente y funciona. Comenzó a ajustar a través de los parámetros de entrada, de nuevo no funciona, o más bien cambió una vez, y eso es todo.......... Puede ser que el viento tenga un fallo o que haya metido la pata en algún sitio otra vez. Adjunto el código fuente.
//+------------------------------------------------------------------+ //| test8.mq4 | //| Copyright 2017, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //------------------------------------------------------------------- extern double lots = 0.1; extern int TakeProfit = 100; extern int StopLoss = 50; extern int Magic = 777; extern int Slippage = 3; //------------------------------------------------------------------- extern string TMA = "Параметры индикатора TMA"; extern string TimeFrame = "current time frame"; extern int HalfLength = 56; extern int Price = PRICE_CLOSE; extern double ATRMultiplier = 2.0; extern int ATRPeriod = 100; extern bool Interpolate = true; extern int TrailingStop = 50; extern int TrailingStep = 20; int timeprev = 0; //------------------------------------------------------------------- double PriceHigh, PriceLow, SL ,TP; int ticket; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { if (Digits == 3 || Digits == 5); { TakeProfit *=10; Slippage *=10; TrailingStop *=10; TrailingStep *=10; } return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if (timeprev == Time [0])return; timeprev = Time [0]; PriceHigh = iCustom(NULL, 0, "TMA_Fair", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 1, 0); PriceLow = iCustom(NULL, 0, "TMA_Fair", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 2, 0); if (CountSell() == 0 && Bid >= PriceHigh) { ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, Slippage, 0, 0, "TMA robot", Magic, 0, Red); if (ticket > 0) { TP = NormalizeDouble(Bid - TakeProfit*Point, Digits); SL = NormalizeDouble(Bid + StopLoss*Point, Digits); if (OrderSelect(ticket, SELECT_BY_TICKET)) if(!OrderModify(ticket, OrderOpenPrice(), SL, TP, 0)); Print("Ошибк амодификации ордера на продажу!"); } else Print("Ошибка открытия ордера на продаду!"); } if (CountBuy() == 0 && Ask <= PriceLow) { ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, Slippage, 0, 0, "TMA robot", Magic, 0, Blue); if (ticket > 0) { SL = NormalizeDouble(Ask - StopLoss*Point, Digits); TP = NormalizeDouble(Ask + TakeProfit*Point, Digits); if (OrderSelect(ticket, SELECT_BY_TICKET)) if(!OrderModify(ticket, OrderOpenPrice(), SL, TP, 0)); Print ("Ошибка модификации ордера на покупку!"); } else Print("Ошибка открытия ордера на покупкку!"); } Trailing(); } //+------------------------------------------------------------------+ void Trailing() { for (int i=OrdersTotal() -1; i>=0; i--) { if (OrderSelect (i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY) { if (Bid - OrderOpenPrice() > TrailingStop*Point || OrderStopLoss() == 0) { if (OrderStopLoss() < Bid-(TrailingStop+TrailingStep)*Point || OrderStopLoss() == 0) { if (!OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble (Bid-TrailingStop*Point, Digits), 0, 0)) Print ("Ошибка модификации ордера на покупку!"); } } } if (OrderType() == OP_SELL) { if (OrderOpenPrice() - Ask > TrailingStop*Point || OrderStopLoss() == 0) { if (OrderStopLoss() > Ask + (TrailingStop+TrailingStep)*Point || OrderStopLoss() == 0) { if (!OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble( Ask + TrailingStop*Point, Digits), 0, 0)) Print ("Ошибка модификации ордера на родажу!"); } } } } } } } //+------------------------------------------------------------------+ int CountSell() { int count = 0; for (int trade = OrdersTotal()-1; trade>=0; trade--) { if (OrderSelect(trade, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL) count++; } } return(count); } //----------------------------------------------------------------------------------------------- int CountBuy() { int count = 0; for (int trade = OrdersTotal()-1; trade>=0; trade--) { if (OrderSelect(trade, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_BUY) count++; } } return(count); } //-----------------------------------------------------------------------------------------------Buenas tardes. Mi pregunta es la siguiente.Escribí un EA, adjunté un trailing stop a él, compilado.......... no funciona:))))). Más precisamente el trailing stop funciona, pero el beneficio previamente prescrito no funciona, ¿cuál es la razón?
Buenas tardes. La pregunta es la siguiente. Escrito un EA, adjuntado un trailing stop a él, compilado.......... no funciona:))))) He reiniciado mi ordenador, he ajustado el código fuente y funciona. Comenzó a ajustar a través de los parámetros de entrada, de nuevo no funciona, o más bien cambió una vez, y eso es todo.......... Puede ser que el viento tenga un fallo o que haya metido la pata en algún sitio otra vez. Adjunto el código fuente.
if (timeprev == Time [0]) { timeprev = Time [0]; return;}
sigue sin poner un tic-tac .... Por favor, eche otro vistazo.
sigue sin poner un tic-tac .... Por favor, compruebe de nuevo.
En la función de arrastre se pone el take profit 0 para todas las órdenes, pero al abrirla se pone el take profit correcto.
Por favor, lea la lógica línea por línea,
abrir una orden, establecer un stop y una toma
start trailing stop take 0
sustituye el 0 en la orden final por OrderTakeProfit()
Ahora no pone un semáforo
Ahora no pone un semáforo
Muéstrame el nuevo código.
Mostrar el nuevo código
Te dije claramente que en el trailing ponías 0 en vez de tomar
Marque esta opción.
Por favor, ayúdeme a comparar el precio de la MA en la primera barra con los precios de la MA en las cuatro barras anteriores. Si el precio ha aumentado y la diferencia es mayor que N, rellene el buffer. Estoy tratando de