
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
Try to use NormalizeDouble(price,Digits). Sometimes price of metatrader is not 1.2000 but 1.20020031023012 and the rest of the digits is a problem for metatrader when placing pending order. Use NormalizeDouble and it will be ok
Thanks so much Kalenzo, it's works now.
Define trading days
Deleted
Solution found!
Hi Coders
I try to insert a function in my EA to choose the trading days.
The function for trading hours works well.
For trading hours i use following:
extern string TradingHours = "TRADING HOURS";
extern bool UseHourTrade = True;
extern int FromHourTrade = 8;
extern int ToHourTrade = 18;
and later after int start:
if (UseHourTrade){
if (!(Hour()>=FromHourTrade && Hour()<=ToHourTrade)) {
Comment("Time for trade has not come else!");
return(0);
But what is needed for select the trading days?
When I define the extern as follow:
extern string TradingDays = "TRADING Days";
extern bool UseDayTrade = True;
extern int FromDayTrade = DayOfWeek;
extern int ToDayTrade = DayOfWeek;
then I have follow two messages:
'DayOfWeek'-variable expected
what's to do?
Somebody can help me?
Thanks for any help
GURU!!! Please Helpppp
Nevermind.....
Please Help everyone
i had a problem , how to make only 1 position open and 2 pending.
let just say Buy and Buystop , Sellstop.
i had an info before from someone in mql4, he use :
if(buystoporder>0 && sellstoporder>0)return(0);
and before that , he use switch(OrderType()).
I am confuse , where do i have to change the code?
i am ended in the buystop and sellstop open several times when i change the code, while if not, it wait until one is trigerred , reach their SL or TP and then make a new 2 pending.
My goal is 1 open and 2 pending, so when the open reach the SL or TP, one of the pending is trigerred, one isnot trigerred will be deleted. and make another 2 pending.
and Is it possible to put magic number in switch() option?
Greatly thanks for your help.
What is an easy statement to check to see if 2 moving averages have crossed within 5 bars before the current bar?? Can anybody help me with this??
Dave
-OR-
How do you state 5 conditional statements?? If all 5 are acceptable, a buyvalue=1 is stated.
I do not know if this would work below??: Can somebody comment on this as to whether it would work, if not, how should it be stated??
if(Condition1)
if(Condition2)
if(Condition3)
if(Condiition4)
if(Condition5)
{
buyvalue=1;
}
Dave
if(Condition2)
if(Condition3)
if(Condiition4)
if(Condition5)
{
buyvalue=1;
}
This is the most economical and fastest way to write multiconditional tests.
It's the fastest because if condition1 is not filled, condition 2, 3, ... are not evaluated, which is not the case if you put "&&" operator between them.
So begin with the most likely unfrequent condition.
So this will undoubtfully work.
Now, as you are often asking if something will work, the best is to try, its a good way to learn too.
Cheers.
What is an easy statement to check to see if 2 moving averages have crossed within 5 bars before the current bar?? Can anybody help me with this?? Dave
ma1_0 = iMA(....,0);
ma2_0 = iMA(....,0);
ma1_5 = iMA(....,5);
ma2_5 = iMA(....,5);
if((ma1_0 - ma2_0) * (ma1_5 - ma2_5) < 0) cross = true;How do I...
Hi there,
Please can you show me if you will, how do I say:-
"if the previous position closed on candle "0" or candle "1", then do not open another position on that same candle." or, even if candle "0" meets the required conditions to open another position... if the previous position closed on that candle then prevent it from opening another position, wait for the conditions to be right again.
I can say it in english but I'm still a bit too new to mql4 it.
thanks
amatrader
You might use the following code snippet:
for ( int i = OrdersHistoryTotal() - 1; i >= 0;i-- ) {
if ( ! OrderSelect( i, SELECT_BY_POS, MODE_HISTORY ) ) continue;
if ( OrderCloseTime() >= Time[ 1 ] ) {
last_order_closed_rather_recently = true;
break;
}
}
[/PHP]
after which you have the bool variable "last_order_closed_rather_recently" telling whether there was an order closed after the opening of bar 1. Then somewhere you'd have:
[PHP]if ( last_order_closed_rather_recently ) return( 0 );before entering a new trade.
Thank you sir, much appreciated.