How can make "Lot" parameter in list array

 
Hi all .. I wanna ask ,, How can I Possibly to make "lotlist[]"  in input paramater  ?...

example :
extern double lotlist[] = { 0.1,0.2,0.3,0.4 };
but I can't because  'lotlist'  objects and arrays are not allowed as inputs

thank you:

void BuyOrderVarying2()
{
    int orderid = 1;
    double lotlist[] = { 0.1,0.2,0.3,0.4 };
    
    int len = ArraySize(lotlist);   // get the length, and that is also max index allowed
    if (orderid > 100 || orderid < 0)
    {
        Print("This block works only with Order Ids between 0 and 100");
        return;
    }
    int currindex = varylots[orderid];
    if (currindex >= len)   // reset index if reached the end
    currindex = 0;
    varylots[orderid] = currindex + 1;    // set it back
    double lots = lotlist[currindex];
    
    double SL = Ask - Stoploss2*PipValue*Point;
    if (Stoploss2 == 0) SL = 0;
    double TP = Ask + Takeprofit2*PipValue*Point;
    if (Takeprofit2 == 0) TP = 0;
    int ticket = -1;
    if (true)
    ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
    else
    ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 4, SL, TP, "My Expert", 1, 0, Blue);
    if (ticket > -1)
    {
        if (true)
        {
            if (!OrderSelect(ticket, SELECT_BY_TICKET)) return;
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }
            
    }
    else
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }
}

 

You could input the number sequence as a string, and then use StringSplit() to put each value into an array.

"0.1,0.2,0.3,0.4"

It is your choice if you then further convert each value into a second array of type double, or convert at the time of usage

https://docs.mql4.com/strings/stringsplit


*Disclaimer: I use MQL5 so you will need to determine the MQL4 equivalent

StringSplit - String Functions - MQL4 Reference
StringSplit - String Functions - MQL4 Reference
  • docs.mql4.com
StringSplit - String Functions - MQL4 Reference
Reason: