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
Bem, não. Não é o meu caso. Em primeiro lugar, tenho menos de 99 Consultores Especialistas. Em segundo lugar, não estou planejando trabalhar por muito tempo - reiniciar e alertar dentro de uma hora.
Então, você pode dar uma olhada no especialista?
O Conselheiro Especialista que dei acima é uma idéia melhor. O código é muito mais simples lá. E não há indicadores.
Quark.
// MT4 tested #include "mylib.mq4" extern double dBuyLevel; extern double dSellLevel; extern double dStopLoss; extern double dTrailingStop; extern double dTakeProfit; extern int nNocInterval; extern double dNocRange; extern int nNocMa; // ------ datetime timePrev = 0; int nSlip = 5; double dTp = 0; double dProfit = 0; double dInitAmount = 1000; double dLotSize = 0.1; int nNumOfExperts = 5; int nMagic = 0; bool bReportDone = false; bool bUseMm = false; ////////////////// int init () { if(Symbol() == "EURUSD" && Period() == 60) { if(!IsTesting()) { // (0.21,0.94,240,40,0.02,3,240), (0.19,0.82,200,30,0.025,5,200) dBuyLevel = 0.19; // (0.21,0.83,160,27,0.026,4,260), (), () dSellLevel = 0.82; dStopLoss = 230 * Point; dTrailingStop = dStopLoss; dTakeProfit = 0; nNocInterval = 28; dNocRange = 0.024; nNocMa = 6; // Max: 0.19,0.82,230,230,0,28,0.024,6; dd: 653, balance: 6900 } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = /*dTrailingStop * Point;*/dStopLoss; } // bBuy = false; // bSell = false; nMagic = 10; } else if(Symbol() == "EURJPY" && Period() == 60) { if(!IsTesting()) { // (0.17,0.96,120,40,0.01,13) dBuyLevel = 0.17; // balance: 3650, dd: 539 dSellLevel = 0.96; dStopLoss = 120 * Point; dTrailingStop = dStopLoss; dTakeProfit = 0; nNocInterval = 40; dNocRange = 0.01; nNocMa = 13; } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss; } // bBuy = false; // bSell = false; nMagic = 11; } else if(Symbol() == "USDCHF" && Period() == 60) { if(!IsTesting()) { // (0.19,0.82,200,35,0.01,5) dBuyLevel = 0.05; // balance: 6200, dd: 763 dSellLevel = 0.92; // (0.05,092,250,30,0.025,3) dStopLoss = 250 * Point; // balance: 3600, dd: 500 dTrailingStop = dStopLoss; dTakeProfit = 0; // (0.07,0.92, 250,40,0.025,9) // balance: 3500, dd: 362 nNocInterval = 30; dNocRange = 0.025; nNocMa = 3; } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss; } // bBuy = false; // bSell = false; nMagic = 12; } else if(Symbol() == "GBPUSD" && Period() == 60) { if(!IsTesting()) { // (0.21,0.84,250,30,0.01,11) // BUY ONLY: retest!!! dBuyLevel = 0.15; // balance: 6588, dd: 1169 dSellLevel = 0.84; // (0.15,0.86,250,20,0.025,9) // BUY ONLY: retest!!! dStopLoss = 200 * Point; // balance: 3337, dd: 552 dTrailingStop = dStopLoss; dTakeProfit = 0; // (0.15,0.84,200,20,0.025,7) // buy and sell // balance: 4171, dd: 850 nNocInterval = 20; dNocRange = 0.025; // (0.15,0.88,200,20,0.025,9) // buy only? retest nNocMa = 9; // balance: 2895, dd: 424 } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss; } // bBuy = false; // bSell = false; nMagic = 13; } else if(Symbol() == "GBPCHF" && Period() == 60) { if(!IsTesting()) { // (0.11,0.86,280,20,0.025,7) dBuyLevel = 0.11; // balance: 5564, dd: 777 dSellLevel = 0.86; // (0.15,0.84,280,25,0.025,11) dStopLoss = 280 * Point; // balance: 4275, dd: 685 dTrailingStop = dStopLoss; dTakeProfit = 0; // (0.11,0.86,280,25,0.025,9) // balance: 4159, dd: 456 nNocInterval = 25; dNocRange = 0.025; nNocMa = 9; } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss; } // bBuy = false; // bSell = false; nMagic = 14; } else if(Symbol() == "USDJPY" && Period() == 60) { if(!IsTesting()) { // (0.07,0.82,280,25,0.025,3) dBuyLevel = 0.07; // balance: 3764, dd: 527 dSellLevel = 0.82; // (0.07,0.8,160,30,0.025,3) dStopLoss = 280 * Point; // balance: 3297, dd: 491 dTrailingStop = dStopLoss; dTakeProfit = 0; // (0.09, 0.94,280,15,0.025,3) // balance: 2703, dd: 541 nNocInterval = 25; dNocRange = 0.025; nNocMa = 3; } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss; } // bBuy = false; // bSell = false; nMagic = 15; } else if(Symbol() == "AUDUSD" && Period() == 60) { if(!IsTesting()) { // (0.14,0.9,280,40,0.015,11) dBuyLevel = 0.14; // balance: 3834, dd: 468 dSellLevel = 0.9; // (0.13,0.92,240,35,0.01,13) dStopLoss = 280 * Point; // balance: 3463, dd: 303 dTrailingStop = dStopLoss; dTakeProfit = 0; nNocInterval = 40; dNocRange = 0.015; nNocMa = 11; } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = /*dTrailingStop * Point;*/ dStopLoss; } // bBuy = false; // bSell = false; nMagic = 16; } else if(Symbol() == "EURGBP" && Period() == 60) { if(!IsTesting()) { // (0.09,0.84,200,35,0.01,3) dBuyLevel = 0.21; // balance: 2517, dd: 486 dSellLevel = 0.82; // (0.21,0.82,280,40,0.015,3) dStopLoss = 280 * Point; // balance: 2726, dd: 324 dTrailingStop = dStopLoss; dTakeProfit = 0; // (0.21,0.84,160,15,0.01,3) // balance: 2255, dd: 314 nNocInterval = 40; dNocRange = 0.015; nNocMa = 3; } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = dStopLoss; } // bBuy = false; // bSell = false; nMagic = 17; } else if(Symbol() == "USDCAD" && Period() == 60) { if(!IsTesting()) { // (0.05,0.88,280,25,0.015,7) dBuyLevel = 0.07; // balance: 3536, dd: 235 dSellLevel = 0.86; // (0.07,0.86,280,15,0.015,3) dStopLoss = 280 * Point; // balance: 3414, dd: 380 dTrailingStop = dStopLoss; dTakeProfit = 0; nNocInterval = 15; dNocRange = 0.015; nNocMa = 3; } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = dStopLoss; } // bBuy = false; // bSell = false; nMagic = 18; } else if(Symbol() == "EURCHF" && Period() == 60) { if(!IsTesting()) { // (0.17,0.84,280,15,0.01,5) dBuyLevel = 0.17; // balance: 1471, dd: 221 dSellLevel = 0.84; // (0.17,0.88,200,15,0.01,5) dStopLoss = 200 * Point; // balance: 1433, dd: 135 dTrailingStop = dStopLoss; dTakeProfit = 0; nNocInterval = 15; dNocRange = 0.01; nNocMa = 5; } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = dStopLoss; } // bBuy = false; // bSell = false; nMagic = 19; } else if(Symbol() == "EURAUD" && Period() == 60) { if(!IsTesting()) { // (0.05,0.8,240,30,0.025,9) dBuyLevel = 0.05; // balance: , dd: dSellLevel = 0.8; // () dStopLoss = 240 * Point; // balance: , dd: dTrailingStop = dStopLoss; dTakeProfit = 0; nNocInterval = 30; dNocRange = 0.025; nNocMa = 9; } else { dStopLoss = dStopLoss * Point; if(dTakeProfit == 700) dTakeProfit = 0; dTakeProfit = dTakeProfit * Point; dTrailingStop = dStopLoss; } // bBuy = false; // bSell = false; nMagic = 20; } return(0); } // ------ int deinit() { return(0); } // ------ int start() { if(Bars < nNocInterval + nNocMa) return(0); Report("Noc_1", nMagic, bReportDone); // The previous bar just closed bool bIsBarEnd = false; if(timePrev != Time[0]) bIsBarEnd = true; timePrev = Time[0]; if(!bIsBarEnd) return(0); // ------ double dNoc = iCustom(NULL, 0, "_Noc_Ind", nNocInterval, dNocRange, nNocMa, 0, 1); double dNocPrev = iCustom(NULL, 0, "_Noc_Ind", nNocInterval, dNocRange, nNocMa, 0, 2); int nNumOfOpenedOrders = 0; for(int nCnt = 0; nCnt < OrdersTotal(); nCnt++) { OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber() == nMagic) { if(OrderType() <= OP_SELL) nNumOfOpenedOrders++; } } if(bUseMm == true) { dProfit = 0; for(nCnt = 0; nCnt < HistoryTotal(); nCnt++) { OrderSelect(nCnt, SELECT_BY_POS, MODE_HISTORY); if(OrderMagicNumber() == nMagic && OrderType() <= OP_SELL) { dProfit += OrderProfit(); } } } if(nNumOfOpenedOrders == 0) { if(dNocPrev <= dBuyLevel && dNoc >= dBuyLevel) Buy(); else if(dNocPrev >= dSellLevel && dNoc <= dSellLevel) Sell(); return(0); } else { for(nCnt = 0; nCnt < OrdersTotal(); nCnt++) { OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber() == nMagic) { if(OrderType() == OP_BUY) { if(dNocPrev >= dSellLevel && dNoc <= dSellLevel) { OrderClose(OrderTicket(), OrderLots(), Bid, nSlip, Aqua); Sell(); return(0); } } else if(OrderType() == OP_SELL) { if(dNocPrev <= dBuyLevel && dNoc >= dBuyLevel) { OrderClose(OrderTicket(), OrderLots(), Ask, nSlip, OrangeRed); Buy(); return(0); } } } } } // ------ for(nCnt = 0; nCnt < OrdersTotal(); nCnt++) { OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber() == nMagic && OrderSymbol() == Symbol()) { if(OrderType() == OP_BUY)// && Bid - OrderOpenPrice() > dStopLoss) { if(OrderStopLoss() < Bid - dTrailingStop - 5 * Point) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - dTrailingStop, OrderTakeProfit(), 0, Aqua); return(0); } } if(OrderType() == OP_SELL)// && OrderOpenPrice() - Ask > dStopLoss) { if(OrderStopLoss() > Ask + dTrailingStop + 5 * Point)// || OrderStopLoss() == 0) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + dTrailingStop, OrderTakeProfit(), 0, OrangeRed); return(0); } } } } return(0); } // ------ void Sell() { if(AccountFreeMargin() < 500) return; dLotSize = GetLotSize(); if(dTakeProfit == 0) dTp = 0; else dTp = Bid - dTakeProfit; OrderSend(Symbol(), OP_SELL, dLotSize, Bid, nSlip, Bid + dStopLoss, dTp, "Noc_1", nMagic, 0, OrangeRed); } // ------ void Buy() { if(AccountFreeMargin() < 500) return; dLotSize = GetLotSize(); if(dTakeProfit == 0) dTp = 0; else dTp = Ask + dTakeProfit; OrderSend(Symbol(), OP_BUY, dLotSize, Ask, nSlip, Ask - dStopLoss, dTp, "Noc_1", nMagic, 0, Aqua); } // ------ double GetLotSize() { double dLot = 0.1; if(bUseMm) { dLot = (0.1 * dInitAmount + 0.2 * dProfit) / 1000; if(dLot * 2 * dInitAmount > AccountFreeMargin() / nNumOfExperts) dLot = AccountFreeMargin() / (2 * dInitAmount * nNumOfExperts); dLot = MathFloor(dLot * 10) / 10; if(dLot < 0.1) dLot = 0.1; } return(dLot); } // ------ticket=OrderSend(Symbol(),OP_SELLL,Lots,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point, "sell",ExpertMagicNumber,0,Red); if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); return(0); }Os logs são limpos, os pedidos são feitos.
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point, "sell",ExpertMagicNumber,0,Red); if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); return(0); }Os logs são limpos, os pedidos são feitos.
O que posso dizer? Tente meu Conselheiro Especialista, aquele que citei primeiro. Dá um comércio por hora. Normalmente, a segunda troca leva a uma mensagem de erro. Se não houver erro em 24 horas, nem sei...
A primeira vez que abre um pedido de uma vez (ver verificação das condições no início de um bar). Então, se você não tocar nele, no início da próxima hora.
Espero muito que Quark em seu especialista tenha feito asneira. Ainda não posso verificar pessoalmente, escrevendo de um PDA longe do computador. Mas se é MT, então f..., no entanto, silêncio de hussardos!