[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 223

 
solnce600:

Gentlemen! Good evening!

Could you please tell me why the compiler thinks that in the code below

the int Ticket variable is undefined.

It generates one error

'Ticket' - variable not defined C:\Program Files\Alpari NZ MT4(2)\experts\hhhh.mq4 (18, 6)

But the Ticket variable is also defined in the assignment statement in the code below and the code compiles successfully

The int Ticket variable is local and will be reset on the next tick.
 
Vinin:


Probably just missing brackets in one place

Problem solved. Thank you very much.
 
TarasBY:
The int Ticket variable is local and will be reset on the next tick.
The remark is taken into account. Thank you very much.
 

I've run into this problem.

I need to initialise a one-dimensional array of type double for 3000 bid price values, all values are different and are not in order.

I have to manually enter each value separated by comma - not realistic.

I tried with excel, but if I put a dot instead of a floating point, excel doesn't read the numbers to put a comma between them.

Please suggest the best option.


 

I wrote a simple Expert Advisor that returns 3 variables and passes them to start().

Then on each tick these data (object type, price1 and price2) should be returned.

//+-------------------------------------------------------------------------------------+
//|                                                TradingByLine.mq4                    |
//|                                                              hoz                    |
//|                                                                                     |
//+-------------------------------------------------------------------------------------+
#property copyright "hoz"
#property link      ""

string objName;
int isObj,
    objType;
double price1,
       price2;

//+-------------------------------------------------------------------------------------+
//| Функция иницилизации                                                                |
//+-------------------------------------------------------------------------------------+
int init()
{

   

  return(0);
}
//+-------------------------------------------------------------------------------------+
//| Функция деиницилизации                                                              |
//+-------------------------------------------------------------------------------------+
int deinit()
{
//----
   
//----
  return(0);
}
//+-------------------------------------------------------------------------------------+
//| Блок поиска своих объектов                                                          |
//+-------------------------------------------------------------------------------------+
bool IsObjectFound(double& price1, double& price2, int& objType)
{
   for (int obj=0; obj<=ObjectsTotal()-1; obj++)
   {
      objName = ObjectName(obj);
      isObj = ObjectFind(objName);
      price1 = ObjectGet("objName", OBJPROP_PRICE1);
      price2 = ObjectGet("objName", OBJPROP_PRICE2);
      objType = ObjectType("objName");

      if (isObj != -1)
         return(true);
   }
   return(false);
}
//+-------------------------------------------------------------------------------------+
//| Функция start                                                                       |
//+-------------------------------------------------------------------------------------+
int start()
{
   if (!IsObjectFound(price1, price2, objType))
      return(0);
   Print("objType = ", objType);
   Print("price1 = ", price1, ", price2 = ", price2);

  return(0);
}

Then I run this Expert Advisor in visualization mode in the tester and draw a line in the chart by hand. The drawing prices and the object type I got in theIsObjectFound() function do not return correct. Here is the log output:

2013.03.16 20:12:46     2013.01.24 00:02  TradingByLine EURJPY,M1: objType = -1
2013.03.16 20:12:46     2013.01.24 00:02  TradingByLine EURJPY,M1: price1 = 0, price2 = 0
2013.03.16 20:12:46     2013.01.24 00:02  TradingByLine EURJPY,M1: objType = -1
2013.03.16 20:12:45     2013.01.24 00:01  TradingByLine EURJPY,M1: price1 = 0, price2 = 0
2013.03.16 20:12:45     2013.01.24 00:01  TradingByLine EURJPY,M1: objType = -1
2013.03.16 20:12:45     2013.01.24 00:01  TradingByLine EURJPY,M1: price1 = 0, price2 = 0
2013.03.16 20:12:45     2013.01.24 00:01  TradingByLine EURJPY,M1: objType = -1
2013.03.16 20:12:44     2013.01.24 00:01  TradingByLine EURJPY,M1: price1 = 0, price2 = 0

The line is hand-drawn, which means it has a type and other parameters:

The line

Why are the required parameters not returned?

 
solnce600:

I've run into this problem.

I need to initialise a one-dimensional array of double type for 3000 bid price values, all values are different and are not in order.

It's not realistic to manually enter each value separated by a comma.

I tried it with excel but if I put a dot instead of a floating point excel doesn't read the numbers to put a comma between them.

Please suggest the best option.


Excel can read, show me more details of how you did it
 
hoz:

I wrote a simple Expert Advisor that returns 3 variables and passes them to start().

Then on each tick these data (object type, price1 and price2) should be returned.

Then I run this Expert Advisor in visualization mode in the tester and draw a line in the chart by hand. The drawing prices and the object type I got in theIsObjectFound() function do not return correct. Here is the log output:

The line is hand-drawn, which means it has a type and other parameters:

Why aren't the required parameters returned?

We have to

price1 = ObjectGet("objName", OBJPROP_PRICE1);
      price2 = ObjectGet("objName", OBJPROP_PRICE2);
      objType = ObjectType("objName");

objName without quotes. This is the variable name (identifier in the program text) that contains the object name (string)

 
alsu:

It should be

objName without quotes. This is the variable name (identifier in the program text) that contains the object name (string)



By the way, the documentation thinks otherwise. That's where I got caught up in the confusion.

documentation error

 
alsu:

Excel can read it, show me more details how to do it

In the line of 100 values with a comma after the first sign (ie, price)

Highlighting a line

Home - find and replace

Changing all the commas to dots - successful.

Now we have to put commas between the values

I select the format of the cells

All formats

In the active field that displays the number format of my string - I put a comma at the end

Exel says he is unable to process the format I have entered.

 
hoz:


By the way, the documentation thinks otherwise. So I've been misled.

The quotes are the VALUE of the string variable, not the variable itself!!!!
Reason: