Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1127

 
Vitaly Muzichenko:

Well I have been since 1997)

See, there is a tick and with it a signal, and if you get an error, it needs to be processed. Processed and query again, but before query you can zero the variable with error, then at next query if there is an error, it will go into variable again, but if there is no error, it will be "0".

You don't have to zero the variable, but if there is an error, it will return a new value. In any case, you should not be interested in the error that you had last time on the last tick, you should process only what you have "now".

Since 1997, that's time! ) Probably the only person who understood me. Thank you.
 
Evgeniy Oshurkevich:
So again, this is on mql5. And I need it on mql4.
As far as this function is concerned, it makes no difference. But if it is principled, then read F1.
 

I'm duplicating my question in this thread as the mql5 thread couldn't help - no one knows the answer.

I have this function and it works in my Expert Advisor/Script

double maxLot(double Percent, string symbol, ENUM_ORDER_TYPE action=ORDER_TYPE_BUY)
  {
   double One_Lot=0.0;
   double price=0.0;
   double volume=0.0;
   double MinLot=SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN);
   double Free=AccountInfoDouble(ACCOUNT_FREEMARGIN);
   double Step=SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP);
   if(action==ORDER_TYPE_BUY)price=SymbolInfoDouble(symbol,SYMBOL_ASK);
   if(action==ORDER_TYPE_SELL)price=SymbolInfoDouble(symbol,SYMBOL_BID);
   if(!OrderCalcMargin(action,symbol,1.0,price,One_Lot))return(MinLot);
   if(One_Lot!=0 && Step!=0)volume = MathFloor(Free*Percent/100.0/One_Lot/Step)*Step;
   if(volume!=0)return(volume);
   return(MinLot);
  }

Question:how to get the maximum possible lot in an indicator,OrderCalcMargin does not work in an indicator for some reason? I tried to useOrderCalcMargin but it doesn't work in mt4.

Thank you!

 

how to do it?

so that when

OnDeinit(REASON_CHARTCHANGE)

Continue as normal without resetting (ignore this cause completely, it's an info panel with levels)

 
trader781:

how to do it?

so that when

OnDeinit(REASON_CHARTCHANGE)

Continue as normal without resetting (ignore this cause completely, it's an info panel with levels)

You can't.
 
Vitalie Postolache:
No way.

Well, there are ways around that.

I'm too lazy to cram levels into the code for each tool out of 40 existing ones.

It's easier to make it automatic and click the TF with symbols as you like.

And at the same time, I'm looking for a way to specify the muving values of the higher TF on the lower one
 
trader781:

Well, there are ways around that.

I'm too lazy to cram levels into the code for each tool out of 40 existing ones.

It's easier to make it automatic and click the TF with symbols as you like.

And at the same time, I'm looking for a way to specify muving values for major TF
The settings should be written to a file and the inite should be read. There is no way to bypass deinit, it does not ask permission.
 
Vitalie Postolache:
Write the settings to a file and read them in the init. There is no way to bypass deinit, it does not ask for permission.
Why not bypass deinit by writing to a file, if at all possible? e.g. in case of deinitialisation, you can initiate a start with the previous parameters
 
trader781:
Why not bypass deinit by writing to a file, if at all possible? e.g. in case of deinitialisation initiate a startup with previous parameters
Isn't that what I wrote above?
 
Vitalie Postolache:
Isn't this what I wrote above?

Okay, so we wrote the required settings into the file, closed it, and what?

In theory, it should now re-open the Expert Advisor with the required parameters, and how can a text file do this (I don't see any other functions in the list, although in this case, you need an exe)?

Reason: