Experts: MA Trend

 

MA Trend:

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

MA Trend

Author: Vladimir Karputov

 
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...
 
fudongyang :
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
shouldn't we strictly set the m_waiting_transaction = false?

____________________________________________________________________________________below is the part of the code


There is forex, but there is a conclusion of transactions on the exchange: A General Scheme of Trading Operations

Scheme of trade operations: from order creation to execution by broker


If a

ResultDeal

Gets the deal ticket


returned '0' need to check what the method returned

ResultRetcode

Gets the code of request result


- if it returned '10009'

10009

TRADE_RETCODE_DONE

Request completed


- we will wait for the deal

               SPosition[index].waiting_transaction= true ;
               SPosition[index].waiting_order_ticket=m_trade.ResultOrder();
Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
 
Vladimir Karputov #:

Sorry, I did not understand your thought.

@Icarus, # Icarus,

When using the MT5 Strategy Tester make sure you set the Date to "Custom Period" then next to that (on the right) manually set the date you wish to use.
I have been testing this ea myself and have not found the related issue you mention, it is running and I have the date set for 12 months and it is currently at 3 months at the time of writing this message.

Hope this helps

При использовании Тестера стратегий MT5 убедитесь, что вы установили дату в «Пользовательский период», а затем рядом с ним (справа) вручную установите дату, которую вы хотите использовать. Я сам тестировал этот советник и не нашел связанной с этим проблемы, о которой вы упомянули, он работает, и у меня установлена ​​дата на 12 месяцев, а на момент написания этого сообщения на данный момент 3 месяца.

 
Привет Владимир,

Отличный эксперт, мне просто интересно, можете ли вы добавить опцию в свои настройки ввода?

Было бы неплохо, если бы оператор мог отключить и / или включить опцию Trailing Step, поскольку некоторые стратегии не работают с Trailing Step.

Если шаг трейлинга отключен, советник будет полагаться на трейлинг-стоп.

Является ли это возможным?
Заранее спасибо.

Hi Vladimir, Great expert, I'm just wondering if you can add an option to your input settings? It would be nice if the operator could disable and / or enable the Trailing Step option, as some strategies do not work with Trailing Step. If the trailing step is disabled, the EA will rely on the trailing stop. Is it possible? Thank you in advance.



 
themasterx7 #:

hi

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

Thank You Again.

This is a good place to start.

https://www.mql5.com/en/docs

MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5
MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5
  • www.mql5.com
MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5
 

Привет Владимир
У меня вопрос.
Но сначала я попытаюсь объяснить свою проблему.

Теперь? Когда я торгую вручную, я могу разместить сделку с размером лота 0,20, что составляет 2 доллара США, но?

Когда я помещаю ваш советник на свой график, он не будет торговать 0,20 лота, я должен уменьшить его до 0,10 $ 1,00.

Мой вопрос, почему?

Я посмотрел на ваш экспертный код и увидел <Expert \ Money \ MoneyFixedMargin.mqh>

а также
 CMoneyFixedMargin * m_money;

Является ли фиксированная маржа установленным пределом?

В МТ5, когда я смотрю на свой счет, написано «Свободная маржа».

 Это другое?

Могу ли я изменить код фиксированной маржи на свободную маржу?

Поможет ли это с разными размерами лотов для ручной и экспертной торговли?




Hi Vladimir I have a question. But first I will try to explain my problem. Now? When I trade manually, I can place a trade with a lot size of 0.20, which is $ 2, but? When I put your EA on my chart, it will not trade 0.20 lots, I have to reduce it to 0.10 $ 1.00. My question is why? I looked at your expert code and saw <Expert \ Money \ MoneyFixedMargin.mqh> and CMoneyFixedMargin * m_money; Is the fixed margin a set limit? In MT5, when I look at my account, it says “Free Margin”. Is it different? Can I change the Fixed Margin Code to Free Margin? Will it help with different lot sizes for manual and expert trading?

 
MAS-Trading # :

Instead of 'Risk in percent for a deal', use 'Constant lot'

Reason: