-
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, 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[].
- You can't open a pending order at market prices.
You can't move stops (or pending prices) closer to the market than the minimum
(MODE_STOPLEVEL * _Point.)
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial - Where do you check if StopLossBuy is below Bid by stop level?
whroeder1:
-
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, 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[].
- You can't open a pending order at market prices.
You can't move stops (or pending prices) closer to the market than the minimum
(MODE_STOPLEVEL * _Point.)
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial - Where do you check if StopLossBuy is below Bid by stop level?
Could please explain its really hard to understand:
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- You can't open a pending order at market prices. You can't move stops (or pending prices) closer to the market than the minimum (MODE_STOPLEVEL * _Point.)
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial - I want to open a pending order at which price I can open a pending order?
- Where do you check if StopLossBuy is below Bid by stop level?
- I will check it later. I mean right now I am just trying to open a pending order.

High - Predefined Variables - MQL4 Reference
- docs.mql4.com
High - Predefined Variables - MQL4 Reference
whroeder1:
-
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, 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[].
- You can't open a pending order at market prices.
You can't move stops (or pending prices) closer to the market than the minimum
(MODE_STOPLEVEL * _Point.)
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial - Where do you check if StopLossBuy is below Bid by stop level?
LotSize = 0.05; // 0.05 Lot SLPips = 0.00030; // 3 pips TpFirstOrder = 0.00100; // 10 pips TpSecondOrder = 0.00150; // 15 pips StopLossBuy = Low[2] - SLPips; // BUY Stop Loss StopLossSell = High[2] + SLPips; // SELL Stop Loss double AskPrice= MarketInfo(_Symbol,MODE_ASK); double BidPrice= MarketInfo(_Symbol,MODE_BID); Ticket1=OrderSend(Symbol(),OP_BUYSTOP,LotSize,AskPrice+0.00030,3,StopLossBuy,AskPrice+0.00030+TpFirstOrder,"Pending Order 1",12254,0,clrGreen); if(Ticket1<0) { Comment("OrderSend failed with error #",GetLastError()); } else { Comment("OrderSend placed successfully"); }
Is this code is okay?
kumaillakhani:
Is this code is okay?
- Don't hard code numbers (as @whroeder1 said)
- StopLossBuy (and TakeProfit) still didn't check against StopLevel.
you will eventually still get error 130 (in the future) if you don't check.
LotSize = 0.05; // 0.05 Lot SLPips = 0.00030; // 3 pips TpFirstOrder = 0.00100; // 10 pips TpSecondOrder = 0.00150; // 15 pips StopLossBuy = Low[2] - SLPips; // BUY Stop Loss StopLossSell = High[2] + SLPips; // SELL Stop Loss double AskPrice= MarketInfo(_Symbol,MODE_ASK); double BidPrice= MarketInfo(_Symbol,MODE_BID); Ticket1=OrderSend(Symbol(),OP_BUYSTOP,LotSize,AskPrice+0.00030,3,StopLossBuy,AskPrice+0.00030+TpFirstOrder,"Pending Order 1",12254,0,clrGreen); if(Ticket1<0) { Comment("OrderSend failed with error #",GetLastError()); } else { Comment("OrderSend placed successfully"); }

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,
I am getting error # 130 while trying to OrderSend() in MQL4.
Experts please help me where I am making mistake?