automatic vaildation dosen't work because invalid stops

 

it work at strategy tester but error in automatic vaildation


void trailing()
  {
   for(int i = PositionsTotal() - 1; i >= 0 && !IsStopped(); i--)
     {
      if(m_position.SelectByIndex(i))
        {

         if(m_position.Magic()==MagicNumber)
           {
            double pos_price      =m_position.PriceOpen();
            double pos_cprice     =m_position.PriceCurrent();
            double pos_sl         =m_position.StopLoss();
            double pos_tp         =m_position.TakeProfit();
            ENUM_POSITION_TYPE pos_type       =(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);

            if(pos_type==POSITION_TYPE_BUY)
              {
               if(pos_sl<pos_price)
                 {
                  if(m_symbol.Ask()>pos_price+_Point*TrailingStep)
                    {
                     double new_sl = m_symbol.NormalizePrice(pos_price+_Point*TrailingStop);
                     m_trade.PositionModify(m_position.Ticket(),new_sl,pos_tp);
                    }
                 }
               else
                 {
                  if(pos_cprice>pos_sl+_Point*TrailingStep)
                    {

                     double new_sl = m_symbol.NormalizePrice(pos_sl+_Point*TrailingStop);
                     m_trade.PositionModify(m_position.Ticket(),new_sl,pos_tp);
                    }
                 }
              }
            else
              {
               if(pos_sl>pos_price)
                 {

                  if(m_symbol.Bid()<pos_price-_Point*TrailingStep)
                    {
                     double new_sl = m_symbol.NormalizePrice(pos_price-_Point*TrailingStop);
                     m_trade.PositionModify(m_position.Ticket(),new_sl,pos_tp);
                    }

                 }
               else
                 {
                  if(pos_cprice<pos_sl-_Point*TrailingStep)
                    {
                     double new_sl = m_symbol.NormalizePrice(pos_sl-_Point*TrailingStop);
                     m_trade.PositionModify(m_position.Ticket(),new_sl,pos_tp);
                    }
                 }

              }
           }
        }
     }
  }


error
 
Kim Yonghwa:

it work at strategy tester but error in automatic vaildation



Hello Kim , you need to also be checking the minimum stop level distance your broker allows per trade , that is the issue i think 

int min_distance_allowed_in_points=SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);

The distance is from the live price not the open of a trade

https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_integer

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Kim Yonghwa:it work at strategy tester but error in automatic vaildation

Did you read the Market rules?

Product Testing#

  1. Products offered through the Market service are subject to automatic pre-testing. The necessary requirements are described in the articles "The checks a trading robot must pass before publication in the Market" and "Tips for an effective product presentation on the Market".

Articles

The checks a trading robot must pass before publication in the Market

MetaQuotes, 2016.08.01 09:30

Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.
 
Lorentzos Roussos #:

안녕하세요 Kim 님, 브로커가 거래당 허용하는 최소 스탑 레벨 거리도 확인해야 합니다. 그것이 제가 생각하는 문제입니다.

거리는 거래 시작이 아닌 실시간 가격입니다.

https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_integer

thank so much!!!

you are right

it's stoplevel issue

 
Fernando Carreiro #:

Did you read the Market rules?

Product Testing#

  1. Products offered through the Market service are subject to automatic pre-testing. The necessary requirements are described in the articles "The checks a trading robot must pass before publication in the Market" and "Tips for an effective product presentation on the Market".


thanks to you

i find solution at document

 
Kim Yonghwa #: thanks to you i find solution at document
You are welcome!