Experts: Validate Me framework

 

Validate Me framework:

Checks a trading robot must pass

Validate Me framework

Author: Merit Christel Marie Mattsson

 

Thanks for this. I'm trying to add back the volume check messages. But it seems you can't return references in MQL4. Any thoughts?


//+------------------------------------------------------------------+
//|Check the correctness of the order volume                                                                   |
//+------------------------------------------------------------------+
double CheckVolumeValue(double checkedvol,string &descrip)
  {
//--- minimal allowed volume for trade operations
   double min_volume=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
   if(checkedvol<min_volume)
   {
      description=StringFormat("Volume is less than the minimal allowed SYMBOL_VOLUME_MIN=%.2f",min_volume);
      return(min_volume);
      }
 
clemmo:

Thanks for this. I'm trying to add back the volume check messages. But it seems you can't return references in MQL4. Any thoughts?


Hi Clemmo,

I had that removed in my code, you can easily get them back by doing something like this and you must then use the original check function. Hope this helps you out

 switch(Market)
     {
      case __BUY__:'
         string MyDescription="";
         ask=MarketInfo(_Symbol,MODE_ASK);
         bid=MarketInfo(_Symbol,MODE_BID);
         sl=(OrderStopPips==0)?0.0:bid-ExtOrderStop;
         if(sl!=0.0 && ExtOrderStop<StopLevel)
            sl=bid-StopLevel;
         tp=(OrderTakePips==0)?0.0:ask+ExtOrderTake;
         if(tp!=0.0 && ExtOrderTake<StopLevel)
            tp=ask+StopLevel;
         GetLot=CheckVolumeValue(Lots,MyDescription);
         PrintFormat(MyDescription);
         if(!CheckStopLoss_Takeprofit(OP_BUY,ExtOrderStop,ExtOrderTake))
            return;
         if(CheckMoneyForTrade(GetLot,OP_BUY))
            order=OrderSend(_Symbol,OP_BUY,GetLot,ask,10,sl,tp,"FrameWork",678,0,Blue);
         break;
Reason: