Download MetaTrader 5
To add comments, please log in or register
Do you need a programmer? Freelance service will find the developer you need!
The Xlearner
224
The Xlearner 2014.12.30 13:16 
Good morning 

I test my EA on the strategy tester with EURUSD , and it works , but when I test it with another symbol , it shows me a huge number of error , I try to close all the windows in the metatrader and restart it and try with another symbol ,it works , what confusing me , why didn't work from the first time .

Thanks in advance.

whroeder1
13656
whroeder1 2014.12.30 13:50  
xlearner: it shows me a huge number of error
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. Most likely "unmatched data errors."
The Xlearner
224
The Xlearner 2014.12.30 14:57  
WHRoeder:
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. Most likely "unmatched data errors."

LoL . 

No , it's not the ummatched data errors .

In this case I try with the EURUSD .. fine No errors ...


But , after this I change the Symbol , and this is whats happen


whroeder1
13656
whroeder1 2014.12.30 16:38  
  1. What part of "There are no mind readers here" was unclear? How should we know what is wrong with your code (130) when we can't see it?
  2. Most likely you are not adjusting pips for JPY. 
The Xlearner
224
The Xlearner 2014.12.30 18:48  
WHRoeder:
  1. What part of "There are no mind readers here" was unclear? How should we know what is wrong with your code (130) when we can't see it?
  2. Most likely you are not adjusting pips for JPY. 

Pips are adjusted for the 5 and 3 digits !

This is the code :
void Trailingstop 
{
   double tssl,tbsl;
   for( int b = OrdersTotal()-1; b>=0; b-- )
   {
      if(OrderSelect( b, SELECT_BY_POS, MODE_TRADES)&&OrderMagicNumber() == magicNumber&&OrderSymbol() == Symbol())
      {
               if(OrderType() == OP_BUY)
               {
                        if(Bid - OrderOpenPrice()>(WhenToTrail+0.5)*pips && OrderStopLoss()<Bid - (TrailAmount+0.5)*pips )/*&bsl != OrderStopLoss()*/
                        {
                           tbsl=Bid-TrailAmount*pips;
                           if (MathAbs( tbsl-Bid ) <stoplevel*pips)
                           {
                              tbsl=Bid-stoplevel*pips;
                           }
                           if (!OrderModify( OrderTicket(), OrderOpenPrice(), tbsl, OrderTakeProfit(), 0, CLR_NONE ))
                           {
                              Print("Buy Order Modify TS Error n° ", GetLastError()," . Bid - TrailAmount*pips = ",Bid - TrailAmount*pips ," . The Bid = ",Bid);
                           }
                           
                           
                        }
               }

   
               if(OrderType() == OP_SELL)
               {
                  if(OrderOpenPrice() - Ask >(WhenToTrail+0.5)*pips && (OrderStopLoss() >Ask + (TrailAmount+0.5)*pips || OrderStopLoss() == 0))
                  {
                        tssl=Ask+TrailAmount*pips;
                        if(MathAbs( tssl-Ask ) <stoplevel*pips)
                        {
                           tssl=Ask+stoplevel*pips;
                        }
                        if (!OrderModify( OrderTicket(), OrderOpenPrice(), tssl , OrderTakeProfit(), 0, CLR_NONE ))
                        {
                           Print("Sell Order Modify TS Error n° ", GetLastError()," . Ask + TrailAmount*pips = ",Ask + TrailAmount*pips," . The Ask = ",Ask);
                        }
                        
                     //}
                  }  
               }
      }
   }
}
Alain Verleyen
Moderator
28705
Alain Verleyen 2014.12.30 19:47  
xlearner:


Your TS is too close to market price. See https://book.mql4.com/appendix/limits
whroeder1
13656
whroeder1 2014.12.30 21:28  
 tbsl=Bid-TrailAmount*pips;
 if (MathAbs( tbsl-Bid ) <stoplevel*pips)
  1. What part of "There are no mind readers here" was unclear?
  2. How should we know what pips is when we can't see it?
  3. How should what know what stoplevel is when we can't see it? If it's MarketInfo(MODE_STOPLEVEL) which is the minimum number of points, why are you multiplying it by pips?

    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()

The Xlearner
224
The Xlearner 2014.12.30 23:55  
angevoyageur:
Your TS is too close to market price. See https://book.mql4.com/appendix/limits
I test if the stoploss is too close to stoplevel !!!
if(MathAbs( tssl-Ask ) <stoplevel*pips)
                        {
                           tssl=Ask+stoplevel*pips;
                        }
Alain Verleyen
Moderator
28705
Alain Verleyen 2014.12.31 00:27  
xlearner:
I test if the stoploss is too close to stoplevel !!!
Obviously, you don't do it correctly. Answer to WHRoeder's post please.
/
To add comments, please log in or register