Trading on Account balance

To add comments, please log in or register
shrtsirkit
592
shrtsirkit  

Hi all.

I need some help in writing the code for an EA I am testing to be able to determine lot size based on account balance an the number of pairs being traded.

Thanks 

Simon Gniadkowski
17241
Simon Gniadkowski  
shrtsirkit:

Hi all.

I need some help in writing the code for an EA I am testing to be able to determine lot size based on account balance an the number of pairs being traded.

What specifically are you having problems with ?
shrtsirkit
592
shrtsirkit  
RaptorUK:
What specifically are you having problems with ?

Thanks for your reply.
I haven't a clue as to how begin to code this operation.  I have been using/modifying an exiting EA to make trades on a Global Variable input.  I would like to have this EA be able to calculate the lot size based on the account Balance and the # of Pairs been traded.  The EA now takes the trades.

William Roeder
20832
William Roeder  
You start with defining how you want to calculate lotsize given AB/nPairs.
string   active.market, active.prefix; 
void init(){
   active.prefix  = WindowExpertName() + "_";         #define CS_VISUAL    1
   active.market  = active.prefix + Symbol();
   if(!GlobalVariableSet(active.market, 0))  DisableTrading(
      "GlobalVariableSet(" + active.market + ")[2] Failed: " + GetLastError() );
}
int      deinit(){                                                OptComplete();
   if(!GlobalVariableDel(active.market))  Alert(
      "GlobalVariableDel(" + active.market + ") Failed: " + GetLastError() );
}
int   nPairs(){
   int      nWaiting = 1;     // Me and how many others CURRENTLY want to open.
   for(int iPos=GlobalVariablesTotal(); iPos >=0; iPos--){
      string   gvn = GlobalVariableName(iPos);
      if(StringFind(gvn, active.prefix) != 0)      continue;   // Wrong prefix.
      if(gvn == active.market)                     continue;   // Myself counted
      // datetime active = GlobalVariableGet(gvn); if(active == 0.){ Alert(
      //    "GlobalVariableGet(",gvn,") Failed: ", GetLastError());  continue;   }
      // if(timeCur.srv - active > 30)             continue;   // Expired.
      nWaiting++;
   }
   return(nWaiting);
}
shrtsirkit
592
shrtsirkit  
WHRoeder:
You start with defining how you want to calculate lotsize given AB/nPairs.


Thanks for your reply.  I am unable to see where to patch this code into the code for the EA I am using.  Is it possible to for you to help me with this if I send you the code? 

Thanks,

Kit 

To add comments, please log in or register