- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
double price=NormalizeDouble((Bidy+… double takeprofit=NormalizeDouble((Bidy+…
You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP would be longer. Don't you want the same/specified amount for either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To
trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (Control-O) → charts → Show ask line.)
- Use the debugger or print out your variables, including _LastError and prices and . Do you really expect us to debug your code for you?
- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell
orders you pay the spread on close.
- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP would be longer. Don't you want the same/specified amount for either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches
it. To trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (Control-O) → charts → Show ask line.)
- Use the debugger or print out your variables, including _LastError and prices and . Do you really expect us to debug your code for you?
the spread is FAR bigger than ANY kind of spread between Ask and Bid... even if I would deal with major broken house of a market maker.
and not sure if using just the Bid (as I think you try to propose) would help to cut a 20 pip difference between my declared SL and the intended one.
i see no solution in your answer, further more: SL is wrong in both cases for BUY and SELL ! therefore you didn't identified the issue. at all.
about debugging code... i think my code is compiled and working. not working as expected, indeed.
and this is why I am here. if you can be positive and offer a solution please do it.
note: this happened on EURGBP and GBPUSD on a very reputable ECN trading platform.
the spread between Ask and Bid cannot be 20 pip for these pairs...
I did what you propose to show the Ask line... and the result so far is zero... meaning that I checked the indicated box on Charts from Tools/Options and nothing pops on the screen... (an error maybe ?).
note: i added the orders in the presented code in the Alt+S box... maybe that will clarify further what my position is...
much appreciated,
C
The issue: SL is not as per definition - at 5 pips. TPs are working fine !!!
You compute your stoploss this:
double stoploss=NormalizeDouble((ArrMA20H4[i]-minstoplevel*ArrPoints[i]-LSL*ApointArr[i]*ArrPoints[i]),ArrDigits[i]);
or
stoploss=NormalizeDouble((ArrMA20H4[i]+minstoplevel*ArrPoints[i]+LSL*ArrPoints[i]*ApointArr[i]),ArrDigits[i]);
So the key is the value of "ArrMA20H4[i]" right? If it's 100 pips away from your open price, then it'll be 100 pips on top of "minstoplevel*ArrPoints[i]+LSL*ArrPoints[i]*ApointArr[i]".
- www.mql5.com
You compute your stoploss this:
or
So the key is the value of "ArrMA20H4[i]" right? If it's 100 pips away from your open price, then it'll be 100 pips on top of "minstoplevel*ArrPoints[i]+LSL*ArrPoints[i]*ApointArr[i]".
yes sir - correct. i would guess than that the rest is fine and only that variable would be at fault ? if this is the case i will double check.
thank You Seng !
yes sir - correct. i would guess than that the rest is fine and only that variable would be at fault ? if this is the case i will double check.
thank You Seng !
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Brothers & Sisters
I have a new challenge which is really confusing my brain out... and I run out of energy.
I also would like to share this code with you - as a reward and showing that MT4 is a truly capable platform.
The issue: SL is not as per definition - at 5 pips. TPs are working fine !!!
My SL goes actually at 25 pips - instead of 5 pips and i do not think is about the minstoplevel variable... what am I doing wrong ?
Kindly, please advise.
Much appreciated !
Kind regards
C