[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 66

 
vovan-gogan:

What's the point? The SL level is correct. When I set the SL variable to MA20 with a shift of 3, I output the SL level through Alert and it is always at the right level. I do not know why the SL is removed before reaching the SL level.

Well, if it's important for you not to fix the problem, but to communicate, then I'll pass.
 
PapaYozh:

No, well, if it's not about fixing the problem, it's about communicating, then I'll pass.

No, on the contrary. I'll take your advice. Let's see what happens.
 
I'm confused by the fact that both types of BUYSTOP / SELLSTOP orders are deleted by the same condition, at least they are different things. I suppose there is another similar code fragment and it will delete all the pending orders in series.
 
splxgf:
I'm confused by the fact that both types of BUYSTOP / SELLSTOP orders are deleted by the same condition, at least they are different things. I suppose there is one more similar code fragment and all the pending orders will be deleted successively.

Nope. Not by one. I just presented a part of the code fragment that describes the case of deleting SellStop orders to make it clearer.
 
vovan-gogan:

No. Not by one.
   if (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP)

One of the order types is below the price, the other is above the price... and the condition for closing them is the same Bid>SL... You have to ask where the logic is.

I recommend to remove one order type from the condition, or you can just dumb down further.

 
vovan-gogan:

people, help me figure out what the heck this is! My Expert Advisor is designed to put out an oplot, and if the price does not reach it, but reverses to the level of its stop, the oplot should be deleted. but on the tester it sometimes puts out an oplot and is immediately deleted before it even reaches the stop. What is the problem? Here is a screenshot and deletion code.

Here is the code:

What is the error here?

In the very first line (let's shut up about the rest)... If the Bid is below the StopLoss of your order...
And the order is set below the Bid and its StopLoss is also below the Bid. The first line of code immediately deletes it.
 
Hello, quite a nubile question...I guess. In the screenshots I often see on standard (native MT4 tools) Fibo levels and Fibo extensions, after the Fibo number there is a price on which the level is ...... My question is: how do I enable it?
 
Vinin:

Adapted from



Hello, help please... There is an indicator here. Is it possible to attach a sound signal when drawing a new segment? ZigzagFr_v1.mq4 (4.4 Kb) View
 
Good afternoon! I don't understand something. I decided to attach a trailing stop to my Expert Advisor. However, it keeps showing error 130. I cannot understand anything, and yesterday I couldn't either.
  } }
   
   
  //+------------------------------------------------------
  double JUN;int tiktik;
   for ( i=0; i<OrdersTotal(); i++) {   OrderSelect(i,SELECT_BY_POS );if(( OrderMagicNumber( )==1000 &&OrderSymbol()==Symbol())) { 
      if( OrderType( )!=OP_BUY ) continue;
     if (price-OrderOpenPrice( )>30*Point) {JUN= price-OrderOpenPrice( );tiktik=OrderTicket();} }} 
     
     Alert("Позиция с тикетом #",tiktik," имеет JUN, ",JUN);Alert("JUN",JUN,"JUNpomnim",JUNpomnim);
    if (JUN>0){if (JUN>JUNpomnim){Alert("JUN",JUN,"JUNpomnim+++++++++++++++++++++++++",JUNpomnim);
      OrderModify(tiktik,OrderOpenPrice(),price-15*Point,OrderTakeProfit(),0,0);     JUNpomnim=JUN;
      Alert("OrderModify-BAY", GetLastError()); }}
      
      
      
  double BAN;int tiktAk;
   for ( i=0; i<OrdersTotal(); i++) {   OrderSelect(i,SELECT_BY_POS );if(( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol())) { 
      if( OrderType( )!=OP_SELL ) continue;
     if (OrderOpenPrice( )-price>30*Point) {BAN= OrderOpenPrice( )-price;tiktAk=OrderTicket();} }} 
     
     Alert("Позиция с тикетом #",tiktAk," имеет BAN, ",BAN);Alert("BAN",BAN,"BANpomnim",BANpomnim);
    if (BAN>0){ if (BAN>BANpomnim){Alert("BAN",BAN,"BANpomnim++++++++++++++++++++++++++++",BANpomnim);
      OrderModify(tiktAk,OrderOpenPrice(),price+15*Point,OrderTakeProfit(),0,0);  BANpomnim=BAN;
       Alert("OrderModify-SELL", GetLastError()); }}
    

  
   return(0);
  }
//+------------------------------------------------------

Please see the line with the modification, there is an error in it. So, the stop loss is set 15 pips higher for Bai, and vice versa for Sell.

In general, a trailing stop starts to fall when the Buy Stop and Sell Stop are opened and then the price moves 30 pips higher (or lower for a Sell), note that the stop is not lower than the open; in other words, I see no logical errors.

I calculate the price at every tick and it goes like this

int X,Y; double price=NormalizeDouble((Ask+Bid)/2,4); 

The main thing is to check if the input values are correct.

Although I wrote a code fragment without a plan and didn't think it through, I drafted it anyway.

 
Dimka-novitsek:
Good afternoon, I don't understand something. I decided to attach a trailing stop to my EA but it keeps showing error 130. I cannot understand anything, I couldn't yesterday either.

Please see the line with the modification, there is an error in it. So, the stop loss is set 15 pips higher for Bai, and vice versa for Sell.

In general, a trailing stop starts to fall when the Buy Stop and Sell Stop are opened and then the price moves 30 pips higher (or lower for a Sell), note that the stop is not below the open; in other words, I see no logical errors.

I calculate the price at every tick and it goes like this

I tried to check it, but it was wrong.

I wrote a part of the code without a plan, without thinking about it, but it's still correct.

in such a mess it's hard to suggest anything.

Well, for starters:

1) don't write 2-3 operators per line, everything gets mixed up and is badly readable

2) JUNpomnim variable. Where is it "given" an initial value? Is it the same for all of the open orders?

For a simple example, you have 2 orders. You just move the SL of the first one, change this variable, and that's it. The second one will not be moved because JUN = JUNpomnim.

3) When using OrderModify(), normalise all prices