Checking the minimum stop in EAs published in the marketplace.

 

Hi all, friends!

There's a special feature of Marketplace: we need to check all values for min stop.

If the value of the variable is less than the min-stop, then assign a min-stop, so that there is no error 130.

Currently 90% of brokers have floating spread and min STOP and yield 0.

There is a code construct that assigns all variables to the min stop.

 int OnInitLevels(string symToWorkmodify)
  {
   if(lot<SymbolInfoDouble(symToWorkmodify,SYMBOL_VOLUME_MIN))lots=SymbolInfoDouble(symToWorkmodify,SYMBOL_VOLUME_MIN);else
   if(lot>SymbolInfoDouble(symToWorkmodify,SYMBOL_VOLUME_MAX))lots=SymbolInfoDouble(symToWorkmodify,SYMBOL_VOLUME_MAX);else lots=lot;
   if(StopLoss>0 && StopLoss<SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL))StopLosss=(int)SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL);else StopLosss=StopLoss;
   if(TakeProfit>0 && TakeProfit<SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL))TakeProfits=(int)SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL);else TakeProfits=TakeProfit;
   if(TrailingStop>0 && TrailingStop<SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL))TrallingStops=(int)SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL);else TrallingStops=TrailingStop;
   if(TakeProfitALL>0 && TakeProfitALL<SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL))TakeProfitsAver=(int)SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL);else TakeProfitsAver=(int)TakeProfitALL;
   if(TrailingStop>0 && TrailingStop<SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL))TrallingStops=(int)SymbolInfoInteger(symToWorkmodify,SYMBOL_TRADE_STOPS_LEVEL);else TrallingStops=TrailingStop;
   return(0);
  }

But it doesn't work in the marketplace anymore, because minstop = 0 everywhere now,

Who is dealing with this problem?

 

Of course it doesn't )))) It's not SL, TP and TS that should be set to minimum, but Stop Level. And not only once at program start, but at every tick:

   digits          = (int) SymbolInfoInteger(symbol, SYMBOL_DIGITS);
   point           = SymbolInfoDouble(symbol, SYMBOL_POINT);
   
   tickSize        = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE);
   
   ask             = SymbolInfoDouble(symbol, SYMBOL_ASK);
   bid             = SymbolInfoDouble(symbol, SYMBOL_BID);
   spread          = ask - bid;

   stopLevel       = MarketInfo(symbol, MODE_STOPLEVEL) * point;
   
   if (stopLevel == 0)
   {
      if (!isECN)
         stopLevel = NormalizeDouble(2 * spread, digits);
   }
   else
      stopLevel = NormalizeDouble(stopLevel + tickSize, digits);
isECN - must be available to the user for setting. There are accounts like "true ECN" where there really are no limitations on minimum distances, i.e. stops/profits/positions can be set inside the spread.
 

Thanks. but your design is the same as mine, only you multiplied at min stop = 0 just by the spread*2, but as we know at many brokers min stop = 3 spread, why did you make 2?

I check for min stop on every tick.

 
StopLevel will not help as it also returns zero, use Ask-Bid difference, can be with some multiplier
 
Alexander Bereznyak:
StopLevel does not help, as it also returns zero, I use the Ask-Bid difference
is it for spread, but for min stop?
 
and for a min stop too
 
Alexander Bereznyak:
and for the min stop, too.
So you make the min stop equal to the spread?
 
Vladislav Andruschenko:

Hi all, friends!

There's a special feature of Marketplace: we need to check all values for min stop.

If the value of the variable is less than the min-stop, then assign a min-stop, so that there is no error 130.

Currently 90% of brokers have floating spread and min STOP and yield 0.

There is a code construct that assigns all variables to the min stop.

But it doesn't work in the marketplace anymore, because minstop = 0 everywhere now,

Who is dealing with this problem?

As an option, introduce a restriction on the minimum stop size. For example, in OnInit(), if a user sets a stop less than 2 points, give a warning and return the code INIT_PARAMETERS_INCORRECT.

Another option is not to allow the user to control the stop size, but to calculate it dynamically in the Expert Advisor based on trading conditions.

 
as the broker states the min stop as zero, there is nothing else to do, you can pick up the multiplier if the spread is not enough
 
Vitalii Ananev:

Alternatively, you can introduce a limit on the minimum stop size. For example, in OnInit(), if a user sets a stop of less than 2 pips, it would give a warning and return the code INIT_PARAMETERS_INCORRECT.

Another option is to not allow the user to control the stop size, and calculate it dynamically in the Expert Advisor based on trading conditions.

I agree - not giving control, but you know how it is required by the type: I want to set my own stop.

I will think about the message output - thank you.

 
Alexander Bereznyak:
As the broker declares min stop to be zero, there is nothing else to do, you can pick up a multiplier if the spread is not enough

Yes, this is only for the market - but there is no universality for any broker

the way it works is you have to make a min stop at 3 spreads in order to be accepted in the market,

The only difference is that the market accepts them - you have to make a min stop and 3 spreads, but in fact this is wrong - if a broker min stop = 1 spread - then the user cannot put less than 3 spreads.

Baffle.

Reason: