EA ignores MM routine

 

I have an EA that includes money management and account type routines. If the account has 5 digits which isa choice by extern variable, it mutplies the SL and TP by 10. Also, it calculates lot size by percentage of risk entered also by extern variable. Bothe of these routines work fine, except for the first time after a restart of the EA. The first time it runs, it comes in with .1 lots no matter what was entered in the exter variable for risk, and the TP and SL are 10x what thney should be. The next time entry parameters are met, it works fine witnh the proper lot size and SL and TP. What could be causing thsi?

 

Sounds like the desired MM calculation function is not called from init() or start() and only gets called at the start of some other function which is responsible for calling OrderSend(). Find the call and duplicate it in init().

CB

 
If you have
extern SLpips = 30;
init() { if (broker5Digits) SLpips *= 10;

This won't work reliable because a chart refresh (change period, or tester optimization) will result in 30, 300, 3000 etc. Also the user shouldn't have to change values just because he switched brokers.

Don't modify extern or global variables. Let the EA adjust for brokers:

//++++ These are adjusted for 5 digit brokers.
double  pips2points,    // slippage  3 pips    3=points    30=points
        pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int init() {
    if (Digits == 5 || Digits == 3) {   // Adjust for five (5) digit brokers.
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... SlippagePips * pips2points, Bid - StopLossPips * pips2dbl