Questions from Beginners MQL5 MT5 MetaTrader 5 - page 878

 
Artyom Trishkin:
Now describe in words what you have described graphically. Use high, low, open, close.
As soon as you describe it in words, you've already written your ToR :)
All that remains is to replace the verbal constructions with code.
OK, I'll do it now)
 

Candle size = high[i] - low[i]

Upper shadow = high[i] - open[i]

Candle body = open[i] - close[i]

Lower shadow = close[i] - low[i]

The ratio of the candlestick body to its size - (high[i] - low[i]) / (open[i] - close[i])

The size of the short shadow must not exceed some threshold - ( close[i] - low[i]) <= close[i]

Candle orientation - high[i] > open[i] > close[i] > low[i]

 
Artyom Trishkin:

I am betting with the mouse.

  • Click above price+Ctrl - Sell Limit
  • Click below price+Ctrl -Buy Limit
  • Click above price+Ctrl+Shift - Buy Stop
  • Click below price+Ctrl+Shift - Sell Stop
One can also put BuyStopLimit and SellStopLimit with the shifft

Is that how you place orders in the tester of MT5, in the visual mode? How are the events handled? OnChartEvent() doesn't work, right?

 
Vladimir Karputov:

The tester works correctly. The error is in the logic of the program: two symbols are like two lives of different people (here "person" is analogous to "symbol"). And the second person does not have to wake up at the same time as the first ("wake up" is analogous to " new bar appearing").

So you have to wait for a new bar to appear AND on the first symbol AND on the second.


Added: article"new bar" event handler

Thanks for the prompt reply. I will think about how to implement all this in multi-currency mode.
 

Such a question - is the order in which the conditions are listed important for finding a candlestick combination?

Example:

    if(((high[i-1]-low[i-1]) < (high[i]-low[i])) && (open[i-1] >= Lower1[i]) && ((close[i-1]-open[i-1]) >= 3*(close[i]-open[i])) &&
      (close[i-1 <= Base[i]]) && (high[i-1] <= 0.5*(high[i]-close[i])) && (close[i-1] <= open[i]) && ((close[i]-open[i])<= 0.33*(high[i]-close[i])) &&
      ((close[i]-open[i]) >= (open[i]-low[i])) && (close[i] <= Base[i])) // когда пин-бар ниже, либо равен линии Base
 

Hello. Netting account, I want to count how many limit orders of the same direction have become positions.

The function does not calculate correctly, why?

int CurrentPos_sell_nettin()
  {
  string symb=_Symbol;
   int    total       =0;  // Всего сделок в списке выбранной истории
   int    count       =0;  // Счетчик сделок по символу позиции
//--- Если история позиции получена
   for(int i=0; i<PositionsTotal(); i++)
     {
      ulong pt=PositionGetTicket(i);
      long ID=PositionGetInteger(POSITION_IDENTIFIER);
      if(PositionGetString(POSITION_SYMBOL)==symb && HistorySelect(PositionGetInteger(POSITION_TIME),TimeCurrent()+60))
        {
         //--- Получим количество сделок в полученном списке
         total=HistoryDealsTotal();
         //--- Пройдем по всем сделкам в полученном списке
         for(int i=0; i<total; i++)
           {
            ulong dt = HistoryDealGetTicket(i);
            long did = HistoryDealGetInteger(dt, DEAL_POSITION_ID);
            ENUM_DEAL_ENTRY in_out=HistoryDealGetInteger(dt,DEAL_ENTRY);
            if(did==pt && in_out==DEAL_ENTRY_IN)
              {
               if(m_position.PositionType()==POSITION_TYPE_SELL)
                 {
                  count++;
                 }
              }
           }
        }
     }
//---
   return(count);
  }
 
lil_lil:

Hello. Netting account, I want to count how many limit orders of the same direction have become positions.

The function does not count correctly, why?

Start with HistorySelectByPosition. Then you will only get the trades involved in that position.

 
clickaider:

Such a question - is the order in which the conditions are listed important for finding a candlestick combination?

Example:

Take a look at the example - there are thirty different patterns.

 
Artyom Trishkin:

Artyom, I will repeat the question, please answer:

Forum on trading, automated trading systems and trading strategy testing

Questions from beginners MQL5 MT5 MetaTrader 5

Alexey Kozitsyn, 2018.06.03 15:39

Is this how you place orders in the MT5 tester, in visual mode? And how do you process events? OnChartEvent() doesn't work, right?


 
Alexey Viktorov:

Start with HistorySelectByPosition. Then you will only get the trades involved in that position.

Thank you.

What's wrong now?

int CurrentPos_sell_nettin()
  {
   string symb=_Symbol;
   int    total       =0;  // Всего сделок в списке выбранной истории
   int    count       =0;  // Счетчик сделок по символу позиции
//--- Если история позиции получена

   for(int i=0; i<PositionsTotal(); i++)
     {
      ulong pt=PositionGetTicket(i);
      long ID=PositionGetInteger(POSITION_IDENTIFIER);
      if(PositionGetString(POSITION_SYMBOL)==symb && HistorySelect(PositionGetInteger(POSITION_TIME),TimeCurrent()+60))
        {
         if(PositionSelect(symb))
           {
            long pos_id=long(PositionGetInteger(POSITION_IDENTIFIER));

            if(pos_id>0)
              {
               if(HistorySelectByPosition(ulong(pos_id)))
                  total=HistoryDealsTotal();
               //--- Пройдем по всем сделкам в полученном списке
               for(int i=0; i<total; i++)
                 {
                  ulong dt = HistoryDealGetTicket(i);
                  long did = HistoryDealGetInteger(dt, DEAL_POSITION_ID);
                  ENUM_DEAL_ENTRY in_out=HistoryDealGetInteger(dt,DEAL_ENTRY);
                  if(did==pt && in_out==DEAL_ENTRY_IN)
                    {
                     if(m_position.PositionType()==POSITION_TYPE_SELL)
                       {
                        count++;
                       }
                    }
                 }
              }
           }
        }
     }
//---
   return(count);
  }
Reason: