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

 
paladin80:
If a 0.01 lot = 1 cent, then for a 0.1 lot position with a 200 pips stop loss = 20 USD.
thanks buddy i thought so...... thanks :)
 

Please help to make this function vice versa:

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 11.09.2008                                                     |
//|  Описание : Перенос уровня стопа в безубыток                               |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   ( ""  - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   ( -1  - любая позиция)                  |
//|    mn - MagicNumber                ( -1  - любой магик)                    |
//|    Кроме того, функция MovingInWL() предполагает наличие глобальных переменных (внешних параметров скрипта или советника):
//|    int LevelProfit - Уровень профита в пунктах, которого должна достигнуть позиция для того, чтобы её стоп был перенесён на уровень безубытка.
//|    int LevelWLoss - Уровень безубытка в пунктах, на который будет перенесён стоп позиции после того, как её профит достигнет уровня LevelProfit в пунктах.
//+----------------------------------------------------------------------------+
void MovingInWL(string sy="", int op=-1, int mn=-1) {
  double po, pp;
  int    i, k=OrdersTotal();

  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      po=MarketInfo(OrderSymbol(), MODE_POINT);
      if (OrderType()==OP_BUY) {
        if (OrderStopLoss()-OrderOpenPrice()<LevelWLoss*po) {
          pp=MarketInfo(OrderSymbol(), MODE_BID);
          if (pp-OrderOpenPrice()>LevelProfit*po) {
            ModifyOrder(-1, OrderOpenPrice()+LevelWLoss*po, -1);
          }
        }
      }
      if (OrderType()==OP_SELL) {
        if (OrderStopLoss()==0 || OrderOpenPrice()-OrderStopLoss()<LevelWLoss*po) {
          pp=MarketInfo(OrderSymbol(), MODE_ASK);
          if (OrderOpenPrice()-pp>LevelProfit*po) {
            ModifyOrder(-1, OrderOpenPrice()-LevelWLoss*po, -1);
          }
        }
      }
    }
  }
}

That is, if the price goes to a loss from an open order by the number of pips LevelProfit (you can call it LevelLoss), you have to move TakeProfit to zero or to a loss by 1 pip 2, etc., depending on what you put in the LevelWLoss parameter, so that if the price even turns around, there would be no more profit. Or maybe you have a ready one?

Thank you in advance))

 

Good afternoon! You know, just cut the code from the EA's init section, (I was debugging it for the weekend - no ticks!), moved it to start. Removed outer fora loop. I compiled it.

It's coded-- 'continue' - 'break' or 'continue' used within some cycle only C:\Alpari\experts\Outputs.mq4 (69, 20)

