Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 569

 
Step:
Hello! I have a small question while studying MQL4. The problem is located in the tutorial on this site. Here is the condition: Problem 25. Create a program, in which the following conditions are realized: if the rate exceeds the specified level, it will output a message, in which words will indicate that the rate exceeds the level (up to 100 points); in other cases, the message will inform that the rate does not exceed the specified level.
And here is the proposed solution:


Shows possible solutions. Useful for training.

There are other options. There are other mistakes.

Trust yourself more. Experiment.

 
Step:
Hello! When studying MQL4, I have a small question. The task is located in the tutorial on this site. Here is the condition: Problem 25. Create a program that realizes the following conditions: if the rate exceeds the specified level, it will output a message saying that the rate exceeds the level (up to 100 points); in other cases, the message saying that the rate does not exceed the specified level.
And here is the proposed solution:


P.S.

Specifically, the usefulness of this example in dealing with an array,

the possible representation of data in words,

the use of the NormalizeDouble function and the predefined Point variable.

Possibility to choose an easier hobby.

 

Apparently, there is no way to declare external variables directly in the class. Then what are the options? If I do not want to declare in the Expert Advisor itself or elsewhere these external specific variables, which are needed only when using this class. I think the only option is to make an inluder, that will declare these external variables. And then the class should be included into it, right?

Then in order to call the class, you need to include the class itself. Is it so? Or there can be some other variants?

It just does not look good to me. A lot of nested inclusion files to create... That's why I have such a question.

Or is it still possible, as in a usual library, to declare external variables and import the required libraries before declaring the class? I mean something like this:

// Объявляем внешние переменные
extern type Var1;
extern type Var2;
extern type Var3;

// Подключаем требуемые библиотеки
//#include <LBase.mqh>
//+---
//#include <Logging.mqh>
#import "user32.dll"
     int GetAncestor;
     int PostMessageA;
#import
//
class CLogging
{
   protected:
 // защищенные данные
   public:
 // открытые данные
};
I've never seen that before. So I wonder if I'm going in the right direction...
 
Transferring indicator code to the Expert Advisor, an error occurs. I have output them as global variables in the terminal screen via Comment.

if(BullBear!="")
{
retXB=(zz[A4]-zz[B4])/(zz[A4]-zz[X4]+0.000001);
retAC=(zz[C4]-zz[B4])/(zz[A4]-zz[B4]+0.000001);



Output them as global variables to the terminal screen through Comment. There were no zeros, only negative numbers. Then I changed

//---- indicator buffers
double zz[1500];
to

//---- indicator buffers
double zz[300];
everything fell into place, put it back. No error! What was the reason? I also switched off the internet.
 
semargl988:

Transferring indicator code to the Expert Advisor, an error occurs. Zero divide in the code part

...

Output them as global variables to the terminal screen via Comment. There were no zeros, only negative numbers. Then I changed

...

to .

...

everything fell into place, put it back into place. No error at all! What was the cause? I turned off the internet some more.

I also got the error "zero divide" where zero could not be passed in the denominator of the fraction. Now before dividing, I do a formal check like:

if(znamenatel==0)
{
 какое-то действие;
}

And the error disappeared. I.e. the compiler should be instructed what to do if denominator=0 even if the programmer is 100% sure there is no 0 there.

 

Hello, can you please help me with the code? I need the EA to do the elementary thing - open positions when approaching the vertical (i.e. strictly time, not price) line, namely for a specified shi interval, which I have here 120 i.e. as I understand - 2 minutes. The colour of the line should determine whether it is buy or sell. I searched in the Internet and rewrote it and got the following:

void OnTick()
{
int AllObject = ObjectsTotal();
for ( int i = 0; i < AllObject; i++)
{

string NameObj = ObjectName(i);
Colorrr = ObjectGet(NameObj, OBJPROP_COLOR);
Vremyaaa = (ObjectGet(NameObj, OBJPROP_TIME) - shi);
if(Vremyaaa == TimeLocal())
break;
}

int kolpos = 0;

if((Colorrr == Green)||(Colorrr == Aqua)){operacia = "OP_BUY";}
if((Colorrr == Red)||(Colorrr == Purple)){operacia = "OP_SELL";}
for (int pos = 0; pos < OrdersTotal(); pos++)
{
if(OrderSelect(pos, SELECT_BY_POS, MODE_TRADES) == true)
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
{
kolpos++;
}
}
}
if(kolpos == 0)
{
if (iTime(NULL,0,1) == Vremyaaa)
{
int ticket = OrderSend(Symbol(), operacia, Lot, Bid, 10, 0, 0, "5", Magic, 0, col);
}

}

}

