Download MetaTrader 5

Experts: psar bug 3

To add comments, please log in or register
Looking for like-minded people? You will find lots of them on the Forum!
MetaQuotes Software Corp.
Moderator
181320
MetaQuotes Software Corp. 2010.07.09 07:31 

psar bug 3:

Opens and closes orders using parabolic SAR

Author: Tonny Obare

whroeder1
14519
whroeder1 2010.07.09 15:24  
  1. This solves incompatibility with some brokers e.g. for forex.com set it to 1 while for alpari and finexo leave it at 10.
    EA's should automatically adjust for 5 digit brokers not require manual changes. You don't adjust slippage.
    //++++ 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(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

  2. You also assume there are no other EA's running (on other pairs, or other time frames.)
        for(int pos = OrdersTotal() - 1; pos >= 0; pos--) if (
            OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
        &&  OrderMagicNumber()  == Magic.Number             // my magic number
        &&  OrderSymbol()       == Symbol() ){              // and period and symbol
    
Tonny Obare
1019
Tonny Obare 2010.07.09 20:21  
Both the three brokers tested are 5 digit but psar bug2 would work on forex .com but couldnt open orders on alpari and finexo unless you multiply stops by 10. Thats why in psar bug 3 i introduced this feature.
MQL4 Comments
16319
MQL4 Comments 2010.07.16 13:16  

I am using Fxopen . This error came out

Error when order select 130


2010.07.16 19:13:51 pSAR bug 3 USDJPY,M1: Error when order select 130


Please help

MQL4 Comments
16319
MQL4 Comments 2010.07.16 20:25  

Thanks for sharing, good stuff!

Best Performing Expert Advisors
Tonny Obare
1019
Tonny Obare 2010.07.23 11:07  
zalinarashid:

I am using Fxopen . This error came out

Error when order select 130


2010.07.16 19:13:51 pSAR bug 3 USDJPY,M1: Error when order select 130


Please help


Error 130 means invalid stops. First change StopMult to 1 if it doesnt work return it to 10 and check what your brokers minimum stops are.
MQL4 Comments
16319
MQL4 Comments 2010.09.01 18:31  

Hello to Author

May you change PSar to MTF selection, becose I trade at M5 chart but using M30 PSar as a Entry and H1 PSar as a Trend.

I relly appreciated that ypur work. Thank You

To add comments, please log in or register