ea runs on my broker but not on another - page 2

 
GumRai:


Sorry, I had written more but the realised that I had made a mistake, so deleted the rest.

I haven't looked at your 2nd code, but I believe that I see an error in the 1st

There is no need for this code at all, I think

And change

to this

Also, you should get into the habit of using and printing GetLastError(). I can guess that you are probably using fairly large lot sizes and the 2 brokers have different StopLevels. You will probably find that GetLastError() returns 130, meaning that the stop is too close to price.

EDIT: I wrote leverage, when I meant StopLevels

 

I do need to work on error messages. Might not need to ask questions on the forum. I think?

 
WHRoeder:
No open order, ticket is invalid. Order on another pair, bogus processing.
What are Function return values ? How do I use them ? - MQL4 forum
order accounting - MQL4 forum
Assumes 10 digit broker and Ticksize == Point
Why is there NO Complete EA within the Code-Base? - MQL4 forum
Assumes forex only, no metals, no exotic pairs
Problems with a calculation - MQL4 forum
Slippage not adjusted for 4/5 digit brokers
Problems with a calculation - MQL4 forum
What are Function return values ? How do I use them ? - MQL4 forum
 

Thanks for the suggestions. I will research this.

 
forestmyopia:

I think I would run into trouble using the Point variable because of the existence of 4 or 5 decimal brokers. Not sure if Point accounts accurately for this.


Actually, it may be more accurate to use TickSize, but mostly it is the same as Point

In this piece of code, you do not calculate value per pip, but value for 1 tick movement, so with 5 digit brokers, your stop will be 10 times bigger than you want

value_per_pip = MarketInfo(Symbol(),MODE_TICKVALUE);
  equity = AccountEquity(); 
  a = equity * risk_factor;
  b = value_per_pip * lots;
  stop_loss_points =a/b - spread; 
  auto_stop_loss = 0;
 
forestmyopia:

I think I would run into trouble using the Point variable because of the existence of 4 or 5 decimal brokers. Not sure if Point accounts accurately for this.

Yes, of course it does.
 
Have you read the FOUR links I posted?
 
WHRoeder:
Have you read the FOUR links I posted?
I will work on it, thanks for the links.