Hello everyone,
Here is my codes in the below for MQL 4. Whem it is compiled, there is no error but aside from some warnings. Since there is no error, i expect my code to work. However, it does not work, not send the order.
Is there anyone who knows why and how to fix it ? Any of your help will be appreciated. Thank you in advance for your time and support.
Best Regards.
Should resolve all compilation warnings as well, and check for any run time error messages.
Instead of 40, 20 and TakeProfit, experiment with larger values to see if there's any issue with your program's logic. If larger values work, that probably means 40, 20 and TakeProfit may be too small for your account (in which case, check the values of MODE_SPREAD and MODE_STOPLEVEL - refer to https://docs.mql4.com/constants/environment_state/marketinfoconstants).

- docs.mql4.com
-
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. - 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 - Post all relevant code and variable values. We have no Idea what type FASTma, UsePoint, TakeProfit is or their values.
- Why are you calling RefresRates? Does that mean that FASTma is invalid? Post all relevant code.
- emsahii: , there is no error but aside from some warnings. Since there is no error, i expect my code to work.Just because it compiles doesn't mean it will work. Use the debugger or print out your variables, including _LastError and prices and . Do you really expect us to debug your code for you?
- If you had
checked your return codes for errors, and
reported them including GLE/LE, your variable values and
the market, we would know that at least you are calling your code. Don't look at GLE/LE
unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles -
double PendingPrice = FASTma-40*UsePoint ; double SELLSTOP_STOPLOSS_LEVEL = PendingPrice + 20*UsePoint; double SELLSTOP_TAKEPROFIT_LEVEL = PendingPrice - TakeProfit*UsePoint ; ///????
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.)

- 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 everyone,
Here is my codes in the below for MQL 4. Whem it is compiled, there is no error but aside from some warnings. Since there is no error, i expect my code to work. However, it does not work, not send the order.
"
RefreshRates();
double PendingPrice = FASTma-40*UsePoint ;
double SELLSTOP_STOPLOSS_LEVEL = PendingPrice + 20*UsePoint;
double SELLSTOP_TAKEPROFIT_LEVEL = PendingPrice - TakeProfit*UsePoint ; ///????
///////////////////////////////
if( x_FASTma_pre1 > y_FASTma_pre1 && x_FASTma < y_FASTma)
SellTicket = OrderSend ( Symbol(), OP_SELLSTOP, 0.01, PendingPrice , UseSlippage, SELLSTOP_STOPLOSS_LEVEL, SELLSTOP_TAKEPROFIT_LEVEL, NULL, 0 ,0, clrDodgerBlue);
"
Is there anyone who knows why and how to fix it ? Any of your help will be appreciated. Thank you in advance for your time and support.
Best Regards.