Full-featured robot for MT5 - page 5

 

Good morning!

The tester does not want to open a position, it generates an error

ERR_TRADE_SEND_FAILED

4756

Failed to send trade request

Rbtg_NYCInclude tester

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I think something should be corrected here

Rbtg_NYCInclude kod

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Now I will try to replace this function with this one

//+------------------------------------------------------------------+
//| Check for long position opening                                  |
//+------------------------------------------------------------------+
bool CSampleExpert::LongOpened(void)
  {
   bool res=false;
//--- check for long position (BUY) possibility

           {
            double price=m_symbol.Ask();
            double tp   =m_symbol.Bid()+m_take_profit;
            //--- check for free money
            if(m_account.FreeMarginCheck(Symbol(),ORDER_TYPE_BUY,InpLots,price)<0.0)
               printf("We have no money. Free Margin = %f",m_account.FreeMargin());
            else
              {
               //--- open position
               if(m_trade.PositionOpen(Symbol(),ORDER_TYPE_BUY,InpLots,price,0.0,tp))
                  printf("Position by %s to be opened",Symbol());
               else
                 {
                  printf("Error opening BUY position by %s : '%s'",Symbol(),m_trade.ResultComment());
                  printf("Open parameters : price=%f,TP=%f",price,tp);
                 }
              }
            //--- in any case we must exit from expert
            res=true;
           }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
//| Check for short position opening                                 |
//+------------------------------------------------------------------+
bool CSampleExpert::ShortOpened(void)
  {
   bool res=false;
//--- check for short position (SELL) possibility

           {
            double price=m_symbol.Bid();
            double tp   =m_symbol.Ask()-m_take_profit;
            //--- check for free money
            if(m_account.FreeMarginCheck(Symbol(),ORDER_TYPE_SELL,InpLots,price)<0.0)
               printf("We have no money. Free Margin = %f",m_account.FreeMargin());
            else
              {
               //--- open position
               if(m_trade.PositionOpen(Symbol(),ORDER_TYPE_SELL,InpLots,price,0.0,tp))
                  printf("Position by %s to be opened",Symbol());
               else
                 {
                  printf("Error opening SELL position by %s : '%s'",Symbol(),m_trade.ResultComment());
                  printf("Open parameters : price=%f,TP=%f",price,tp);
                 }
              }
            //--- in any case we must exit from expert
            res=true;
           }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
 
SanAlex:

Good morning!

The tester does not want to open a position, it generates an error

ERR_TRADE_SEND_FAILED

4756

Failed to send trade request

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I think something needs to be fixed here.


Yes. It's your dealer-Forexclub for them order type FilingFock. I'll take a walk with the dog and fix it. Didn't think there was anyone else on forexclub...

Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Свойства ордеров - Торговые константы - Константы, перечисления и структуры - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
ElenaFxPro4:

Yes. It's your dealer-Forexclub for them to have a FilingFoc order type. I'll take a walk with the dog and fix it. Didn't think there was anyone else on forexclub...

Filling mode should be set by the rules, not from the name of the forex dealer.


Added.

You can see an example in the CTrade trade class

SetMarginMode

Sets the mode of margin calculation according to the current account settings

SetTypeFillingBySymbol

Sets the order type according to the settings of the specified symbol

Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / SetMarginMode
Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / SetMarginMode
  • www.mql5.com
SetMarginMode - CTrade - Торговые классы - Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
ElenaFxPro4:

Yes. It's your dealer-Forexclub for them to have a FilingFoc order type. I'll take a walk with the dog and fix it. Didn't think there was anyone else on forexclub...

Didn't notice - surely you have a broker still here

Rbtg_NYCInclude kod 01

 

It's working.

Rbtg_NYCInclude tester 01

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

         ENUM_ORDER_TYPE_FILLING TypeFilling = ORDER_FILLING_FOK;
         if (AccountInfoString(ACCOUNT_COMPANY)=="Alpari") TypeFilling = ORDER_FILLING_IOC;

swapped -----------

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Seems to be working fine so far.

Picture 345

 
SanAlex:

It's working.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

swapped -----------

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Seems to be working fine so far.


as the pre-testing by the algorithm takes place, I wonder - is the result the same?
 
Renat Akhtyamov:
as it is pre-tested with algorithm, I wonder if the result is the same?

I'm still testing on a one minute test - my computer is weak, so testing is slow.

It looks good at first glance - let's see what the end result looks like.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

no errors in Expert's tester

 
SanAlex:

Good morning!

The tester does not want to open a position and gives an error

ERR_TRADE_SEND_FAILED

4756

Failed to send trade request

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I think something should be corrected here

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I'm going to try to replace this function with this one.

You don't have to.

The 119th line should be if (AccountInfoString(ACCOUNT_COMPANY)=="Alpari" || AccountInfoString(ACCOUNT_COMPANY)=="Forex Club International Limited") TypeFilling = ORDER_FILLING_FOK;

and the same for AUTOOrderSELL. THAT'S IT. :)


 
ElenaFxPro4:

No need.

The 119th line should be if (AccountInfoString(ACCOUNT_COMPANY)=="Alpari" || AccountInfoString(ACCOUNT_COMPANY)=="Forex Club International Limited") TypeFilling = ORDER_FILLING_FOK;

and the same for AUTOOrderSELL. THAT'S IT. :)


I will leave it this way for now - I will correct it after the test

- don't want to stop the tester

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

the only bad thing is that the test is going on now - and i seem to be overdoing it here

Picture 3456

 
Vladimir Karputov:

Fill mode should be set by the rules, not from the name of the forex dealer.


Added.

You can see an example in the CTrade trade class

SetMarginMode

Sets the mode of margin calculation in accordance with the current account settings

SetTypeFillingBySymbol

Sets the order type according to the settings of the specified symbol

Thank you very much. I should use automatic mode but I couldn't find it. That's why I prepared this patch as simple instructions for broker which one I have to use :) They are only 2. Remake. Thank you.

Reason: