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

 
ilunga:

So why are you comparing the same thing a bunch of times in a row?

Well, how do you think it should be compared?
 
Dimka-novitsek:

if(Stoch_1>Stoch_2) { flag1=1 ; Print (flag1,flag2,flag3,flag4); }


if(Stoch_1<Stoch_2 && flag1==1) flag2=1 ; Print (flag1,flag2,flag3,flag4); }

if ((Stoch_1>Stoch_2) && flag1==1 && flag2==1) {flag3=1; Print (flag1,flag2,flag3,flag4);PlaySound("alert.wav");}


if(Stoch_1<Stoch_2 && flag1==1 && flag2==1 && flag3==1) flag4=1;
{Print (flag1,flag2,flag3,flag4);}
if(Stoch_1>Stoch_2 && flag1==1 && flag2==1 && flag3==1 && flag4==1)
{OrderSend (Symbol( ), OP_SELL, 0.01 ,Bid, 0, 0, 0, NULL, 450, 0, CLR_NONE);
Print ("OUT");}



flag1=0;
flag2=0;
flag3=0;
flag4=0;

Understanding that you'll learn and for the sake of learning you write something... At least I've arranged your brackets in such a way that they play a role, in my opinion.


and even though your code gave out 24 errors in the compiler!!! still thanks even for the sloppy help.... for the idea... (it works now - although I tried to do it that way in principle, but the punctuation was a problem)
 

Again I wondered what the position index is. If it is a position number in the history, then what does this function do?

GetIndexLastPos Index of the last opened position or -1 ???

the index of the last opened position is always 1 because it is the latest !!!

i am obviously misunderstanding the INDEX ....

clue who knows ?

 
lottamer:

How do you think it should compare?

Let's begin:

1.If(Stoch_1>Stoch_2) flag1=1 ; , then the condition following it (Stoch_1<Stoch_2 && flag1==1) cannot in principle be true, because if Stoch_1<Stoch_2 flag1==0 and if flag1==1then Stoch_1>Stoch_2. it is the same with all subsequent conditions in this function, so only flag1 can change the value. That is, your program will execute the first two lines, skipthe third, executethe fourth, skipthe fifth, execute the sixth, execute the seventh, and skip all others.


	          
 
xant:

TarasBY,

Var1 and others named as I have, inserted block fGet_MineGV() inside init and block fSave_MineGV() inside staft.

When compiling, the EA gave out a bunch of errors.

I tried it one by one. First I inserted it inside init, then compiled it. There are 0 errors, one remark: is not referenced and will be removed from exp-file. Well, it makes sense to me, it can't find the file, because it doesn't exist yet. It has to be written inside the staft.

So, when I try to write the second block inside the staft, it produces a lot of errors.

Structural algorithm:

int init()
{
    fGet_MineGV();
}
int start()
{
    fSave_MineGV();
}
double Var1, Var2, Var3, Var4;  // 4-ре переменных для сохранения (у Вас они свои !!!)
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, Var1);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_2");
    GlobalVariableSet (ls_Name, Var2);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_3");
    GlobalVariableSet (ls_Name, Var3);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_4");
    GlobalVariableSet (ls_Name, Var4);
//----
}
// в init()
void fGet_MineGV (string fs_PrefName = "")     // префикс имени переменной
{
    string ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_1");
//----
    //---- Восстанавливаем значения переменных
    if (GlobalVariableCheck (ls_Name)) Var1 = GlobalVariableGet (ls_Name);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_2");
    if (GlobalVariableCheck (ls_Name)) Var2 = GlobalVariableGet (ls_Name);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_3");
    if (GlobalVariableCheck (ls_Name)) Var3 = GlobalVariableGet (ls_Name);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_4");
    if (GlobalVariableCheck (ls_Name)) Var4 = GlobalVariableGet (ls_Name);
//----
}

Did you, of course, do that??? And it doesn't compile???

 
lottamer:

Again I wondered what the position index is. If it is a position number in the history, then what does this function do?

GetIndexLastPos Index of the last opened position or -1 ???

the index of the last opened position is always 1 because it is the latest !!!

i am obviously misunderstanding the INDEX ....

clue who knows ?


the index of the last opened is always 1 because it's the latest !!! Not 1, but 0, and not in the history. In the history 0 is the index of the last closed position or of the last deleted order, and not always, because besides the market, there are also pending orders, which are not positions.
 
Profi, please tell me how to write the following programmatically: "To put a pending order at SL level with parameters of a closing order taking into account the spread" and where to attach it in the code of an EA?
 
yosuf:
Prof Profi, please tell me how to write the following programmatically: "To put a pending order at SL level with parameters of a closing order including spread" and where to attach it in the EA code?

You can't do it with parameters of a close order. The opening price is also a parameter.
 

TarasBY

Yes, I did as you wrote. And it doesn't compile.

Obviously, I've done something wrong, but I don't know what exactly. You can go through it step by step.

 
rigonich:

There is no way with the parameters of the one to be closed. The opening price is also a parameter.
Why? For example, an order has been opened with O=1.2900, TP 1.300 and SL 1.2800. The pending order should have the parameters BAY O= 1.2800 with TP 1.2900 and SL 1.2700. If possible, please consider the spread to be lost.
Reason: