teamlabs:
Hi guys,
I am newbie and try to run an EA in a rangebars chart but this hangs after a while. it opens 1 position and that's all. Nothing more. It does not even close it. Some people claim that EA's don't work at all with range bars. If this is the case then rangebars and renko are useless. Is this the case? If not, please I would appreciate any help.
Yes, EAs do work with rangebars and renkos. I trade off renko's all the time.
So not sure what your problem is, without seeing code, but keep at it. They do work.davidb_012:
Yes, EAs do work with rangebars and renkos. I trade off renko's all the time.
So not sure what your problem is, without seeing code, but keep at it. They do work.Hi Davidb_012. Thnk you very much for your prompt answer. I would appreciate if you could have a look in my code for any suggestions since I need your help or any help from other fellows. Thanks again
//+------------------------------------------------------------------+ //| TestOfflineEA.mq4 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" extern double stopLoss = 100; extern double limit = 100; extern double Lots = 0.1; int ticket; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { start(); return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { while (!IsStopped()) { RefreshRates(); double MASlow = iMA(NULL,0,18,0,MODE_SMA,PRICE_CLOSE,1); double MAFast = iMA(NULL,0,5,0,MODE_SMA,PRICE_CLOSE,1); double MASlowPrev = iMA(NULL,0,18,0,MODE_SMA,PRICE_CLOSE,2); double MAFastPrev = iMA(NULL,0,5,0,MODE_SMA,PRICE_CLOSE,2); int total = OrdersTotal(); int order_type = -1; int order_buy = -10; int order_sell = -100; int last_trade=OrdersTotal(); int last_ticket = 0; if(last_trade>0) { if(OrderSelect(last_trade-1,SELECT_BY_POS,MODE_TRADES)==true) { if(OrderType() == OP_BUY){ order_type = order_buy; } if(OrderType() == OP_SELL){ order_type = order_sell; } last_ticket = OrderTicket(); } } if(MAFast>MASlow && MAFastPrev<=MASlowPrev){ if(order_type == order_sell){ Print("There is an open order"); Print("Last ticket: "+last_ticket); if(OrderClose(last_ticket,Lots,Ask,3,Red) == true){ Print("Last Order closed succesfully"); } else{ Print("Error closing last order : ",GetLastError()); } } //if(history_order_type!= history_order_buy){ ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-stopLoss*Point,Bid+limit*Point,"EA1",16030,0,Green); Print("Ticket: "+ticket); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened for indicator value > : ",OrderOpenPrice()); } else{ Print("Error opening BUY order : ",GetLastError()); } } if(MAFast<MASlow && MAFastPrev>=MASlowPrev){ if(order_type == order_buy){ Print("There is an open order"); Print("Last ticket: "+last_ticket); if(OrderClose(last_ticket,Lots,Ask,3,Red) == true){ Print("Last Order closed succesfully"); } else{ Print("Error closing last order : ",GetLastError()); } } //if(history_order_type!= history_order_buy){ ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-stopLoss*Point,Bid+limit*Point,"EA1",16030,0,Green); Print("Ticket: "+ticket); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened for indicator value > : ",OrderOpenPrice()); } else{ Print("Error opening BUY order : ",GetLastError()); } } Sleep(1000); } return(0); } //+------------------------------------------------------------------+. Thanks again
teamlabs:
Hi Davidb_012. Thnk you very much for your prompt answer. I would appreciate if you could have a look in my code for any suggestions since I need your help or any help from other fellows. Thanks again. Thanks again
Hi Davidb_012. Thnk you very much for your prompt answer. I would appreciate if you could have a look in my code for any suggestions since I need your help or any help from other fellows. Thanks again. Thanks again
int order_type = -1; int order_buy = -10; int order_sell = -100; .............. order_type = order_buy; ....... order_type = order_sell; .......... if(order_type == order_sell) //>> this condition is never successfull, so orderclose will never be called...Check help file for values of OP_BUY & OP_SELL
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys,
I am newbie and try to run an EA in a rangebars chart but this hangs after a while. it opens 1 position and that's all. Nothing more. It does not even close it. Some people claim that EA's don't work at all with range bars. If this is the case then rangebars and renko are useless. Is this the case? If not, please I would appreciate any help.