TP and SL are not the same
TP is 25 Points (Ask+25)
SL is 25 Points plus the spread (Bid-25)
I tried:
int Ticket = OrderSend(Symbol(), OP_BUY ,Lots, Ask, 3 ,(Ask - SL * Point) ,(Ask + TP * Point), "", 0, 0, clrGreen);
There is only a marginal difference.
The loss is still twice as big as the profit.
I tried:
There is only a marginal difference.
The loss is still twice as big as the profit.
I don't see how that is possible.
If a buy trade with a sl at Ask -25 Points and tp of Ask+ 25 Points, losses should be the same as wins, maybe a bit off because of marginal slippage.
Thank you guys for the fast help.
The total code now:
#property description "SimpleEA" #property version "000.001" input double SL = 25.0; input double TP = 25.0; input double Lots = 1.0; int OnInit() { return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { } int start() { int Total=OrdersTotal(); if (Total>0) return(0); int Ticket = OrderSend(Symbol(), OP_BUY ,Lots, Ask, 3 ,(Ask - SL * Point) ,(Ask + TP * Point), "", 0, 0, clrGreen); if(Ticket>0) Alert("BUY : ",Ticket); else Alert("BUY Error: ",GetLastError()); return(0); }
That is what i get in when testing.
The bug still occurs. A slippage that is doubling the losses is quite unusual isn't it?
Can someone maybe test my code?
Maybe there is no bug in the code, maybe the bug is elsewhere?
But there definitely is a bug?
Thank you guys for the fast help.
The total code now:
That is what i get in when testing.
The bug still occurs. A slippage that is doubling the losses is quite unusual isn't it?
Can someone maybe test my code?
Maybe there is no bug in the code, maybe the bug is elsewhere?
But there definitely is a bug?
The bug is in your code:
Ask is the higher price, and is the price that actually you get in when you buy. So, when you buy you already lost the spread.
You need to change the code to -
SL=ASK-SL
TP=ASK+TP
sorry - you get in at buy on the bid
Please try this
int Ticket = OrderSend(Symbol(), OP_BUY ,Lots, Ask, 3 ,(Bid - SL * Point) ,(Bid + TP * Point), "", 0, 0, clrGreen);
Hey, thanks.
Its not helping.
My complete code again:
#property description "SimpleEA" #property version "000.001" input double SL = 25.0; input double TP = 25.0; input double Lots = 1.0; int OnInit() { return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { } int start() { int Total=OrdersTotal(); if (Total>0) return(0); //int Ticket = OrderSend(Symbol(), OP_BUY ,Lots, Ask, 3 ,(Ask - SL * Point) ,(Ask + TP * Point), "", 0, 0, clrGreen); int Ticket = OrderSend(Symbol(), OP_BUY ,Lots, Ask, 3 ,(Bid - SL * Point) ,(Bid + TP * Point), "", 0, 0, clrGreen); if(Ticket>0) Alert("BUY : ",Ticket); else Alert("BUY Error: ",GetLastError()); return(0); }
Its even worse now.
Profit 13, loss is 42 for each trade.
Could you maybe test my code?
I've tested your code with the TP and SL based on the Ask price and get profits and losses of the same value (as you would expect).
Perhaps you should try a clean install of MT4?
Thanks, now it's working.
I think maybe something with the trading server was wrong, or some other settings.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I am a C++ programmer and completely new to mql4 and I like it very much.
There is a strange problem with all my Expert Advisors.
I made this extremely simple EA to demonstrate the bug.
Normally I expect this one to do whether wins nor losses. But it does lose all Money it gets.
The Reason for this is simple
Every loss is more than twice as big as each profit.
As you see in the Code the TP and SL limits have the same size.
Why dont't have loss and profit the same size???