Download MetaTrader 5
To add comments, please log in or register
Do you need a trading robot? Orderit via Freelance service!
Sven Hohmann
120
Sven Hohmann 2014.12.06 13:29 

Hello,

hello i want to know why MT4 has many different outputs in backtests? for example i test one EA with a profit possibilities of 10000$, the next day the EA is limited to 5000$ with the same parameter and timehorizon despite i didnt change anything in the code(or i am forgetful?)

For Example the EA ran yesterday lon Demo and made 2,5 R and now i didnt get any positive result in a backtest..

Is here anybody who had similar problems with it and what was the solution?  Is it a problem with the historical data or what could it be else? Is It a problem with using "Open Bars"(despite i just use close,high,etc of a candle?)

It is very annoying if it suddenly  dont works overnight any more and you dont know why..

install MT4 Again?


nice weekend

Carl Schreiber
5938
Carl Schreiber 2014.12.06 14:11  
What is the setup of the spread in the Tester? Fix or Current? If Current it is the last received spread of the _Symbol, which can be very high at weekends e.g.!
honest_knave
954
honest_knave 2014.12.06 14:17  
Sven Hohmann
120
Sven Hohmann 2014.12.06 18:06  
Thx i dont know if this is the main problem, but it is a reason too... i didnt know it and the spread is at the moment really high (3-6 Pips)..
Carl Schreiber
5938
Carl Schreiber 2014.12.06 18:15  
Pips? Are you sure? Spread is in Points! Just to be save!
Sven Hohmann
120
Sven Hohmann 2014.12.07 16:07  

Points? In Forex there are no points. there are just pips or fractional pips. there are points if you trade the DAX or something similar.

But can you change it really? The Profit changes, when i change the Spread, but the backtest are worse than normally and the report says Current(45) despite i changed the spread.

I will see it tomorrow..

Carl Schreiber
5938
Carl Schreiber 2014.12.07 18:50  

1) Read in the reference: MODE_SPREAD = "Spread value in points"

2) There are no Pips in Forex (anymore), it is just a kind of agreement!

whroeder1
13602
whroeder1 2014.12.07 20:05  
gooly: 2) There are no Pips in Forex (anymore), it is just a kind of agreement!
False. A pip is a defined value.

There is Tick, PIP, and Point. They are all different in general. A tick is the smallest change of price. A Point is the least significant digit quoted. In currencies a pip is defined as 0.0001 (or for JPY 0.01)

On a 4 digit broker a point (0.0001) = pip (0.0001). [JPY 0.01 == 0.01] On a 5 digit broker a point (0.00001) = 1/10 pip (0.00010/10). Just because you quote an extra digit doesn't change the value of a pip. (0.0001 == 0.00010) EA's must adjust pips to points (for mq4.) In currencies a tick is a point. Price can change by least significant digit (1.23456 -> 1.23457)

In metals a Tick is still the smallest change but is larger than a point. If price can change from 123.25 to 123.50, you have a TickSize of 0.25 and a point of 0.01. Pip has no meaning.

This is why you don't use TickValue by itself. Only as a ratio with TickSize. See DeltaValuePerLot()

Carl Schreiber
5938
Carl Schreiber 2014.12.07 20:39  
WHRoeder:
gooly: 2) There are no Pips in Forex (anymore), it is just a kind of agreement!
False. A pip is a defined value.

There is Tick, PIP, and Point. They are all different in general. A tick is the smallest change of price. A Point is the least significant digit quoted. In currencies a pip is defined as 0.0001 (or for JPY 0.01)

On a 4 digit broker a point (0.0001) = pip (0.0001). [JPY 0.01 == 0.01] On a 5 digit broker a point (0.00001) = 1/10 pip (0.00010/10). Just because you quote an extra digit doesn't change the value of a pip. (0.0001 == 0.00010) EA's must adjust pips to points (for mq4.) In currencies a tick is a point. Price can change by least significant digit (1.23456 -> 1.23457)

In metals a Tick is still the smallest change but is larger than a point. If price can change from 123.25 to 123.50, you have a TickSize of 0.25 and a point of 0.01. Pip has no meaning.

This is why you don't use TickValue by itself. Only as a ratio with TickSize. See DeltaValuePerLot()

You're right but it wont help! Mt4 and its brokers do not 'know' your definition of the Pip! Formally it was what is now mt4's _Point. But nowadays we have to calculate the pip ourself.

Some brokers already offer a tenth of others broker's _Point (e.g. Gold or share-indices).

So either you define in a long list for each symbol - actually more and more non-forex symbols are offered, for which your definition never was valid - or you define it differently!

I prefer this solution, which works for every symbol. I define 'my'  pip as the closest value of ~10 units of the account currency and I get not only the size of 'my' pip but even its no. of digits:

// use: int DIGs; double PIP; setPIP(sym, DIGs, PIP);
void setPIP(string sym, int &dig, double &pip, double refValue= 10.0){

      int       digis =  (int)MarketInfo(sym,MODE_DIGITS),
                xp    =  9, XP=0;
      double    tiV   =  MarketInfo(sym,MODE_TICKVALUE), 
                bst   =  9999999999;
                         
                while(xp>-9){
                        double m = pow(10,xp),
                               p = m*tiV,
                               d = fabs(p-refValue);
                        if ( d < bst ) {
                                XP = xp;
                                bst= d;
                        }
                        if (d>bst) break;
                        xp--;
                }
                
                dig = digis - XP;
                pip = pow(10,-dig);
                //Print("setPIP(",sym,"..,Ref:",DoubleToStr(refValue,2),")  Digits: ",digis,"  dig: ",dig," TickVal: ",DoubleToStr(tiV,2),"  pip: ",DoubleToStr(pip,Digits));
                //setPIP(XAUUSD..,Ref:10.00)  Digits: 3  dig: 1 TickVal: 0.08  pip: 0.100
                return;
}
whroeder1
13602
whroeder1 2014.12.07 21:07  
//++++ These are adjusted for 5 digit brokers.
int      pips2points;                  // slippage  3 pips  3=points 30=points
double   pips2dbl;                     // Stoploss 15 pips  0.0015   0.00150
int      digits_pips;                  // DoubleToStr(dbl/pips2dbl, digits_pips)
int      Oninit(){                                          OptInitialization();
    if(Digits % 2 == 1){   // DE30=1/JPY=3/EURUSD=5 https://www.mql5.com/en/forum/135345
            pips2dbl = Point*10;    pips2points = 10;    digits_pips = 1;
   } else { pips2dbl = Point;       pips2points =  1;    digits_pips = 0;     }
   // OrderSend(... Slippage_Pips * pips2points, Bid - StopLossPips * pips2dbl
//---- These are adjusted for 5 digit brokers.
Carl Schreiber
5938
Carl Schreiber 2014.12.07 21:49  

What about e.g. Gold, Dax, ..?

Gold: 4-Dec.-Borker 1 digit, 5-dec.-Broker (Hotforex) 2 digits, JFD 3 digits!

DAX: 4-Dec.-Broker (I don't know), 5-dec.-Broker (Hotforex) 0 digits, JFD 2 digits!

and so on..

Your code will fail or you have to add a long list of exceptions..

/ /12
To add comments, please log in or register