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

 
xant:

rigonich

I could respond to you point by point to your every word, but I don't see the point anymore. If someone is stubborn, there is no point in explaining anything. The question was how to organize. Then, when you gave a hint that global variables are better than writing to a file, the question arose about how to do it correctly. Then your nervous co-signer gave a piece of code, not missing an opportunity to quip. It's simple - part of the code goes into the initialisation block, part of the block goes into the main EA block.

This is what goes into the initialisation block:

This is what goes into the main block

As you can see, I have renamed the variables.

So, I sequentially inserted the second part of the code, starting immediately after the variables calculation and all the way to the end of the start block, ending with an attempt to insert before the last curly bracket.

Judging by your highly professional explanation, that's what I should have done, because it's clear to any beginner. According to you, it should work. But it doesn't. Here's the best I've managed to achieve:


Read carefully. These two blocks are called function descriptions, and they cannot be placed inside other function descriptions. In the init should be placed

{
fGet_MineGV();
}

and in start a similar call to the second function. the functions themselves need to be placed separately in your EA, neither in init nor in start in any custom function.

Andyour nervous co-signer didn't give you part of the code, but two ready-made functions that he wrote for you.

 
lottamer:

are such chains allowed ?

if ( (A==1 && B==2) && (C==2 || D==3) && E==4)

i.e. both AND and OR in one line?


Yes, everything enclosed in parentheses is treated by the compiler as a separate comparison.
 
drknn:

Write it yourself - there's 1 single loop. Just try to do it. And if you fail, show us the code of your loop - we'll help you.


I have a problem with cycles.

I've seen the beginning many times...

next it's foggy....

for (i=0; i<k; i++) {

if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)

the most I can understand is that each i is assigned ...something...

But what to do with this mixture of i's... I have no idea...

 

rigonich

Well, it's finally starting to make sense. So, the short strings in curly braces are function calls, and the functions themselves need to be placed somewhere.

Now in order.

I add a call of the first function to the init, I do it immediately after starting the init function, i.e. just like this, it will be correct, right?

int init()
{
    fGet_MineGV();
}
//... и далее мой код, который был ранее

Similarly, I add the call of the second function to the start block. If I do this immediately after the calculation of the variables, would this be correct? For example like this:

     if ((A1>0)&&(A2>0)&&(A3>0)&&(A4>0)&&(A5>4.5)&&(VVV>V_NN)&&(SUA==0))
{
SUA=100;
SUA1+=1;
}
if((A1>0)&&(A2>0)&&(A3>0)&&(A4>0)&&(A5>4.5)&&(VVV<2)&&(VVV>0)) 
SUA=0;
if ((BUA==100)&&(A5<-4.5))
{
SUA=0;
SUA1=0;
}

     if ((A1<0)&&(A2<0)&&(A3<0)&&(A4<0)&&(A5<-4.5)&&(VVV>V_NN)&&(BUA==0))
{
BUA=100;
BUA1+=1;
}
if ((A1<0)&&(A2<0)&&(A3<0)&&(A4<0)&&(A5<-4.5)&&(VVV<2)&&(VVV>0)) 
BUA=0;
if ((SUA==100)&&(A5>4.5))
{
BUA=0;
BUA1=0;
}
//...сюда вставляю...
{
    fSave_MineGV();
}
//...и далее опять мой код...

Are these first 2 steps correct?

И нервный ваш согестник  дал вам не часть кода, а две готовые функции, которые он дя вас написал. 
Well, I actually told him thank you for that right away.
 

How do I get out of an if series if the condition if=true ?

if

if

if (TRUE) - but need to start all over again, and don't go further down the line

if

if

.......

 
lottamer:

could not find the right function in the library

Takeprofit size of the last closed position.

Maybe someone has one?


The take profit size in the deposit currency is returned by OrderProfit(), in pips - closing price minus opening price, and how to find the last closed position or where to get a ready-made function for this, I believe, was explained to you several times.
 
lottamer:

How do I get out of an if series if the condition is if=true ?

if

if

if (TRUE) - but need to start all over again, and don't go further down the line

if

if

.......


if

if

if (TRUE) - but you need to start all over again, and not go further up the ladder

else {

if

if

.......

}//if (TRUE) - but need to start all over again and not go further up the ladder

Actually, in about 99.9% of cases this means that you have not thought enough about the implementation of the algorithm.

 
VladislavVG:

if

if

if (TRUE) - but you need to start all over again and not go further up the ladder

else {

if

if

.......

}//if (TRUE) - but need to start all over again and not go further up the ladder

Actually, in about 99.9% of cases this means that you haven't thought the algorithm implementation through enough.


:))) already seems to have found a solution

return (0) - and wonderfully comes out all if

 
VladislavVG:

if

if

if (TRUE) - but you need to start all over again, and not go further up the ladder

else {

if

if

.......

}//if (TRUE) - but need to start all over again and not go further up the ladder

Actually, in about 99.9% of cases this means that you have not thought enough about the implementation of the algorithm.

With },else, return, or break or continue (for loops).
 
rigonich:

The take profit size in the deposit currency is returned by OrderProfit() function, in points - close price minus open price. I think it was explained to you several times how to find the last closed position or where to get a ready function for it.


Exactly. You must first take the ticket of the last closed position GetTicketLastPos , and then use the standard functions to take out what you need from this ticket.

Thank you.