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

 
webip:
People, please help me. It's been 5 days now and I can't figure it out. I have made my EA to modify stop loss order when necessary criteria triggers. And stop loss - which should be set, take profit of the last closed order. But when modification starts, the robot always sets a Stop Loss of 1.0000. I do not understand what is wrong. I have already wracked my brains. Does anybody have some variants, how to take the take profit of the previous order and place the stop loss of the current order?

Well... it looks like you're storing it in a variable of the int type, while you want it to be a double.

The current order's take may not necessarily be set to the stop loss of the previous order. It may be placed in a place where it should not be.

 
artmedia70:

Well... It looks like you're storing it in a variable of int type, while you should be storing it in double.

And it's not necessarily that you can place the current one's take on the stop of the previous one... It may be placed in a place where it should not be.


but it is where you can put it. I also thought I was memorising in the wrong type at first, but then I checked and it was fine.
 
webip:
but it's where you can put it. I also thought I was memorising in the wrong type at first, but then I checked and it was fine.

Store it in a double variable, most likely you store the price in an int variable, so the fractional part is cut off.
 
artmedia70:
Store it in a double variable, most likely you store the price in an int variable, so the fractional part is cut off.


Checked it again. Didn't understand anything, but all the variables are in their place. The only problem now is that when the criterion for modifying an order triggers, the Strategy Tester chart simply freezes. What should I do? I think we memorized everything in double.
 
webip:

Checked it again. I have not understood anything, but all variables are in their place. The only problem now is that, when the criterion for modifying an order triggers, the Strategy Tester's chart simply freezes. What should I do? I think we memorized everything in double.

Forgot to lock the fridge in the kitchen :)

Well, what else can I tell you in a bare spot?

Like this? Or are you sure you store prices in a variable with type double?

 
artmedia70:

They forgot to lock the fridge in the kitchen :)

Well, what else can I tell you on the bare bones?



No. The fridge is closed. :))

Don't know what the problem is. I've done all the variables correctly. Here's the piece where it gets modified. Maybe you'll understand what the problem is.

int modify_2(int tip)
 {

 int ticket;  //номер ордера
 double 
 price,   //Цена открытия
 tp;     //Новое значение цены
 double ts;
 bool modify=false;
 double take;
 
  for(int n=1;n<=OrdersTotal();n++)
   {
    ticket=mas_ord[n][1];
    if(mas_ord[n][4]!=tip)
     continue;
    price=mas_ord[n][6];
    tp=mas_ord[n][2];                          
    
    switch(tip)
     {

      case 0:
     OrderSelect(1,SELECT_BY_POS,MODE_HISTORY);
      take=OrderTakeProfit();
       ts=take;
       modify=true;
       break;
      
      case 1:
       ts=Ask+Level_sell_138*Point;
       modify=true;        
     } 
    //--------------
    if(modify==false)
     continue;
    
    bool ans=OrderModify(ticket,price,ts,tp,0);
    
    if(ans==false)
     { 
      n--;
     }
     else ord_2=true;
   }
   return;
 }
 
webip:


No. The fridge is closed. :))

I don't know what the problem is. I've done all the variables correctly. Here's the piece where the modifications are made. Maybe you can figure out what the problem is.

Is this from a textbook or something?

for(int n=1;n<=OrdersTotal();n++)

You need to go through the orders like this:

for(int n=0;n<OrdersTotal();n++)

Accordingly, the rest of the arrays will float...

I would look for the last closed order by trying to search through the history, not by explicitly pointing to 1

So on and so on ... I can't look any further - firstly, without code integrity it's unlikely to help, and secondly, it's seven in the morning and I haven't even gone to bed yet...

 
webip:


No. The fridge is closed. :))

I don't know what the problem is. I've done all the variables correctly. Here's the piece where the modifications are made. Maybe you can figure out what the problem is.

Try n do double! Wouldn't hurt, but might help to solve the problem.
 
artmedia70:

Is this from a textbook?

You have to overrun the orders like this:

Accordingly, the rest of the arrays will float...

I would search for the last closed order by trying to search through history, not by explicitly pointing to 1

And so on ... I can't search any further - first, it would hardly help me without code integrity, and second, it's 7 a.m. and I haven't even gone to bed yet...



The last closed order I pointed out directly to see if it worked at all. And that last closed order, I pointed directly to find out if the program works well at all (and it works like shit). And since I'm testing in the tester (and I know that the order I'm interested in will open first), my code is very long, I won't be able to copy it here:)
 
webip:


No. The fridge is closed. :))

I don't know what the problem is. I've done all the variables correctly. Here's the piece where the modifications are made. Maybe you can figure out what the problem is.

The array

mas_ord

What type do you have?

What type are price, tp, take variables? Why should we guess here?

Reason: