Dear forumchane! Please tell me how to make the expert Advisor (for example, thisone ) work forcibly on one pair, what you need to change, what you can “wrap the code” with”:
– if we select any other pair in the tester, only the one specified in the code works
– if we throw any other pair on the chart, only the one specified in the code works
issah5
Thank you all! I sort of figured it out.
andreifan
))))) Let the author of the topic catch it. I know how to do that.
And I didn’t start.
I just always try to follow the letter of the TOR.
But I agree – the question in the title really requires clarification from the customer – what he meant. And it is the programmer’s responsibility to ask these questions.
P. S, I look at everything from The side of a freelance Performer.
iks_
That’s exactly what allows it. There are situations, especially on cents, when you need to limit the currency pair, and in the set all the characters with prefixes. Therefore, a hard binding to a single character is not quite correct.
andreifan
Your code will allow you to work with a different symbol, if the broker has a symbol with the prefix, Eurusd_c
You need to check full compliance.
issah5
if (StringFind(Symbol(), "EURUSD") != -1){....}
Thanks! Do you need to wrap each function and data type?
in OnInit(), OnTick (), bool, etc.
barabashkakvn
Please note that the example given above is only a General recommendation is to introduce an input parameter. In addition, you need to look at the rest of the code, understand the algorithm and, if necessary, explicitly prescribe access to the specified character from the input parameters.
That is, one input parameter is usually not enough.
iks_
Prohibit working on all characters except the one you allow. StringFind will help you with this.
issah5
Thank you all!
barabashkakvn
Specifically for the specified expert Advisor ( N-_Candles_v3), you need to add the input parameter “Trade sybmol“
//--- input parameter
input string InpSymbol = "AUDUSD"; // Trade sybmol
//...
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
m_symbol.Name(InpSymbol); // sets symbol name
and pass this input parameter to the Name method
fxsaber
Insert these lines at the beginning of any expert Advisor
#define _Symbol2 "EURUSD" // The expert Advisor will only work with this symbol, but OnTick will go from the one on which it is running
string Symbol2() { return _Symbol2; }
#define Symbol Symbol2
#define _Symbol _Symbol2