Download MetaTrader 5

How to Add custome Lots Input in this code ?

To add comments, please log in or register
Did you like the article? Share it with your friends!
Komoles Kumar
46
Komoles Kumar 2016.05.20 17:48 
Hi,How can i add custom lots :
extern string LS="Lots Settings";
extern double Lot1=0.03; //Lot 2
extern double Lot2=0.09; //Lot 3 
extern double Lot3=0.25; //Lot 4
extern double Lot4=0.60; // Lot 5
extern double Lot5=1.30; // Lot 6
extern double Lot6=0; // Lot 7
extern double Lot7=0; // Lot 8
extern double Lot8=0; // Lot 9
extern double Lot9=0; // Lot 10
extern double Lot10=0; // Lot 11
extern double Lot11=0; // Lot 12
extern double Lot12=0; // Lot 13
extern double Lot13=0; // Lot 14
extern double Lot14=0; // Lot 15
extern double Lot15=0; // Lot 16
extern double Lot16=0; // Lot 17
extern double Lot17=0; // Lot 18
extern double Lot18=0;// Lot 19 
extern double Lot19=0; // Lot 20
extern double Lot20=0; // Lot 21
extern double Lot21=0; // Lot 22
extern double Lot22=0; // Lot 23
extern double Lot23=0; // Lot 24
extern double Lot24=0; // Lot 25
extern double Lot25=0; // Lot 26 
#property copyright "Copyright 2016, Komoles Kumar"
#property link      "https://www.facebook.com/komoles"
#property strict

extern int  stoploss       = 50,
            takeprofit     = 50;
extern double      Lot=0.01; 
          
input int MagicNumber=0;// Magic Number(0-For All )            

int tip;
//--------------------------------------------------------------------
int init()
{
   bool send=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,NormalizeDouble(Ask + stoploss*Point,Digits),
                                    NormalizeDouble(Bid - takeprofit*Point,Digits)," ",MagicNumber,Blue);
   return(EMPTY_VALUE);                                 
}
//--------------------------------------------------------------------
int start()
{
   for (int i=0; i<OrdersTotal(); i++){   
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){
         if (OrderSymbol()==Symbol()){
            tip = OrderType();
            Lot = OrderLots();return(EMPTY_VALUE);}}}
   if (Lot==0) return(EMPTY_VALUE);
   if (tip==0) 
   bool send1=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,NormalizeDouble(Ask + stoploss*Point,Digits),
                                    NormalizeDouble(Bid - takeprofit*Point,Digits)," ",MagicNumber,Blue);
   if (tip==1) 
   bool send12=OrderSend(Symbol(),OP_BUY ,Lot,Ask,3,NormalizeDouble(Bid - stoploss*Point,Digits),
                                    NormalizeDouble(Ask + takeprofit*Point,Digits)," ",MagicNumber,Blue);
   return(0);
}
//-----------------------------------------------------------------
Osama Shaban
1447
Osama Shaban 2016.05.21 14:20  

For adding custom lots could be either by using some formula or as you suggest, different lots for different

conditions, you need to show your code because the coder need to see the conditions of each time a new

lot must be used. You must use something like a buffer or a function to read number of opened trades or 

last used lot index to send the next lot size to the OrderSend( ) function.

Everything depends on the logic you use in your EA ... So, no one able to show you how to do it if code is

not revealed.

Good luck ... 

To add comments, please log in or register