Download MetaTrader 5

Trailing Bar Entry EA - page 3

To add comments, please log in or register
whroeder1
16353
whroeder1  
BenLinus: What I asked for is a way to exit the caller from inside a function.

What you asked for is something to give to your CEO to get your boss (and you) fired. Doesn't work in SW.

Once you return, your 'boss' is in charge. You can't force your 'boss' to do anything.

Ben Linus
245
Ben Linus  
WHRoeder:

What you asked for is something to give to your CEO to get your boss (and you) fired. Doesn't work in SW.

Once you return, your 'boss' is in charge. You can't force your 'boss' to do anything.


Lol.

It is conceivable at least. For example, I could give the CEO spoofed evidence that we are both involved in some questionable activities.We will both be fired.

Ben Linus
245
Ben Linus  

Anyway,

I worked something out:

I replaced all occurrences of OrderSelect() in start() with

        if (!OrderSelectAlert(index, select, pool=MODE_TRADES))   //order is now selected as a side effect
                return(0);

Where, OrderSelectAlert() is defined as follows:

bool OrderSelectAlert(int index, int select, int pool=MODE_TRADES) {
        if (OrderSelect(index, select, pool))   return(true);
        else{
                if(Closing_Alert_Made) return(false);   //This is a global variable in customs.mqh initialized to 0
                //order was not made and an alert was shown. start() should skip
                Alert("Ticket was not found.");
                Closing_Alert_Made = true;
                return(false);
        }
}


I don't know if this is good design. If ever I become a better, more experienced programmer I might know.

Matthias
42
Matthias  
double NormalizePrice(double p, string pair=""){
        // https://forum.mql4.com/43064#515262 zzuegg reports for non-currency DE30:
        // MarketInfo(chart.symbol,MODE_TICKSIZE) returns 0.5
        // MarketInfo(chart.symbol,MODE_DIGITS) return 1
        // Point = 0.1
        // Prices to open must be a multiple of ticksize 
    if (pair == "") pair = Symbol();
    double ts = MarketInfo(pair, MODE_TICKSIZE);

    return( MathRound(p/ts) * ts );
}
Added missing semicolon (red)
123
To add comments, please log in or register