Forum on trading, automated trading systems and testing trading strategies
Hello,
Please EDIT your post and use the SRC button when you post code.
Thank you.
- When you post code please use the SRC button! Please edit your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum int currentOrder = OrderTicket();
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.- You can not use any
Trade Functions until you select an order.
int OnStart(){
Invalid signature, and is only used in scripts, not in EAs
Program Running - MQL4 programs - MQL4 Referencevoid OnStart none scripts Start event handler. bool OrderDelete( int ticket, // ticket color arrow_color // color );
The function is predefined in MT4.
OrderDelete - Trade Functions - MQL4 ReferenceOrderDelete(currentOrder); return(1); Print("Cannot order, spread is too high");
You can only delete pending orders.- Check your return codes for errors and report them.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - Do you expect to ever see that message?
- Of course your "code needs updates." A) It doesn't compile. B) It doesn't create orders. C) All of the above.
Hi,
Need an EA having input as :
"maximum spread allowed" : (any number like 10/20)
Now, suppose I try to place order and if spread at that time is less than or equal to defined number in input parameter, order should be placed.
If spread is grater than number defined in input parameter, reject the order with message "Order rejected because of high spread"
I am newbie in mql4 coding, here is my code :
==============================================
#property strict
#property show_inputs
extern int MaxSpread=0;
int OnStart()
{
//—
//Max Spread in pipettes
int currentOrder = OrderTicket();
if(MarketInfo(Symbol(), MODE_SPREAD)<MaxSpread){
Print("I can order");
return(0);
}
else{
OrderDelete(currentOrder);
return(1);
Print("Cannot order, spread is too high");
}
}
//+——————————————————————+
bool OrderDelete(
int ticket, // ticket
color arrow_color // color
);
=============================================================================
Error while attaching to the chart :
<name of EA> is not an expert and cannot be executed
also please let me know if code is correct or need updates.
Regards.
Your code need to be re-written, this is like a full job you are asking, if you can't update your code
There is always the freelancer section.
The idea of EA you want will have fewer trade as you can expect, cause spread constantly change or increase when the best possible entry occur.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Need an EA having input as :
"maximum spread allowed" : (any number like 10/20)
Now, suppose I try to place order and if spread at that time is less than or equal to defined number in input parameter, order should be placed.
If spread is grater than number defined in input parameter, reject the order with message "Order rejected because of high spread"
I am newbie in mql4 coding, here is my code :
==============================================
#property strict
#property show_inputs
extern int MaxSpread=0;
int OnStart()
{
//—
//Max Spread in pipettes
int currentOrder = OrderTicket();
if(MarketInfo(Symbol(), MODE_SPREAD)<MaxSpread){
Print("I can order");
return(0);
}
else{
OrderDelete(currentOrder);
return(1);
Print("Cannot order, spread is too high");
}
}
//+——————————————————————+
bool OrderDelete(
int ticket, // ticket
color arrow_color // color
);
=============================================================================
Error while attaching to the chart :
<name of EA> is not an expert and cannot be executed
also please let me know if code is correct or need updates.
Regards.