It does not trade for some reason. It does not write any errors in the log...
 
dmitriyriy666:

Hello, can you please help me with the code? I need the EA to do the elementary thing - open positions when approaching the vertical (i.e. strictly time, not price) line, namely for a specified shi interval, which I have here 120 i.e. as I understand - 2 minutes. The colour of the line should determine whether it is buy or sell. I searched in the Internet and rewrote it:

void OnTick()
{
int AllObject = ObjectsTotal();
for ( int i = 0; i < AllObject; i++)
{

string NameObj = ObjectName(i);
Colorrr = ObjectGet(NameObj, OBJPROP_COLOR);
Vremyaaa = (ObjectGet(NameObj, OBJPROP_TIME) - shi);
if(Vremyaaa == TimeLocal())
break;
}

int kolpos = 0;

if((Colorrr == Green)||(Colorrr == Aqua)){operacia = "OP_BUY";}
if((Colorrr == Red)||(Colorrr == Purple)){operacia = "OP_SELL";}
for (int pos = 0; pos < OrdersTotal(); pos++)
{
if(OrderSelect(pos, SELECT_BY_POS, MODE_TRADES) == true)
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
{
kolpos++;
}
}
}
if(kolpos == 0)
{
if (iTime(NULL,0,1) == Vremyaaa)
{
int ticket = OrderSend(Symbol(), operacia, Lot, Bid, 10, 0, 0, "5", Magic, 0, col);
}

}

}

The code does not trade for some reason. It doesn't log any errors...

If your time coincides with the terminal time, you can use TimeLocal(), but TimeCurrent() is more reliable .

Change operacia variable type to int and remove OP_BUY and OP_SELL quotes

 
AlexeyVik:

If you have the same time as the terminal time, you can use TimeLocal(), but TimeCurrent() is more reliable .

Change operacia variable type to int and remove OP_BUY and OP_SELL quotes



Thank you. About TimeCurrent it's true, my time doesn't match the server time. Fixed it, but it still doesn't work... Doesn't write any errors in the log.


P.S. In my previous post, code without spaces was somehow inserted. But I think I put all the curly braces correctly.

 

MT4 - 625, tester message when trying to test owls with library:

2014.03.29 18:38:48.753 'C:\Program Files\Admiral1\MQL4\Libraries\ingLib094.mq4' is not 32-bit version

Before that owl compiled without a hitch, and the library didn't have a single word either. In fact, I don't understand it at all.

My system (I mean Windows) is 32-bit, I've never had another one. Seventh.

The library is my native one, all the way with it. Goes well in real time on new build. Including with other owls. And in tester in earlier versions without problems.

But it doesn't want to open in tester, and the reason is even sucked out of your fingers.

And there is not a word about 32-bit cases in all the manuals.

 
dmitriyriy666:

Thank you. About TimeCurrent it's true, my time doesn't match the server time. Fixed it, but it still doesn't work... Doesn't write any errors in the log.


P.S. In my previous post, code without spaces was somehow inserted. But I think I put all the curly braces correctly.

Please specify whether you corrected everything I wrote or just TimeLocal() to TimeCurrent()
Reason: