Experts: 5_8 MACross - page 5

 
Shara1:

Thanks, but in the optimisation window, some lines are red because of this ?

Yes, the red lines are rejected passes.

 
Vladimir Karputov:

Yes, the red lines are rejected passes.

Thanks, I'll test it.

 

Vladimir, for the EA to buy and sell separately, do you need this code ?

//+------------------------------------------------------------------+
//| Determines the expert's trading status. ||
//+------------------------------------------------------------------+
enum ENUM_TRADE_STATE
{
   TRADE_BUY_AND_SELL,              // Buying and selling allowed.
   TRADE_BUY_ONLY,                  // Only purchases are allowed. Sales are prohibited.
   TRADE_SELL_ONLY,                 // Sales only. Purchases are prohibited.
   TRADE_STOP,                      // Trading is prohibited. Immediately close all positions. Do not accept new entry signals.
   TRADE_WAIT,                      // Control over open positions is lost. New signals are ignored. Useful at the moment of news release.
   TRADE_NO_NEW_ENTRY               // Signals for entry are ignored. However, already opened positions are followed according to the trading logic. 
};

If yes, please tell me after which line it should be inserted into the code.

 
I'm sorry, but I've already given you a lot of answers. You can take it from here.
 

Vladimir, I think I've figured it out. I added two lines:

#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>  
#include <Trade\AccountInfo.mqh>
CPositionInfo  m_position;                   // trade position object
CTrade         m_trade;                      // trading object
CSymbolInfo    m_symbol;                     // symbol info object
CAccountInfo   m_account;                    // account info wrapper
//---
input bool     InpCanOpenBUY                       = true;              // Open BUY
input bool     InpCanOpenSELL                      = true;              // Open SELL
input double   Lots=0.1;
input ushort   StopLoss=0;
input int      TrailingStop=0;
input ushort   TakeProfit=40;
input int      mafastperiod=5;
input int      mafastshift=-1;
input ENUM_MA_METHOD    mafastmethod=MODE_EMA;
input ENUM_APPLIED_PRICE mafastprice=PRICE_CLOSE;
input int      maslowperiod=8;
input int      maslowshift=0;
input ENUM_MA_METHOD maslowmethod=MODE_EMA;
input ENUM_APPLIED_PRICE maslowprice=PRICE_OPEN;
//---

I got this in your Expert Advisor:


Did I do it right?

 
Shara1:

Vladimir, I think I've figured it out. I added two lines:

I got this in your Expert Advisor:


Did I do it right?

Yes, you have inserted the input parameters correctly. Now you need to add the code to the places where positions are opened (to either allow or disallow).

 
Vladimir Karputov:

Yes, you have inserted the input parameters correctly. Now we need to add code to the places where positions are opened (to either allow or disallow).

Add these lines wherever there is a Buy or Sell ?

 
Hi friends, I tested this EA but I have a hard time adjusting the Lot. How do I set Fixed Lot on this EA? Can you help me?
 
dougcavalcanti :
Hi friends, I tested this EA but I have a hard time adjusting the Lot. How do I set Fixed Lot on this EA? Can you help me?

Use the"Lots" parameter