Experts: Patterns_EA - page 2

 
Morexod:



See mode clauses.

item 5 = 3 trades

item 3 = 18 tr.

p.5 + p.3 = 21 tr. p.5 + p.3 <= p.2

but p.2 = 200 tr and not <= 21 tr.

The Expert Advisor is for hedge accounts. It is impossible to reverse one position in it. You have to close one position and open another.
 
Artyom Trishkin:
The Expert Advisor is for hedge accounts. It is impossible to reverse one position. You have to close one position and open another.

It is optimised.

Always one position (swing) - always only one position in the market = 200 orders

Any position - any positions = 185 orders

Under the "any position" condition, there should be more orders than under the "always only one position in the market" condition

 
Morexod:

Optimisation is in progress.

Always one position (swing) - always only one position in the market = 200 orders

Any position - any positions = 185 orders

There should be more orders in the "Any position" condition than in the "Always only one position in the market" condition

In case of Any position - any positions, the restriction on the maximum allowed total volume on the account is triggered - because it opens all positions indiscriminately. And at some point there comes a moment of overflow of the total allowed volume on the account, and positions stop being opened.

And in case of Always one position (swing) - "only one position" - the restriction can work only if the initially set volume of the opened position is larger than the maximum allowed one. And the EA, as the author promises, will simply adjust this lot to the possible one.

Maybe it's easier for you to look in visual mode, rather than trying to make premature conclusions based on the number of orders in reports? ;)

 
fxsaber:

That's where the code comes from:

int OnInit()
  {
//--- Setting trading parameters
   if(!SetTradeParameters())
      return INIT_FAILED;

The function itself. The mode that could cause what you're implying is disabled.

//+------------------------------------------------------------------+
//| Setting trading parameters|
//+------------------------------------------------------------------+
bool SetTradeParameters()
  {
//--- Setting the symbol
   ResetLastError();
   if(!symbol_info.Name(Symbol()))
     {
      Print(__FUNCTION__,": Error setting ",Symbol()," symbol: ",GetLastError());
      return false;
     }
//--- Getting prices
   ResetLastError();
   if(!symbol_info.RefreshRates())
     {
      Print(__FUNCTION__,": Error obtaining ",symbol_info.Name()," data: ",GetLastError());
      return false;
     }
   if(account_info.MarginMode()==ACCOUNT_MARGIN_MODE_RETAIL_NETTING)
     {
      Print(__FUNCTION__,": ",account_info.MarginModeDescription(),"-account. EA should work on a hedge account.");
      return false;
     }
//--- Automatic setting of the filling type
   trade.SetTypeFilling(GetTypeFilling());
//--- Installing Magik
   trade.SetExpertMagicNumber(InpMagic);
//--- Slip setting
   trade.SetDeviationInPoints(InpDeviation);
//--- Lot setting with correction of the entered value
   lot=CorrectLots(InpVolume);
//--- Asynchronous order sending mode is switched off
   trade.SetAsyncMode(false);
//---
   return true;
  }
//+------------------------------------------------------------------+

Or did I misunderstand your hint?

 
Artyom Trishkin:

That's where the code comes from:

The function itself. The mode that can cause what you are suggesting is disabled.

Or did I misunderstand your hint?

This situation concerns synchronous mode.

 
This mode does not work in this EA: InpModeOpened==OPENED_MODE_SWING
 
kwlin_089:
This mode does not work in this EA: InpModeOpened==OPENED_MODE_SWING

Why?

I look at the code and see:

//+------------------------------------------------------------------+
//| The trading function|
//+------------------------------------------------------------------+
int Trade(const ENUM_PATTERN_TYPE &pattern_type,const int index)
  {
   ENUM_POSITION_TYPE type=patt.PositionPattern(pattern_type);
   int number=0,last_total=list_trade_patt.Total();
//--- Always one position in the market Buy or Sell
   if(InpModeOpened==OPENED_MODE_SWING)
     {
      if(type==POSITION_TYPE_BUY && NumberSell()>0) CloseSell();
      if(type==POSITION_TYPE_SELL && NumberBuy()>0) CloseBuy();
     }
//--- Only one Buy position
   if(InpModeOpened==OPENED_MODE_BUY_ONE)
     {
      if(NumberBuy()>0) return WRONG_VALUE;
      if(type==POSITION_TYPE_SELL) return last_total;
     }
//--- Any quantity Buy
   if(InpModeOpened==OPENED_MODE_BUY_MANY)
      if(type==POSITION_TYPE_SELL) return last_total;
//--- Only one Sell position
   if(InpModeOpened==OPENED_MODE_SELL_ONE)
     {
      if(NumberSell()>0) return WRONG_VALUE;
      if(type==POSITION_TYPE_BUY) return last_total;
     }
//--- Any number of Sell
   if(InpModeOpened==OPENED_MODE_SELL_MANY)
      if(type==POSITION_TYPE_BUY) return last_total;
//--- All checks are passed or any coli is selected чество любых позиций - открываем позицию
   if(to_logs)
      Print(__FUNCTION__,": To open ",(type==POSITION_TYPE_BUY ? "Buy" : "Sell")," position by pattern ",patt.DescriptPattern(pattern_type));
   if(OpenPosition(pattern_type))   
      list_trade_patt.Delete(index);
//--- Return the number of open positions
   return last_total-list_trade_patt.Total();
  }
//+------------------------------------------------------------------+
  1. If it's swing mode.
    1. if it is necessary to open a purchase and there are sales, then close sales
    2. if it is necessary to open a sale and there are purchases, then close purchases.
  2. If all checks are passed, open the desired position.
Or am I misunderstanding something here? Explain.
 
Artyom Trishkin:

Why?

I'm looking at the code and I see it:

  1. If it's swing mode.
    1. if it is necessary to open a purchase and there are sales, then close sales.
    2. if it is necessary to open a sale and there are purchases, then close purchases.
  2. If all checks are passed, open the desired position.
Or am I misunderstanding something here? Explain.

Artem, as I understand it, we are talking about "disappearing" positions. In mt4 these are SL and TP. I can't judge about mt5...

 
Алексей Тарабанов:

Artem, as I understand it, we are talking about "disappearing" positions. In mt4 these are SL and TP. I can't judge about mt5....

So in MT5 it will be the same. If there is a buy 0.1, the stop is a stop order to sell 0.1
There will be no position when it triggers. And to reverse the position, you need to sell 0.2
 
Artyom Trishkin:
So it will be the same in MT5. If there is a buy 0.1, the stop is a stop order to sell 0.1
There will be no position when it triggers. And to reverse the position, you need to sell 0.2.

You know better, but sometimes someone prefers to check.