expert advisor - miscellaneous questions - page 33

 

MQL4:

MODE_LOTSTEP

24

Step for changing lots


Print("Step for changing lots=",MarketInfo(Symbol(),MODE_LOTSTEP));

MQL5:

SYMBOL_VOLUME_STEP

Minimal volume change step for deal execution

double


Print(" Step: ",SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);

So it informs you about the smallest step up or down in lotsize if it is 0.01 then your lots have to agree to 0.01, 0.02, 0.03, 0.04 etc.

If it would be 0.1 then your change in lotsize would have to meet 0.1 next 0.2 next 0.3 etc.

So i do not understand your:

   if(lotsize>=(lotstep*100))
     {
      lotstep=lotstep*100;
      Print("lot step: ",lotstep);
     }

Maybe you mean a different lot step ?

Normally you would not change the value because it is fixed for each symbol.

 
Max Enrik:
// lot plus
if(sparam==lotbuttonplus)
  {
   if(lotsize>=(lotstep*100))
     {
      lotstep=lotstep*100;
      Print("lot step: ",lotstep);
     }

Things can get confusing if you change the value of an intuitively-named variable. I would suggest lotstep is always lotstep, nothing else.

How about something like this? 

   double increment = (lotsize < lotstep*100) ? lotstep : lotstep*100;
   lotmaxdivide=lotmax/lotmax *(lotvalue*10);
   lotsize=fmin(lotmaxdivide,lotsize+(( ctrlfalse) ? increment*10 : increment));
Edit: sorry, just seen Marco's reply. I agree re: lotstep naming.
 

Marco vd Heijden:

So i do not understand your:

   if(lotsize>=(lotstep*100))
     {
      lotstep=lotstep*100;
      Print("lot step: ",lotstep);
     }

Maybe you mean a different lot step ?
Normally you would not change the value because it is fixed for each symbol.

Yeah! I mean different lot step, so when lot size reached to lot size 1.00 for EURUSD. Then I need to lot size increase by 1.00. Before lot size reached 1.00 - lot size increase 0.01, 0.02 etc. ( which one I want ) - but after lot size reached 1.00 - then lot size increase 1.00, 2.00, 3.00, etc.
That is what I want to do in this subtopic.

Thanks so much more.

 
honest_knave:

Things can get confusing if you change the value of an intuitively-named variable. I would suggest lotstep is always lotstep, nothing else.
How about something like this? 

   double increment = (lotsize < lotstep*100) ? lotstep : lotstep*100;
   lotmaxdivide=lotmax/lotmax *(lotvalue*10);
   lotsize=fmin(lotmaxdivide,lotsize+(( ctrlfalse) ? increment*10 : increment));
Edit: sorry, just seen Marco's reply. I agree re: lotstep naming.

( I just little changed not - ... ? lotstep : lotstep*100 - ...? lotstep : lotstep*10 )

Yeah! In my original code things confuses.
After your great help, I solve my issue. Thanks a lot.

Also I wish lot size increase like this.
So lot size increases like this 0.99, 1.00, 1.01, 1.11.
But I need like this 0.99, 1.00, 1.10, 1.20 etc.

Thanks in advance.

 

I think 0.99, 1.00, 1.01, 1.02. would be the best idea.

Stick to the smallest available step i guess.

Why do you want to take these ULTRA LARGE steps?

Have you tried it?

Please try it.
 
Marco vd Heijden:

I think 0.99, 1.00, 1.01, 1.02. would be the best idea.
Stick to the smallest available step i guess.
Why do you want to take these ULTRA LARGE steps?
Have you tried it?

Please try it.

I already tried it, think if I need to reach lot size 5.00 I should 40 times click lot plus button ( + ctrl ).

 

Wow and why five ?

You can just use + and - in stead of *

lotsize=lotsize+0.1;
lotsize=lotsize-0.1;

But there is one line in my robot that saves it from total destruction and it's this:

static input double lotsmax=1;// Max Lots (please respect the setting)
 
Marco vd Heijden:

But there is one line in my robot that saves it from total destruction and it's this:

That is absolutely true, also of course I respect that setting.

But this is just a issue - I mean I can adjust it anytime.
Maybe I need a little experience about that lot size.

I think this subtopic could close for now.

Thanks @Marco vd Heijden and @honest_knave

#Lot Step - Closed

 

#Lot Size Max - Open

@Marco vd Heijden - thanks so much more for your latest comment, which is I inspired to write this part of code for my EA's. ( I just stopped to write other functions - that I try to write this one before others )

So, as usually I try to test something for lot size max.
When lot size better then lot size max, print function does not let me about trade mode.
After I solve this issue, I need to put this function Sell and Buy button functions.

Q:  How can I do print function let me about trade mode either? ( - lot size better then lot size max or less then it )
Q:  Is this method useful for lot size max?

Thanks in advance.

void example()
  {
   string trademode;
   ENUM_ACCOUNT_TRADE_MODE accounttype=(ENUM_ACCOUNT_TRADE_MODE) AccountInfoInteger(ACCOUNT_TRADE_MODE);

   if(accounttype==ACCOUNT_TRADE_MODE_DEMO)
     {
      switch(accounttype)
        {
         case ACCOUNT_TRADE_MODE_DEMO:
            if( lotsize > ( lotstep * lotsizemax ) ) return;
            trademode="demo";
            break;
         case ACCOUNT_TRADE_MODE_CONTEST:
            trademode="contest";
            break;
         default:
            trademode="live";
            break;
        }
     }
   Print("Trade Mode: ",trademode);
  }
 

No thats for verifying if it's a demo account or a live account, contest is rarely used.

Lot max can be very easy.

//---
// calculate lotsize here
//---

// check if lotsize is not too high

if(lotsize>lotsize_max)
{
  lotsize=losize_max;
}
Reason: