Discussion of article "Universal Expert Advisor: Pending Orders and Hedging Support (Part 5)" - page 3

 
Сергей Криушин:
It doesn't work - these lines are not in Impulse itself....
According to the compiler messages, they are in Impulse, but they cannot be called because the Ask, Bid, etc. functions are not defined in your version of CStrategy.
 
Vasiliy Sokolov:
According to the compiler messages they are in Impulse, but their call is not available because the Ask, Bid, etc. functions are not defined in your version of CStrategy.
How to define them there... the version must be my version... insert from your trading strategy... Ask, Bid, etc. are the same for all common ones...
 
Сергей Криушин:
How do you define them there... the version has to be mine... insert from my trading strategy... they are Ask, Bid, it seems to be the same for all common...
Attached at the bottom of the article is the file strategyarticle_20.04.16.zip. Download it, unzip it and replace all previous CStrategy files with these new ones.
 
Сергей Криушин:
There is CStrategyList Manager; but Impuls class is not there... maybe that's why.
How not? MQL5\Include\Strategy\Samples\Impulse.mqh
 
Vasiliy Sokolov:
How not? MQL5/Include/Strategy/Samples/Impulse.mqh.
Yes, it worked fine thanks a lot... the other account worked fine.... I guess I should have rebooted the terminal... I don't know, everything was compiling, but the owl got stuck... so sorry...that's how it is always something somewhere... and look for half a day...3 times I downloaded and checked everything...)))))
 
How would stop ones make limit ones, as it seems more asks for limit ones...and change the distance..... and how to reduce the lot to 0.01.... so many things that I can't find anything...))))
 
Сергей Криушин:
How would stop ones make limit ones, as it seems more asks for limit ones...and change the distance..... and how to reduce the lot to 0.01.... so many things that it is impossible to find anything...))))
MM.SetLotFixed(0.01);
if(buy_stop_total == 0 && task == ORDER_TASK_MODIFY)
   Trade.BuyLimit(MM.GetLotFixed(), target, ExpertSymbol(), 0, 0, NULL);
As you can see, nothing complicated. The value of target will have to be calculated by yourself.
 
Vasiliy Sokolov:
As you can see, nothing complicated. You will have to calculate the target value yourself.

I tried it like this from scratch - it doesn't work - the stops keep going like this....

//+------------------------------------------------------------------+
void CImpulse::InitSell(const MarketEvent &event)
{
   if(!IsTrackEvents(event))return;                      
   if(positions.open_sell > 0) return;                    
   int sell_limit_total = 0;
   ENUM_ORDER_TASK task;
   double target = Ask() - Ask()*(m_percent/100.0);
   if(target < Moving.OutValue(0))                    // Order triggering price must be above the moving average
      task = ORDER_TASK_DELETE;
   else
      task = ORDER_TASK_MODIFY;
   for(int i = PendingOrders.Total()-1; i >= 0; i--)
   {
      CPendingOrder* Order = PendingOrders.GetOrder(i);
      if(Order == NULL || !Order.IsMain(ExpertSymbol(), ExpertMagic()))
         continue;
      if(Order.Type() == ORDER_TYPE_SELL_LIMIT)
      {
         if(task == ORDER_TASK_MODIFY)
         {
            sell_limit_total++;
            Order.Modify(target);
         }
         else
            Order.Delete();
      }
   }
   if(sell_limit_total == 0 && task == ORDER_TASK_MODIFY)
      Trade.SellLimit(MM.GetLotFixed(), target, ExpertSymbol(), 0, 0, NULL);
}
//+------------------------------------------------------------------+
//| Working with SellStop pending orders to open short |
//| positions|
//+------------------------------------------------------------------+
void CImpulse::InitBuy(const MarketEvent &event)
{
   if(!IsTrackEvents(event))return;                      
   if(positions.open_buy > 0) return;                    
   int buy_limit_total = 0;
   ENUM_ORDER_TASK task;
   double target = Bid() + Bid()*(m_percent/100.0);
   if(target > Moving.OutValue(0))                    // Order triggering price must be above the moving average
      task = ORDER_TASK_DELETE;
   else
      task = ORDER_TASK_MODIFY;
   for(int i = PendingOrders.Total()-1; i >= 0; i--)
   {
      CPendingOrder* Order = PendingOrders.GetOrder(i);
      if(Order == NULL || !Order.IsMain(ExpertSymbol(), ExpertMagic()))
         continue;
      if(Order.Type() == ORDER_TYPE_BUY_LIMIT)
      {
         if(task == ORDER_TASK_MODIFY)
         {
            buy_limit_total++;
            Order.Modify(target);
         }
         else
            Order.Delete();
      }
   }
   if(buy_limit_total == 0 && task == ORDER_TASK_MODIFY)
      Trade.BuyLimit(MM.GetLotFixed(), target, ExpertSymbol(), 0, 0, NULL);
}
 
Сергей Криушин:

