emsahii:
Hello Everybody!
I am about to lose my mind. Why doesn't my code work? Where am i mistaken ? Could you pls guide me and gimme a hand? I really appreciate. Thanks in advance for your help and your time that you are gonna spare !
Here is the code. Please check it out.
Hi,
I see many problems but you can start from the following:
False: int ticket = OrderSend(_Symbol,OP_SELLSTOP,LotSize,PendingPrice,MySlippage,StopLoss,TakeProfit,"SELL",MagicNumber); Correct: int ticket = OrderSend(_Symbol,OP_SELLSTOP,LotSize,PendingPrice,MySlippage,PendingPrice+StopLoss*MyPoint,PendingPrice-TakeProfit*MyPoint,"SELL",MagicNumber); False: int ticket = OrderSend(_Symbol,OP_BUYSTOP,LotSize,PendingPrice,MySlippage,StopLoss,TakeProfit,"BUY",MagicNumber); Correct: int ticket = OrderSend(_Symbol,OP_BUYSTOP,LotSize,PendingPrice,MySlippage,PendingPrice-StopLoss*MyPoint,PendingPrice+TakeProfit*MyPoint,"BUY",MagicNumber);
emsahii: Why doesn't my code work? Where am i mistaken ?
-
Why did you post your MT4
question in the Root / MT5 General
section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. - Use the debugger or print out your variables, including _LastError and prices and . Do you really expect us to debug your code for you?
- Had you done № 2 you would have found Arash is almost correct.
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.)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello Everybody!
I am about to lose my mind. Why doesn't my code work? Where am i mistaken ? Could you pls guide me and gimme a hand? I really appreciate. Thanks in advance for your help and your time that you are gonna spare !
Here is the code. Please check it out.