What is it about? Well, in loop continuo, in loop, so what? I don't speak much English. If I can understand some words, I can't make sense of them!

 if (strela1 < strela2)
    {Sleep(600);
        if (SELL > 0) udalenie (OP_SELL);Sleep(600);
        if (BUY == 0)
        {Sleep(600);RefreshRates();
           OrderSend (Symbol( ), OP_SELL, lot, NormalizeDouble (Bid, Digits), 5 , NormalizeDouble( Ask+ (stoplos*Point),Digits),   NormalizeDouble( Ask-( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE) ;            
           int Error=GetLastError(); 
           Sleep(600);
    if (Error==129)continue;    }
    
    
    }
    else if (strela1 > strela2)
    {Sleep(600);
        if (BUY > 0) udalenie (OP_BUY);Sleep(600);
        if (SELL == 0)
        {Sleep(600); RefreshRates();
             OrderSend (Symbol( ), OP_BUY, lot,NormalizeDouble(Ask, Digits), 5, NormalizeDouble( Bid- (stoplos*Point),Digits),   NormalizeDouble( Ask+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE); 
            
           Error=GetLastError(); 
        if (Error==129)continue;  }
 
Dimka-novitsek:

Good afternoon! You know, just cut the code from the EA's init section, (I was debugging it for the weekend - no ticks!), moved it to start. Removed outer fora loop. Compiled.

Came up with-- 'continue' - 'break' or 'continue' used within some cycle only C:\Alpari\experts\Outputs.mq4 (69, 20)

What's that about? Well, in the loop, in the loop, so what? I'm not very good at English. If I understand some words, I can't make sense of them all!

You don't have a loop, but you have the continue operator (it's only used in loops).
 
Lians:

Please help to make this function vice versa:

That is, if the price goes to a loss from an open order by the number of pips LevelProfit (you can call it LevelLoss), you have to move TakeProfit to zero or to a loss by 1 pip 2, etc., depending on what you put in the LevelWLoss parameter, so that if the price even turns around, there would be no more profit. Or maybe you have a ready one?

Thank you in advance))

The function may be as follows:

void fMoving_TPInBU (int fi_LevelLOSS,       // уровень Лосса в пп. (для цены) - ТОЛЬКО > 0
                     int fi_LevelBU,         // уровень БУ в пп. (для тэйкпрофита) - может быть и >= 0 и < 0
                     string fs_Symbol = "",  // Symbol
                     int fi_Type = -1,       // Type
                     int gi_MG = -1)         // MagicNumber
{
    double ld_Point, ld_Price;
    int    li_Type, li_cnt, li_total = OrdersTotal();
//----
    if (li_total == 0) return;
    if (fs_Symbol == "" || fs_Symbol == "0") fs_Symbol = Symbol();
    for (int li_pos = li_total - 1; li_pos >= 0; li_pos--)
    {
        if (!OrderSelect (li_pos, SELECT_BY_POS, MODE_TRADES)) continue;
        if (OrderSymbol() != fs_Symbol) continue;
        if (gi_MG > -1) if (gi_MG != OrderMagicNumber()) continue;
        li_Type = OrderType();
        if (li_Type > 1) continue;
        if (li_Type > -1) if (li_Type != fi_Type) continue;
        RefreshRates();
        if (li_Type == 0) {li_cnt = 1; ld_Price = MarketInfo (fs_Symbol, MODE_BID);}
        else {li_cnt = -1; ld_Price = MarketInfo (fs_Symbol, MODE_ASK);}
        ld_Point = MarketInfo (OrderSymbol(), MODE_POINT);
        if (li_cnt * (OrderOpenPrice() - ld_Price) >= fi_LevelLOSS * ld_Point)
        {
            double ld_TP = NormalizeDouble (OrderOpenPrice() + li_cnt * fi_LevelBU * ld_Point, MarketInfo (fs_Symbol, MODE_DIGITS));
            //---- Проверка на "излишнюю" модификацию
            if (ld_TP - OrderTakeProfit() != 0.0)
            {OrderModify (OrderTicket(), ld_Price, OrderStopLoss(), ld_TP, 0);}
        }
    }
//----
}

Don't forget to check MODE_STOPLEVEL and MODE_FREEZELEVEL constraints when modifying a STOP.

 

Thank you!!! Let's have a look...

How not? And if (BUY == 0)- isn't this a loop? Strangely, I only removed the outer loop, which surrounded the whole program in parentheses. It was needed for debugging, so I took it out.

If it's not there, let it pass if (strela1 < strela2), the program's logic won't be broken.

 
Dimka-novitsek:

Thank you!!! Let's have a look...

How not? And if (BUY == 0)- isn't this a loop? Strange, I only removed the outer loop that was bracketing the entire program at the start.


No. Not a loop. You took out exactly what should have been left. Read the whole tutorial! Especially here: "An example of using a compound operator in a conditional operator. The conditional if(expression) operator comes first, followed by the compound operator. The compound operator contains a list of executable operators."

 
Reading.
 
HELP! Please help!!! As an example, I attach this picture. I am not a programmer this indicator to some way soldered but then ran into a lack of knowledge and skills have tried a whole week to display the arrows on the screen did not work. I will explain the essence. in selected areas, underlined in white, there is a clear divergence (as I understand it) that is the difference between the histogram and the price line. in figure for example, I marked these places numbers 1-2-3-4.In these places, the values of the indicator line decreases modulo, although the price continues to update the bottom and thus we got to point 5 in it we see the basis of the price updated low and bottom at the close, the histogram is also growing, but the line shows a decrease.
Files:
tjllfe2.zip  45 kb
 

TarasBY, thanks for the explanations and the function!

I'm taking the function to my collection, but I don't understand something:

Parameter fi_LevelBU has minus value - it shifts take profit, while if it has plus value it shows profit or vice versa?

And second: is it better to check for constraints within the function itself or outside the function?

Reason: