Experts: psar bug 3

 

psar bug 3:

Opens and closes orders using parabolic SAR

Author: Tonny Obare

 
  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
    
 
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.
 

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

 

Thanks for sharing, good stuff!

Best Performing Expert Advisors
 
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.
 

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