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

 
Dimka-novitsek:
Good evening! The trailing stop works immediately after the order is placed. And it should work only when the order with the ticket will move to the history, and it will move strictly by TakeProfit.

But, if your history is not empty, you will almost certainly find there an order triggered exactly at Take Profit? Apparently, you are not searching the history for an order closed at TP, but you are checking through the history how the order you need closed, and whether it closed at all. That is what you need to check, why do you check exactly what the closing price of your order is? Three options - 1. close price==0 - if the order is market, it is not in the history (OrderSelect() will return false) 2. close price is equal to
OrderTakeProfit()
-- the order has closed at stop price, 3.
OrderTakeProfit()
-- the order did not close at stop .
 

rigonich

Twenty-five again. I asked very specifically whether I had made the right first move. You didn't answer a direct question, you didn't say a word in substance.

Yes, of course, I read a textbook, but as I have a profession that has nothing to do with programming, it's clear that I'm asking for a clear, simple, concrete algorithm. How hard is it to understand? If you find it difficult to answer on the merits, so why bother? Just walk away.

And as a comment - you have no idea how many people I meet that I, as a general practitioner, can call stupid. It's hard to imagine that adults don't understand basic questions about their own health. If I react to everyone the way you do, I will be worthless as a specialist. Sleep well.

_______________

Please - someone email me at neroy(dog)mail.ru who can bluntly take the EA code and paste in what you need in the right place.

 
xant:

rigonich

Twenty-five again. I asked very specifically whether I had made the right first move. You didn't answer a direct question, you didn't say a word in substance.

Yes, of course, I read a textbook, but as I have a profession that has nothing to do with programming, it's clear that I'm asking for a clear, simple, concrete algorithm. How hard is it to understand? If you find it difficult to answer on the merits, so why bother? Just walk away.

And as a comment - you have no idea how many people I meet that I, as a general practitioner, can call stupid. It's hard to imagine that adults don't understand basic questions about their own health. If I react to everyone the way you do, I will be worthless as a specialist. Sleep well.

_______________

Please - someone email me at neroy(dog)mail.ru who can bluntly take the EA code and paste in what you need in the right place.


You haven't asked to take your EA and paste the required code into it, you haven't posted the EA code, first you asked for help to solve the problem of data loss when turning off the EA, when you did that, you insulted the one who helped you, then you asked if you made the "first step" right, and when you were told it was wrong and pointed out specific mistakes, you again insult those who are helping you, so I guess nobody else would want to do that.

P.S. I can't even think of an easier and clearer algorithm, than taking two ready-made functions, copying them into my EA and putting a call of one in the beginning of the init and the other at the end of the start.

 
rigonich:

It's actually your code, partially corrected by someone else.


my code did not give any errors. But it didn't give any results either.

And his code didn't even work, because 24 errors....

but I got the idea... and now it works.

 

The compiler, of course, is inhuman. Now my brain is nearly broken as to why the error is showing

'(' - function definition unexpected G:\Program_Files_2\MT4-demo\experts\3.mq4 (139, 14)

while this Expert Advisor worked like a charm yesterday, but today I just opened a long IF into several short if....

Turns out I missed an inverted comma about a KILLOMETre from where the compiler showed the error! In addition, he was silent about the inverted comma, he was not satisfied with the FUNCTION, you see....:((((((((

 

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:

 void fGet_MineGV (string fs_PrefName = "") // префикс имени переменной
     {
        string ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_1");
        if (GlobalVariableCheck (ls_Name)) SUA = GlobalVariableGet (ls_Name);
        ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_2");
        if (GlobalVariableCheck (ls_Name)) SUA1 = GlobalVariableGet (ls_Name);
        ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_3");
        if (GlobalVariableCheck (ls_Name)) BUA = GlobalVariableGet (ls_Name);
        ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_4");
        if (GlobalVariableCheck (ls_Name)) BUA1 = GlobalVariableGet (ls_Name);
     }

This is what goes into the main block

 void fSave_MineGV (string fs_PrefName = "") // префикс имени переменной
{
 static datetime ldt_NewBar;
 datetime ldaTBeginBar = iTime (Symbol(), 1, 0)
 //---- Сохраняемся в начале каждой минуты
 if (ldt_NewBar == ldaTBeginBar) return;
 ldt_NewBar = ldaTBeginBar;
 //---- Сохраняем поочереди значения каждой переменной
 string ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_1");
 GlobalVariableSet (ls_Name, SUA);
 ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_2");
 GlobalVariableSet (ls_Name, SUA1);
 ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_3");
 GlobalVariableSet (ls_Name, BUA);
 ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_4");
  GlobalVariableSet (ls_Name, BUA1);
}

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:

8 error(s), 0 warning(s)        
 

could not find the right function in the library

TakeProfit size of the last closed position.

Maybe someone has one?

 

are such chains allowed ?

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

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

 
 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?


The answer is yes. Are some languages not allowed? What, do they have to reduce everything to conjunctive and disjunctive-normal forms?
 
lottamer:

could not find the right function in the library

Takeprofit size of the last closed position.

Maybe someone has one?


Write it yourself - there is 1 single loop. Just try to do it. And if you fail, show us the code of your loop - we will help you.
Reason: