Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
Yes,
You are comparing strings.
This will not work. Your times need to be in datetime variable type for the comparison you are doing.
Dominik Egert:
Thank you.
Yes,
You are comparing strings.
This will not work. Your times need to be in datetime variable type for the comparison you are doing.
Forexalpha777:
Could someone please tell me
How to add if false == ordersend();
Although I add these coding, EA still open positions.
you can use this code instead:
input string Time_Start_Hour = 2; input string Time_Start_Minute = 0; input string Time_End_Hour = 21; input string Time_End_Minute = 0; extern bool Filter_TradingTime=true; uchar hour = Hour(); uchar minute = Minute(); void OnTick() { TradingTime(); } bool TradingTime() { if(Filter_TradingTime) { if(hour >= Time_Start_Hour && hour<=Time_End_Hour) return true; else return false; } }
and about orderSend function, it returns an integer value
and when no order opened, it returns -1
you should write such this:
int ticket = OrderSend(); if (ticket <0) or if(ticket ==-1)
I suggest not using strings to do such comparison.
Strings are characters. In MQL5 they are Unicode. This type of comparison is considered inconsistent.
Mohsen Bjp:
Appreciate it. I will try.
you can use this code instead:
and about orderSend function, it returns an integer value
and when no order opened, it returns -1
you should write such this:
Dominik Egert:
Strings are characters. In MQL5 they are Unicode. This type of comparison is considered inconsistent.
I suggest not using strings to do such comparison.
Strings are characters. In MQL5 they are Unicode. This type of comparison is considered inconsistent.
Thank you for the advice
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
Could someone please tell me
How to add if false == ordersend();
Although I add these coding, EA still open positions.