Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1243

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
I don't have the slightest desire to google or read, so I opened file D:\1.txt
What is the best way to do it in the indicator, to start timer 1s or in OnCalculate to compare time (seconds)
<1sec, exit
or there are other working options?
need to update HistorySelect for the month + work with objects
or in OnCalculate compare time (seconds)
<1sec, output
seconds is not enough. The problem is with datetime - it can't be less than a second.
compare at least milliseconds
what is better to do in the indicator, to start a timer 1s or in OnCalculate to compare time (seconds)
it is not important where to do it, the only thing that OnCalculate is related to ticks - there will be no tick and therefore there will be no OnCalculate call
you need to update HistorySelect for a month + work with objects
HistorySelect is fast, but when you go to move or create objects, there may be lags, if objects over 1000 +
and you will be modifying these objects every second
(enter your code and the pitfalls will pop up ))))
a second is enough for me and less often until the tick comes
for me to display trades on the chart + result of the trade over bars, and some semi-static information such as the global trend
can price watch the change from
or time from the second option
Please tell me!
How can I compare the current chart symbol with the one I need?
I need the program to open an order on AUD/USD, so it opens the order (it works properly). However, the program tries to open the order on other open charts(the robot is running on several currency pairs) and it returns a price error for the other currency pairs where the Expert Advisor is running. I have to make a comparison and if Symbol() == is equal to the symbol on which the order should be opened, then we open it and if not, we exit. I haven't found anywhere how to set the symbol name from the terminal and make the comparison.
Please tell me!
How can I compare the current chart symbol with the one I need?
I need the program to open an order on AUD/USD, so it opens the order (it works properly). However, the program tries to open the order on other open charts(the robot is running on several currency pairs) and it returns a price error for the other currency pairs where the Expert Advisor is running. I have to make a comparison and if Symbol() == is equal to the symbol on which the order should be opened, then we open it and if not, we exit. I haven't found anywhere how to set the symbol name from the terminal and make comparison.
There is an example of getting the right prices at the end.
Thank you, but I don't need the right prices. The prices are fine. I need the EA not to open an order if the currency pair at which the order is opened is not the same as the current open chart to which the robot is attached. Maybe we may implement this by opening a new chart with a timeframe, open a desired order in it and then close the chart.
No, it doesn't work that way.
My program accesses the current chart, assigns to it the name of the current instrument and seals it into a variable, then compares the value of this variable to the current symbol on the chart. It actually compares it to itself)))) I need to somehow convert Sympol() to any value with which any other variable can be compared. For example:
AUDUSD;
(Symbol() == AUDUSD)
I've somehow managed to do it - while I was rejoicing and changing everything correctly - nothing works anymore))
No, it doesn't work that way.
My program accesses the current chart, assigns it the name of the current instrument and seals it into a variable, then compares the value of this variable to the current symbol on the chart. It actually compares it to itself)))) I need to somehow convert Sympol() to any value with which any other variable can be compared. For example:
AUDUSD;
(Symbol() == AUDUSD)
I've managed it somehow, until I was happy and changed everything correctly - nothing works))
string AUDUSD = "AUDUSD";
At least like this.
No, it doesn't work that way.
My program accesses the current chart, assigns it the name of the current instrument and seals it into a variable, then compares the value of this variable to the current symbol on the chart. It actually compares it to itself)))) I need to somehow convert Sympol() to any value with which any other variable can be compared. For example:
AUDUSD;
(Symbol() == AUDUSD)
I did it somehow, and while I was rejoicing and changing everything, nothing worked anymore))
The Expert Advisor, the script, the indicator do not apply, but work in the current window. And global variables of different windows / charts do not overlap. Therefore, it should work)
string AUDUSD; // This is a text variable, which is initially empty, i.e. equals ""
(Symbol() == AUDUSD) // this string has nothing to do with variable AUDUSD.
But the order opening criteria should not be the same for different instruments/windows. If they are the same, they will indeed open in all windows.