MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Update to MetaTrader 4 build 735 and Test the VPS for Free

ea not closing open trades at specific time

Back to topics list To post a new topic, please log in or register
avatar
5
igorko 2011.11.07 10:47
 

Hello!

I've made an EA (with debugging help from RaptorUK, thanx for that :) ) that should open and close trades at specific time. Opening works properly, and everything else, but close_all doesn't work at all...

Here is the piece of the code I found online and inserted:

void closeall() {
  double pBid, pAsk;

if (TimeHour(TimeCurrent())==CloseHour && TimeMinute(TimeCurrent())>=CloseMinute) { 
    for (int i=OrdersTotal()-1; i>=0; i--) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
        if (!UseCurrSymbol || OrderSymbol()==Symbol()) {
          if (OrderType()==OP_BUY) {
            pBid=MarketInfo(OrderSymbol(), MODE_BID);
            OrderClose(OrderTicket(), OrderLots(), pBid, Slippage, clCloseBuy);
          }
          if (OrderType()==OP_SELL) {
            pAsk=MarketInfo(OrderSymbol(), MODE_ASK);
            OrderClose(OrderTicket(), OrderLots(), pAsk, Slippage, clCloseSell);
          }
        }
      }
    }
  }
}

In my EA, it doesn't work... I attached the EA so you can have a look on whole code.

Help please...

 
Neural Network Training Using Simplex Optimization
Neural Network Training Using Simplex Optimization
PCWalker | 22 October 2014, 16:06 | Views: 32
Simplex optimization is one of the simplest algorithms available to train a neural network. Understanding how simplex optimization works, and how it compares to the more commonly used back-propagation algorithm, can be a valuable addition to your machine learning skill set. A neural network is basically a complex mathematical function that accepts numeric inputs and generates numeric outputs.
avatar
14160
RaptorUK 2011.11.07 10:56 #
 
You need to test the return code from the OrderClose just like you did with the OrderSend . . . add in some Print statements to see which parts of the code are being executed and which aren't . .
 
avatar
5
igorko 2011.11.08 09:47 #
 

solved :) this part of code that needed to be activated at certain hour to close all orders needed to be called on every tick, and in my code was a continuation of part of the code called when pending orders are opened once in the morning....

print statements didn't show anything, but the lack of them, where they should be, gave me the idea what the problem is ;)

tnx again RaptorUK

 
Back to topics list  

To add comments, please log in or register