-
Why did you post your MT4
question in the Root / MT5 EA
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. -
openOrderID = OrderSend(NULL,OP_BUYLIMIT,lotSize, …
Don't use NULL.- 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. OrderSenddoes 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[].
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
double stopLossPrice = NormalizeDouble(High[2]-0.2*(High[2]-Low[2]),Digits);
double takeProfitPrice = NormalizeDouble(High[2]+0.8*(High[2]-Low[2]),Digits);
double lotSize = OptimalLotSize(riskPerTrade,NormalizeDouble(High[2]+0.1*(High[2]-Low[2]),Digits),stopLossPrice);
openOrderID = OrderSend(NULL,OP_BUYLIMIT,lotSize,NormalizeDouble(High[2]+0.1*(High[2]-Low[2]),Digits),10,stopLossPrice,takeProfitPrice,NULL,magicNB);
if(openOrderID < 0) Alert("order rejected. Order error: " + GetLastError());
i keep getting OrderSend Error: 130 with this code but I cant seem to find the problem. Im backtesting on USDJPY. Any help would be appreciated.
2020.01.26 10:53:33.920 2020.01.21 00:00:00 Inside Bar Momentum Strategy USDJPY,Daily: Entry Price = 110.314
2020.01.26 10:53:33.920 2020.01.21 00:00:00 Inside Bar Momentum Strategy USDJPY,Daily: Stop Loss Price = 110.242
2020.01.26 10:53:33.920 2020.01.21 00:00:00 Inside Bar Momentum Strategy USDJPY,Daily: Take Profit Price = 110.484
2020.01.26 10:53:33.920 2020.01.21 00:00:00 Inside Bar Momentum Strategy USDJPY,Daily: OrderSend error 130
2020.01.26 10:53:33.920 2020.01.21 00:00:00 Inside Bar Momentum Strategy USDJPY,Daily: Alert: order rejected. Order error: 130
I have checked if the stops are too close to the entry price but they are not.