I tried it like this - it doesn't work - the stops are still going like this.....

Let me check...
 
Vasiliy Sokolov:
I will check it now...

I added SL and TP levels and trawl to the owl - it shows itself perfectly on the Metaquotes demo...when switching to real again something does not see - it gives errors - the main thing is that I copied everything cleanly, the whole library - and still errors... what is wrong again....a big request - is it possible to somehow combine in one EA with comments...so to speak, for a clear understanding of the essence of all described...With great respect to your great work done...thank you very much...I would also like to know - is it only me with such incomprehensions or someone else is testing.... and without errors...

'Trade.mqh'     Trade.mqh       1       1
'Object.mqh'    Object.mqh      1       1
'StdLibErr.mqh' StdLibErr.mqh   1       1
'SymbolInfo.mqh'        SymbolInfo.mqh  1       
'OrderInfo.mqh' OrderInfo.mqh   1       1
'HistoryOrderInfo.mqh'  HistoryOrderInfo.mqh    1       1
'PositionInfo.mqh'      PositionInfo.mqh        1       1
'DealInfo.mqh'  DealInfo.mqh    1       1
'ENUM_ACCOUNT_MARGIN_MODE' - declaration without type   Trade.mqh       36      4
'POSITION_TICKET' - undeclared identifier       PositionInfo.mqh        84      37
'PositionGetInteger' - no one of the overloads can be applied to the function call      PositionInfo.mqh        84      18
'ENUM_ACCOUNT_MARGIN_MODE' - undeclared identifier      PositionInfo.mqh        259     4
'margin_mode' - undeclared identifier   PositionInfo.mqh        259     29
'margin_mode' - some operator expected  PositionInfo.mqh        259     29
'ACCOUNT_MARGIN_MODE' - undeclared identifier   PositionInfo.mqh        259     86
'ACCOUNT_MARGIN_MODE' - cannot convert enum     PositionInfo.mqh        259     86
'AccountInfoInteger' - some operator expected   PositionInfo.mqh        259     67
'ACCOUNT_MARGIN_MODE_RETAIL_HEDG...'. - undeclared identifier      PositionInfo.mqh        264     20
'PositionSelectByTicket' - function not defined PositionInfo.mqh        325     11
'ENUM_ACCOUNT_MARGIN_MODE' - undeclared identifier      PositionInfo.mqh        332     4
'margin_mode' - undeclared identifier   PositionInfo.mqh        332     29
'margin_mode' - some operator expected  PositionInfo.mqh        332     29
'ACCOUNT_MARGIN_MODE' - undeclared identifier   PositionInfo.mqh        332     86
'ACCOUNT_MARGIN_MODE' - cannot convert enum     PositionInfo.mqh        332     86
'AccountInfoInteger' - some operator expected   PositionInfo.mqh        332     67
'ACCOUNT_MARGIN_MODE_RETAIL_HEDG...'. - undeclared identifier      PositionInfo.mqh        334     20
'PositionGetTicket' - function not defined      PositionInfo.mqh        336     20
'position' - struct member undefined    Trade.mqh       196     12
'position' - struct member undefined    Trade.mqh       196     35
'position_by' - struct member undefined Trade.mqh       197     12
'position_by' - struct member undefined Trade.mqh       197     35
'position' - struct member undefined    Trade.mqh       50      85
'position_by' - struct member undefined Trade.mqh       51      85
'm_margin_mode' - undeclared identifier Trade.mqh       94      44
'ENUM_ACCOUNT_MARGIN_MODE' - undeclared identifier      Trade.mqh       94      59
'ACCOUNT_MARGIN_MODE' - undeclared identifier   Trade.mqh       94      103
'ACCOUNT_MARGIN_MODE' - cannot convert enum     Trade.mqh       94      103
'AccountInfoInteger' - some operator expected   Trade.mqh       94      84
'position' - struct member undefined    Trade.mqh       354     14
'POSITION_TICKET' - undeclared identifier       Trade.mqh       354     42
'PositionGetInteger' - no one of the overloads can be applied to the function call      Trade.mqh       354     23
'PositionSelectByTicket' - function not defined Trade.mqh       367     8
'position' - struct member undefined    Trade.mqh       373     14
possible loss of data due to type conversion    Trade.mqh       373     22
'position' - struct member undefined    Trade.mqh       427     20
'POSITION_TICKET' - undeclared identifier       Trade.mqh       427     48
'PositionGetInteger' - no one of the overloads can be applied to the function call      Trade.mqh       427     29
'PositionSelectByTicket' - function not defined Trade.mqh       472     8
'position' - struct member undefined    Trade.mqh       492     14
possible loss of data due to type conversion    Trade.mqh       492     23
'PositionSelectByTicket' - function not defined Trade.mqh       513     8
'PositionSelectByTicket' - function not defined Trade.mqh       517     8
'TRADE_ACTION_CLOSE_BY' - undeclared identifier Trade.mqh       529     26