ticket = OrderSend(NULL,OP_BUY,OptimalLotSize(maxRiskPrc,Ask,stopLossPrice),0,500,stopLossPrice,takeProfitPrice,NULL,magicnumber);
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum 2020.07.25
William Roeder:
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum 2020.07.25
I Have Changed NULL to SYBMOL(), But still the error is here.
The thing is that this Code is working fine on live, but this error appers only in Backtest.
You are buying at 0 with 500 slippage. Why don't you just buy at Ask?
Why do you do a RefreshRates() right before opening the order, so that your buying parameters do now belong to possibly outdated values?
lippmaje:
You are buying at 0 with 500 slippage. Why don't you just buy at Ask?
Why do you do a RefreshRates() right before opening the order, so that your buying parameters do now belong to possibly outdated values?
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
Hey Everyone!
I am having an issue, my EA is Working Fine in Live Market But when i run it on the Strategy tester it is not opening any trade and return Error is 138.
I have tried to Fix this issue by Reading many threads And i Have tried everything that i can get my Hands on, but the issue is still there.
It would be highly appreciated if Someone can help me out. I am New to this community and Autotrading.
Here is my Whole Code.