[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 233

 
hoz:

How many times have I used the autopoint, but the first time doesn't work.

Here is Init()

I put it in any place of my program (in this case, even in the start for the experiment):

The function returns to the log:

Where is the logic?

VladislavVG told me:Because at the init() function you are not guaranteed to load the data of the financial instrument.
 
GaNDarM:
VladislavVG has suggested it to me:Because at the init() function stage you are not guaranteed to load data of the financial instrument.

So, value of variable Point without Init() should return the same...
 
hoz:
Why would there be nonsense if the function returns an object name specifically?
And you are 100% sure that this function will always and everywhere work correctly, it won't glitch somewhere or choke on some tricky object name, or you yourself won't accidentally slip the number of a non-existent object into it, all of a sudden? And the result returned from the function cannot be used to judge whether it worked correctly or not. This is what it says in the documentation. The only correct way is to get the error code and then work around it. This is how you protect yourself against your own (or someone else's) blunders.
 
hoz:

How many times have I used the autopoint, but the first time it doesn't work.


Where's the logic?

Try it like this:

int init()
{
   if (Digits == 2 || Digits == 4)
     pt = MarketInfo(Symbol(), MODE_POINT);
   if (Digits == 1 || Digits == 3 || Digits == 5)
     pt = MarketInfo(Symbol(), MODE_POINT) * 10;
 
  return (0);
}

Not even like this, but like this:

int init()
{
   int MyDigits = MarketInfo(Symbol(), MODE_DIGITS)
   if (MyDigits == 2 || MyDigits == 4)
     pt = MarketInfo(Symbol(), MODE_POINT);
   if (MyDigits == 1 || MyDigits == 3 || MyDigits == 5)
     pt = MarketInfo(Symbol(), MODE_POINT) * 10;
 
  return (0);
}

Because Digits is an internal variable, just like Piont.

That should work :)



 
hoz:

So the value of Point variable without Init() should return the same...

It's not a fact... Point is an internal variable of MQL processor and it requires some time and some initialization actions. All this usually happens only before the processor calls start() and at the stage of init() the values of the processor's internal variables may not be set.
 
GaNDarM:


"Crying" about it:

and here's the log:

18:25:09 IndikatorZZ GBPJPY,Daily: F_CYF INIT: DownL = 0 UpL = 0


Variables are not int by any chance?


I've caught myself like this a couple of times

 
ilunga:

Variables by any chance int?


I've caught myself doing that a couple of times


No, double. What's wrong with int, I wonder?
 
Hello! A situation occurred on the previous day. On 19.03.2013 around 17-00 GMT I placed an order to place a Sell stop. The open price was 1.2903, Stop loss 1.2913, trailing stop 15 pips, M15, lot -0.5. As the account history shows, the position was opened at 17-49. The position was closed at 21:15 again by GMT with the profit minus 90. When I saw the history, I got a lot of questions in my mind. For example, why the position was closed at the top of the spike (see picture). Why was not the trailing stop triggered, because if it worked, the profit would be positive, because the price movement was correct. After the trailing stop, a stop loss would not be 90 USD. And again - why the position was closed at the top of the rise. Point to point. I did not contact the dealing centre on this issue. Probably they will not answer. I have remembered this forum and hope that professionals will be able to explain the reason of this anomaly in simple language. I started trading on MT4 not so long ago. I am still sniffing and looking around.
 
Hello. Can you please tell me if one EA is attached to several windows of currency pairs at once, then changes in the EA in one window affect the EA in another window??? i.e. local variables change or not???
 

Gentlemen, please give me a hint!

I am trying to implement a simple idea that is described in the comments to the program.

The program opens orders in the TESTER at a price that is not coinciding with those specified in the code.

For example, the order opens at the price of 0.86084, while the closest value in the array is 0.85375.

The difference is positive while the code specifies to open orders if the difference is < 0.00000, i.e. negative.


Please advise us where the error is located.

Thank you.

int start()
{
 double Price=iOpen (Symbol (),0,0);        
 double SL=NormalizeDouble (Price-3000*Point, Digits);         
 double TP=NormalizeDouble (Price+100*Point, Digits);    
 #include <MASSIV.mqh> //объявление массива типа double (неповторяющиеся значения цены с пятью знаками после точки)
 double value =  Bid ;//параметру value функции ArrayBsearch присваивается значение  цены последнего тика

 int S = ArrayBsearch(  massiv,  value, WHOLE_ARRAY,  0, MODE_ASCEND);//функция возвращает индекс значения цены макс. близкой к цене последнего тика 
 if( (NormalizeDouble (Bid-massiv[S],Digits) <=0))//если разница между значением массива возвращенным на последнем тике и ценой последнего тика отрицательная или = 0.00000


{
                        
 OrderSend(Symbol(),OP_BUY,0.1,Ask,1,SL,TP,"jfh",123 );//ордер открыть
  }                                  

   }