Experts: MA Trend

 

MA Trend:

A trading system based on indicator iMA (Moving Average, MA).

MA Trend

Author: Vladimir Karputov

 

Hello Vladimir.

Can you add only Buy and only Sell buttons to this Expert Advisor?

Thank you.

 
Shara1:

Hello, Vladimir.

Can you add only Buy and only Sell buttons to this Expert Advisor?

Thank you.

Of course you can modify the code at your discretion and add any controls based on the CDialog dialogue panel creation class.

 
Vladimir Karputov:

Of course you can modify the code as you wish and add any controls based on the CDialog dialogue panel creation class.

Thank you. This is a dark forest for me. I am a complete zero in programming.

 
Shara1:

Hello, Vladimir.

Can you add only Buy and only Sell buttons to this Expert Advisor?

Thank you.

Here is the second version of MA Trend 2:

... added the Type traiding restriction parameter:

  • Only BUY - it is allowed to open only BUY
  • Only SELL - it is allowed to open only SELL
  • BUY and SELL - it is allowed to open both BUY and SELL

...

 

Happy New Year. Can you tell me if this Expert Advisor is suitable for Forts. I am interested in settings for 1 lot, etc.

 
Константин:

Happy New Year. Can you tell me if this Expert Advisor is suitable for Forts. I am interested in settings for 1 lot, etc.

Who is "Forts"? I know Forex, I know Exchange, I know Forts - I don't know such a beast :)

 
Icarus :


Thanks for sharing, I found your coding elegant.

However, the EA shows some annoying bugs. When I put to test over a period of one year, it only operates in the month of January, and in specific week days , in the EURUSD. I haven't changed your code.

Sorry, I did not understand your thought.

 

hi

Thank you for sharing .... I need to code myself any recommendations or books I can read or learning materials?

Thank You Again.

 
themasterx7 :

*** I need to code myself any recommendations or books I can read or learning materials?***

I do not understand you.

 
Hi Mr Vladimir Karputov, I love your contribution to the community, there is one thing I suspect you there is a bug in one of your function you used quite a lot: OpenBuy,

in the section below: where m_trade.ResultDeal()!=0 which means the deal ticket is return which means the order is completed, why do you still use condition
   if(m_trade.ResultRetcode()==10009)
     {
      m_waiting_transaction=true; // "true" -> it's forbidden to trade, we expect a transaction
      m_waiting_order_ticket=m_trade.ResultOrder();//current processing order
     }
shouldn't we strictly set the m_waiting_transaction = false?

____________________________________________________________________________________below is the part of the code


   if(m_trade.Buy(long_lot,m_symbol.Name(),m_symbol.Ask(),sl,tp))
      // CTrade::Buy -> "true"
      //if a open buy order placed successful
     {
      if(m_trade.ResultDeal()==0)//if there is no closed deal returned--position open not DONE yet
        {
         if(m_trade.ResultRetcode()==10009) // trade order went to the exchange | Request completed
           {
            m_waiting_transaction=true; // "true" -> it's forbidden to trade, we expect a transaction
            m_waiting_order_ticket=m_trade.ResultOrder();//record current processing order to be confirmed
           }
         else
            m_waiting_transaction=false;//new trade allowed
         if(InpPrintLog)
            Print("#1 Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
                  ", description of result: ",m_trade.ResultRetcodeDescription());
         if(InpPrintLog)
            PrintResultTrade(m_trade,m_symbol);
        }
      else
        {
         if(m_trade.ResultRetcode()==10009)
           {
            m_waiting_transaction=true; // "true" -> it's forbidden to trade, we expect a transaction
            m_waiting_order_ticket=m_trade.ResultOrder();//current processing order
           }
         else
            m_waiting_transaction=false;//new trade allowed
         if(InpPrintLog)
            Print("#2 Buy -> true. Result Retcode: ",m_trade.ResultRetcode(),
                  ", description of result: ",m_trade.ResultRetcodeDescription());
         if(InpPrintLog)
            PrintResultTrade(m_trade,m_symbol);
        }
     }
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
  • www.mql5.com
Trading is done by sending orders to open positions using the OrderSend() function, as well as to place, modify or delete pending orders. Each trade order refers to the type of the requested operation. Trading operations are described in the ENUM_TRADE_REQUEST_ACTIONS enumeration...