Experts: Opening and Сlosing on time v2

 

Opening and Сlosing on time v2:

The Expert Advisor opens and closes at a certain time comparing two iMA indicators having different periods. A trade having a specified volume is opened at a specified symbol. Setting Stop Loss and Take Profit. Select position type: Buy or Sell.

Author: Vladimir Karputov

 
Is there any possibility to remove the true/false parameter? So that it makes a decision to open a Buy or Sell position only on the basis of MA position
 
Jamal32:
Is there any possibility to remove the true/false parameter? So that it makes a decision to open a Buy or Sell position only on the basis of the MA position

I suggest this variant: instead of true/false I will insert an enumeration

//+------------------------------------------------------------------+
//| Enum Trade|
//+------------------------------------------------------------------+
enum ENUM_TRADE
  {
   buy=0,         // only Buy
   sell=1,        // only Sell
   buy_and_sell=2,// Buy and Sell
  };

so it will be possible to choose three trading options

  1. only Buy
  2. only Sell
  3. and Buy and Sell.
What do you think?

 
Just what the doctor ordered)))
 
Jamal32:
Just what the doctor ordered)))

Please wait for the publication of version 2.002 (the code will be changed to version 2.002 after verification).

 
Vladimir Karputov:

Please wait for the publication of version 2.002 (the code will be changed to version 2.002 after verification).

Thank you very much!
 
Jahmal32:
I stopped opening trades. Although in the strategy tester everything shows perfectly and strictly in time. Do you know what can be the problem?

First of all, check the "Journal" tab of the terminal - are there no messages there?

 
Vladimir Karputov:

First of all, check the "Log" tab of the terminal - are there no messages there?

I checked the first thing, there are no errors. I think I figured it out - when installing the robot on the chart in the field where the volume is specified, it is necessary to specify a number with a dot, even if the lot is whole (i.e. "1.0").

 
Jahmal32:

I checked the first thing, no errors. I think I figured it out - when installing the robot on the chart, in the field where the volume is specified, it is necessary to specify a number with a dot, even if the lot is whole (i.e. "1.0")

If you specify the wrong volume, there will be an error in OnInit() and the Expert Advisor will be unloaded from the chart.

 
Vladimir Karputov:

First of all, check the "Log" tab of the terminal - are there no messages there?

After all, it is not a matter of specifying the number of lots. In order for the robot to open a position, it is necessary to restart the terminal and switch on automatic trading again. But now there is another problem - it does not close the open position. There are no error messages in the log.

 
Jahmal32:

However, it is not a matter of specifying the number of lots. In order for the robot to open a position, it is necessary to restart the terminal and switch on automatic trading again. But now there is another problem - it does not close an open position. There are no error messages in the log.

Restarting is definitely unnecessary.