hi guys.
i have "2014.03.31 08:16:38.149 2009.01.02 08:01 TheTurtleTradingChannel_Strict EURUSD,M15: 2 parameter for SetIndexBuffer function must be array" this error message, while i was doing backtest.
this issue is only for buy position but sell position works fine without no error.
can anybody help me or explain me what's that error?
thx guys.
Post the SRC code
Post the SRC code
//+------------------------------------------------------------------+ //| Expert Advisor for MetaTrader 4 | //| version 1 | //| Copyright 2012 Kay | //| EA Conversion by Kay | //+------------------------------------------------------------------+ //| VERSION HISTORY | //| 1.0 - Initial release. | //+------------------------------------------------------------------+ //EXTERNAL VARIABLES extern bool CompoundGrowth = false; extern double lots = 1; extern double Lots; extern int risk_percent = 15; // risk caculte by percentage. extern int MaxOrder = 2; // extern int TP = 100; extern int SL = 150; bool bresult, sresult; extern double MaxSpread = 50; // set max spread to allowed. extern string note_period = "1=last candle, 2=current candle"; extern int period = 1; //INTERNAL VARIABLES int i; int ticket; int ticket2; int slippage=2; bool tradinghours = false; bool weekendhours = false; bool firstdayopen = false; bool nonfarm = false; bool spread_check = false; int percent_base = 23; int Lotsdevide; string cycle; int input_index_value = "2147483647"; string state = "wait"; string buy01; string buy02; string sell01; string sell02; //INITIALISATION int init() { } //MAIN ROUTINE int start() { //COMPOUND GROWTH if(CompoundGrowth) { Lots=0; Lotsdevide = (100 - risk_percent) * percent_base; double Thousands = AccountBalance() / Lotsdevide; //double RoundDown = MathFloor(Thousands); //if (RoundDown < 1) { RoundDown =1; } Lots= NormalizeDouble(lots * Thousands,2); } if(Lots < 0.1) { Lots =0.1; } //Open Position string test = iCustom(Symbol(),0,"CycleIdentifier",1,1); string test2 = iCustom(Symbol(),0,"CycleIdentifier",2,1); //Comment("\n", test, "\n", test2); if (test != "0") { //Alert("test ok"); cycle = "buy"; } //Comment("\n", "buy: " ,cycle_buy, "\n", "sell: ", cycle_sell); else if (test2 != "0") { //Alert("test2 ok"); cycle = "sell"; } else { cycle = "not ready"; } //Comment("\n", "buy: ", cycle_buy, "\n", "sell: ", cycle_sell); string ttl01_test01 = iCustom(Symbol(),0,"TheTurtleTradingChannel",4,period); string ttl01_test02 = iCustom(Symbol(),0,"TheTurtleTradingChannel",5,period); string ttl02_test01 = iCustom(Symbol(),0,"TheTurtleTradingChannel_Strict",4,period); string ttl02_test02 = iCustom(Symbol(),0,"TheTurtleTradingChannel_Strict",5,period); //Comment("\n", "t1_01: ", ttl01_test01, "\n", "t1_02: ", ttl01_test02, "\n", "t2_01: ", ttl02_test01, "\n", "t2_02: ", ttl02_test02); if (cycle == "buy") { if (ttl01_test01 != input_index_value && ttl02_test01 != input_index_value) { state = "ready_buy"; } else { state = "wait"; } } else if (cycle == "sell") { if(ttl01_test02 != input_index_value && ttl02_test02 != input_index_value) { state = "ready_sell"; } else { state = "wait"; } } // check max spread if(MarketInfo(Symbol(),MODE_SPREAD) < MaxSpread) { spread_check = true; } else { spread_check = false; } //print all conditions. if(ttl01_test01 != input_index_value) { buy01 = "on"; } else { buy01 = "off"; } if(ttl02_test01 != input_index_value) { buy02 = "on"; } else { buy02 = "off"; } if(ttl01_test02 != input_index_value) { sell01 = "on"; } else { sell01 = "off"; } if(ttl02_test02 != input_index_value) { sell02 = "on"; } else { sell02 = "off"; } Comment("\n", "cycle= ", cycle, "\n", "buy01: ", buy01, "\n", "buy02: ", buy02, "\n", "sell01: ", sell01, "\n", "sell02: ", sell02, "\n", "state: ", state ); // positioning orders if (!OrdersTotal() > 0) { if(state == "ready_buy" && spread_check) { OpenBuy(); } if(state == "ready_sell" && spread_check) { //OpenSell(); } } // profit check if(OrdersTotal() > 0) { double profit = OrderProfit(); double total_profit = profit / Lots; for(int i=0;i<OrdersTotal();i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break; if(OrderSymbol() == Symbol()) { if(OrderType()==OP_BUY) { if(total_profit >= TP) { CloseAll(); Alert("Buy order closed PROFIT"); } else if(total_profit <= -SL) { CloseAll(); Alert("Buy order closed STOP"); } } if(OrderType()==OP_SELL) { if(total_profit >= TP) { CloseAll(); Alert("Sell order closed PROFIT"); } else if(total_profit <= -SL) { CloseAll(); Alert("Sell order clesed STOP"); } } } } } } int OpenSell() { if(OrdersTotal() < MaxOrder) { ticket=OrderSend(Symbol(),OP_SELL,Lots,MarketInfo(Symbol(), MODE_BID),slippage,0,0,"",Symbol(),0,Orange); if(ticket>0) { Print("Sell Order Opened :", OrderOpenPrice() + " Symbol :", Symbol() + " Magic :", OrderMagicNumber()); } else {Print("Sell Order Failed :", GetLastError());} Alert("posiotion opened"); Sleep(500); PlaySound("news.wav"); } } int OpenBuy() { if(OrdersTotal() < MaxOrder) { ticket=OrderSend(Symbol(),OP_BUY,Lots,MarketInfo(Symbol(), MODE_ASK),slippage,0,0,"",Symbol(),0,DodgerBlue); if(ticket>0) { Print("Buy Order Opened :", OrderOpenPrice() + " Symbol :", Symbol() + " Magic :", OrderMagicNumber()); } else {Print("Buy Order Failed :", GetLastError());} Alert("position opened"); Sleep(500); PlaySound("news.wav"); } } int CloseAll() { int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; switch(type) { //Close opened long positions case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); break; //Close opened short positions case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); Alert("All positions closed"); Sleep(500); PlaySound("news.wav"); } if(result == false) { Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() ); Sleep(3000); } } return(0); }
the error pertains to your indicator. care to post its src code?
this warning ==> "the return value of 'OrderSelect' function should be checked"
is giving me concern. how do i get rid of this warning? what is causing it in the new build of mt4?
You just need to write ..
If(!OrderSelect.....){ }
Something like that ...
this warning ==> "the return value of 'OrderSelect' function should be checked"
is giving me concern. how do i get rid of this warning? what is causing it in the new build of mt4?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi guys.
i have "2014.03.31 08:16:38.149 2009.01.02 08:01 TheTurtleTradingChannel_Strict EURUSD,M15: 2 parameter for SetIndexBuffer function must be array" this error message, while i was doing backtest.
this issue is only for buy position but sell position works fine without no error.
can anybody help me or explain me what's that error?
thx guys.