Can someone help me with the code (Random Lot Size)

 

Good Day everyone,

Can someone help me with the MQL4 code setup of random lot size.
I want to have several input for the Lot size.

Lot size A = 0.01
Lot size B = 0.02
Lot size C = 0.03
Lot size D = 0.04
Lot size E = 0.05

And EA will choose Randomly for this lot size number when opening the trade.


input double lot     = 0.01;  // lot
input int slippage   = 8;    // max slippage
datetime tlast;
int OnInit()
{
   tlast = INT_MAX;
   return INIT_SUCCEEDED;
}
void OnTick()
{
    if(Time[0] > tlast)
    {
        if(Open[1] > Close[1])
            bool res = OrderSend(_Symbol, OP_SELL, lot, Bid, slippage, 0, 0);
        else
        if(Open[1] < Close[1])
            bool res = OrderSend(_Symbol, OP_BUY, lot, Ask, slippage, 0, 0);
    }
    tlast = Time[0];
 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
 
Nicko Putra Setiawirawan: Can someone help me … I want …

Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
          No free help 2017.04.21

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum 2018.05.12

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
          No free help 2017.04.21

 
Keith Watford:
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.

Ups Sorry..
Btw I've got this one solved with mathrand fucntion.

Reason: