Experts: GONNA SCALPING - page 2

 
Kenneth Parling:

it's a fatal error in the expert adviser! In computing, a program error may result from an attempt to divide by zero. Ask developer to correct this error.

Hello

You are using wrong lotsize You don't have enough money or vice versa you use high margin (bigger then 10000USD) with small lotsize this is not a program error, it is a wrong use of lotsize.

 
Aharon Tzadik:

Hello

You are using wrong lotsize You don't have enough money or vice versa you use high margin (bigger then 10000USD) with small lotsize this is not a program error, it is a wrong use of lotsize.

LOL

in fact if your adviser can't handle divisions correct it's fatal! It would be better you learned how to code and avoid such errors

And to be clear..i don't even use your adviser, just replied to another guy

 
Kenneth Parling:

LOL

in fact if your adviser can't handle divisions correct it's fatal! It would be better you learned how to code and avoid such errors

And to be clear..i don't even use your adviser, just replied to another guy

it's clear, i agree 100% 

 
wang_trader:

it's clear, i agree 100% 

I just take care of stop out level and use these lines:

  if((((AccountStopoutMode()==1) &&

        (AccountFreeMarginCheck(symb,type,lots)<AccountStopoutLevel()))

       || ((AccountStopoutMode()==0) &&

           ((AccountEquity()/(AccountEquity()-AccountFreeMarginCheck(Symbol(),OP_SELL,lots))*100)<AccountStopoutLevel()))))

You can not handle lot size and ignore stop out levels, if i will ignore stop out levels and delete these lines you will not see the error message but it will be wrong to ignore stop out levels.

It is indeed fatal to use the wrong lot size when you dont have enough money.

 
Aharon Tzadik:

I just take care of stop out level and use these lines:

  if((((AccountStopoutMode()==1) &&

        (AccountFreeMarginCheck(symb,type,lots)<AccountStopoutLevel()))

       || ((AccountStopoutMode()==0) &&

           ((AccountEquity()/(AccountEquity()-AccountFreeMarginCheck(Symbol(),OP_SELL,lots))*100)<AccountStopoutLevel()))))

You can not handle lot size and ignore stop out levels, if i will ignore stop out levels and delete these lines you will not see the error message but it will be wrong to ignore stop out levels.

It is indeed fatal to use the wrong lot size when you dont have enough money.

Even if some one uses wrong lots size the adviser can not and shall not give a division error. If it does it means that the code is broken and it is for sure if it can't handle a zero divide error

Your problem is here : ((AccountEquity()/(AccountEquity()

and you need a function that makes sure to divide n by d and return 0 if d=0 else it should return n/d

 
Kenneth Parling:


Problem is fixed by adding a check line before the condition.

I dont have any error message in any case  not before the change and not now because every broker/platform has a different calculation ,will be glad to have feedback and if someone will tell me if he has an error message.

Thank you.

 
Kenneth Parling:

Thank you for taking this issue as seriously as you can.

You have good intentions but you are wrong,

You dont need any function for zero divide error, all you need to do is to check that the D=denominator(divisor)!=0 ,not equal to zero.

Like this:

//-----------------------------------------------------------------------------------------------------------------------------------------------

if ( denominator != 0 )

      { answer =  numerator / denominator; }

   else

      { Alert("WARNING: denominator == 0 !"); }  

//------------------------------------------------------------------------------------------------------------------------------------------------


In my program you have this change in line 776 to check the denominator:


//-------------------------------------------------------------------------------------------------------------------------------------------------

      if(AccountEquity()-AccountFreeMarginCheck(Symbol(),type,lots)==0)

        {

         Print("StopOut level  Not enough money ", type," ",lots," ",Symbol());

         return(false);

       }

//-------------------------------------------------------------------------------------------------------------------------------------------------

Just for you to know every broker has a different calculation for these values.

Also as you noticed there are more divisions in my code in the lot optimizing function, but the denominator there is :

 double volume_step=SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_STEP);

And this value will not be zero, this function is copied exactly from here:

https://www.mql5.com/en/articles/2555

Are you saying that "METAQUOTES" article is providing fatal errors ? 

You are wrong.

You are talking like a person thet never used these checking functions, are they new to you ? if you didnt used these functions as they are then you should, or else all of your EAs are with bad code.

I did not see any division check in your codes, is that ok ?

I looked at your poblished codes and didnt see  a single checking function  writen correctly or a check before divide,and you patronize me and send me to study? what is this behvior ?

There are some places that you dont have to check the devision as i see in your codes also, i refer to the ready made functions, you can not write any code you like without the checks and tell every one to check their codes.

And please dont reccomend any thing to any one if you dont make some home work ,you dont need to post any thing when your comment is not serious.

This is the function:

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

//--- maximal allowed volume of trade operations
   double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
   if(volume>max_volume)
     {
      description=StringFormat("Volume is greater than the maximal allowed SYMBOL_VOLUME_MAX=%.2f",max_volume);
      return(false);
     }

//--- get minimal step of volume changing
   double volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);

   int ratio=(int)MathRound(volume/volume_step);
   if(MathAbs(ratio*volume_step-volume)>0.0000001)
     {
      description=StringFormat("Volume is not a multiple of the minimal step SYMBOL_VOLUME_STEP=%.2f, the closest correct volume is %.2f",
                               volume_step,ratio*volume_step);
      return(false);
     }
   description="Correct volume value";
   return(true);
  }

THE CHECKS A TRADING ROBOT MUST PASS BEFORE PUBLICATION IN THE MARKET

THE CHECKS A TRADING ROBOT MUST PASS BEFORE PUBLICATION IN THE MARKET

The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks, as a small error in the expert or indicator logic can cause losses on the trading account. That is why we have developed a series of basic checks to ensure the required quality level of the Market products. If any errors are identified by the Market...
 

What is going on here?

Why does this topic keep coming to the top when there are no new posts.

If somebody is editing their post, then please edit it all at once, not little pieces at a time.

 
Aharon Tzadik:

Thank you for taking this issue as seriously as you can.

You have good intentions but you are wrong,

You dont need any function for zero divide error, all you need to do is to check that the D=denominator(divisor)!=0 ,not equal to zero.

Hi Mr Aharon,

Thank you for pointing out your implementation at line 776 because that one totally slipped by my eyes here. I'm not trying to offend you in any way or saying you are a bad coder (your own words) and i'm not saying i'm a full blown professional either but about my homework i did that a long time ago and divisions was one of them and how to handle them. I can tell you this, my source codes in codebase is not trading robots for use either on demo's or real accounts, they are templates for further development and it's also stated. And i haven't got one single complaint that a zero divide error has occurred. Why i addressed your's was simply by the fact you had complaints about this and i was answering in the first place that person who filed the complaint.

I'm having a slightly different way to handle this issue but i'm sure they both yours and mine doing what they are suppose to do. So, no hard feelings Aharon and i'm sorry for not seeing your bug fix at line 776 ;-) . Same as you, i'm also learning new things every day about coding and also about people and it's an endless learning process.....

Have a nice Easter weekend, take care in Covid-19 times ;-)

 
Dear Aharon Tzadik!
Goona Scalp does not open a position! The Test only shows a negative result, what kind of setting is needed, because it does NOT give OPTIMIZATION in the back test! Serious negative balance after 2 years back test even! Please help because I am Scalpolos and disabled! In the settings I set the Trailling Stop ot, TP STO Loos to 2- 5- 5, 3 is the position! Being 5 pips in EA is 50 points!
What is a good setup for M5, M15 ??
best regards
freemanlaci
Reason: