[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 165

 
FelixFX:

thanks

A lot of errors were found during compilation
 
RoniIron:

Excuse me...... the martingale advisor, is it possible to prescribe a stoploss in it or is it not possible. Thank you.

The OrderSend() function has stop loss as one of its parameters. And it is it that sets the order. Therefore, we calculate the stop level for the order we need and enter it into the function.
 
FelixFX:

compilation has revealed a lot of errors

Well, so it will be - I've warned you that MY subroutines are involved! Remove them and replace them with your printers with GetLastError()
 
drknn:

Well, it will be - I told you that MY subroutines are involved! Remove them and replace them with your printers with GetLastError() query.

It's easy to do, if you're well-versed in mql. ) I'm just learning, so for me it's a bit difficult to remove all unnecessary things and leave only the necessary ones.
 
// =================================================================================================
// ************************* Трейлинг рыночных ордеров *********************************************
// =================================================================================================


// =================  TrailingRyn() =============================================================
// функция осуществляет трейлинг рыночных ордеров 
// ----------------------------------------------
void TrailingRyn_b(int ryn_TrStop, int ryn_TrStep, int Proskalz, int MAGIC, bool WaitProfit,  bool UseTrailingSound) {
  string SMB=Symbol(); 
  int i;
  int MinLevel=MarketInfo(SMB,MODE_STOPLEVEL);//Минимально допустимый уровень стоп-лосса/тейк-профита в пунктах   
  int SchBuy=SchBuy(MAGIC);
  int SchSell=SchSell(MAGIC);
  if(ryn_TrStop>=MinLevel && ryn_TrStep>0 && (SchBuy>0 || SchSell>0)){    
    for (i=OrdersTotal()-1;i>=0;i--){
      if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {Print("Ошибка № ",GetLastError()," при выборе ордер № ",i);}
      else {
        if (OrderSymbol()==SMB && OrderMagicNumber()==MAGIC){
          TrailingPositions_b(ryn_TrStop,ryn_TrStep,Proskalz,WaitProfit,UseTrailingSound);
        }
      }
    }
  }
 if(ryn_TrStop>=MinLevel && ryn_TrStep==0)
 Print("Трейлинг невозможен - ryn_TrStep==0");
} 
// =================================================================================================

//+------------------------------------------------------------------+
//| Сопровождение позиции простым тралом                             |
//+------------------------------------------------------------------+
void TrailingPositions_b(int ryn_TrStop, int ryn_TrStep, int Proskalz, bool WaitProfit, bool UseTrailingSound){
  if(OrderType()==OP_BUY){
    if(!WaitProfit || (Bid-OrderOpenPrice())>ryn_TrStop*Point){
      if (OrderStopLoss()<Bid-(ryn_TrStop+ryn_TrStep-1)*Point){
        ModifyStopLoss_b(Bid-ryn_TrStop*Point,UseTrailingSound);
      }
    }
  }
  if(OrderType()==OP_SELL){
    if(!WaitProfit || OrderOpenPrice()-Ask>ryn_TrStop*Point) {
      if(OrderStopLoss()>Ask+(ryn_TrStop+ryn_TrStep-1)*Point || OrderStopLoss()==0){
        ModifyStopLoss_b(Ask+ryn_TrStop*Point,UseTrailingSound);
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Перенос уровня StopLoss                                          |
//| Параметры:                                                       |
//|   ldStopLoss - уровень StopLoss                                  |
//+------------------------------------------------------------------+
void ModifyStopLoss_b(double ldStopLoss, bool UseTrailingSound){
  bool fm=false;
  string NameTrallingSound  = "ok.wav";// Наименование звукового файла для трейлинга
  fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
  if(fm!=0 && fm!=-1){
    if(UseTrailingSound) { PlaySound(NameTrallingSound);}
  }   
  if(fm==0 || fm==-1) { Print("Ошибка № ",GetLastError()," при модификации ордера № ",OrderTicket());}
}
//+------------------------------------------------------------------+
 
VOLDEMAR:
Thanks guys.....
How iCustom is used with iCustom and an indicator that draws an arrow at some point to tell the EA to open .....
If iBands is an Ask > BBUP it is understandable but what about the object which may or may not show up (like arrow) ??????


All the same, you need to look at the code of the indicator, to understand which of the buffers contains the value of which line.

If you want to enter indicator parameters into iCustom function, then indicator parameters should be added to the Expert Advisor's custom variables. Otherwise, the EA will not understand what values are in the listed variables.

 
Hello! Please don't kick me if I'm asking the wrong question but I've dug all over the forum and the internet and haven't found what I'm looking for. The question is this! Is it possible to create a condition in if (after the last StopLoss (in time) should close eg 2 profit) until they are not doing else ... And if it is possible a small sketch in code, but it is possible and simply to draw a scheme in words - thanks in advance!
 
ruzzo:
Hello! Please don't kick me if I'm asking the wrong question, but I dug the whole forum and the Internet and didn't find what I was looking for. The question is this! Is it possible to create a condition in if (after the last StopLoss (in time) should close eg 2 profit) until they are not doing else ... If possible, a small sketch in code, but you can just draw a scheme in words, thanks in advance!


In general, well, it's not clear what exactly you need.

A condition in if() can be inserted. It can be inserted after any event occurs. But what does it mean to close two profits? And else can be done. That's all...


if(условие){

// какой-то код 

}

else{

// какой-то код 

} 
 
drknn:


Actually, I don't understand what you actually need.

A condition in if() can be inserted. It can be inserted after any event occurs. But what does it mean to close two profits? And else can be done. The point is...


I understand that first the condition, and then the code, but I wanted to create a condition, I got StopLoss and work with another lot, for example - until I close the deal with two profits - I just do not want to compare the balance in if - all because if I compare the balance, and I have a pending order with a time limit - the changed lot skips by - because the order expires with the increased lot - maybe I'm not digging?
 

Help plz to understand.

I decided to use the MACD Sample and I can not understand what's wrong - no matter what version, even the native one in the terminal.

all give out errors :

2011.02.28 23:01:53 MACD Sample EURUSD,M15: Error opening BUY order: 130

5 digits account. 1:500, lot 0.1 or 1, no difference, real account.

I've increased SL and TP 10-fold, nothing has changed, I've even changed more, no result, I can't get it to open something there ((

The fact that it works clearly, if I open a deal with my hands, then it transfers it to the no-loss position and starts trawling, but does not want to open it by itself!

What am I doing wrong, I can not understand for a week !??