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

 
Roman.:

The right button of the mouse click on grey colour of an indicator in the terminal, then in the menu - "change" click already left mouse, then compile in the meta editor, then reboot the terminal and live happily...:-)


Didn't help. Did it all, restarted the terminal, alas.

The source code doesn't seem to have anything to do with it, the program is mine.

For some reason it's all about the name, deleted all the text, loaded a simple nonsense that works instead, recompiled, same result.

Anyway, if no one has encountered this kind of thing, fuck it. I'll forget this name and no problem.

 
ramses:


//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{

if (OrdersTotal()>0)
{ <-- this bracket is redundant.

 
DhP:

The margin for a 1 lot order is equal:

You can figure it out from there.

And we also need to check if there are enough available funds:

Where are the values from AccountFreeMarginMode()? Which can be 0, 1, 2, 3, 4 (I think).


Here is my function to determine lot size, but I understood that I didn't take AccountFreeMarginMode()into account

double GetLots() {
   double lot;
   double Step   =MarketInfo(Symbol(),MODE_LOTSTEP);
   if(MoneyManagement) {
      RefreshRates();                              // Обновление данных
      double
         TickValue = MarketInfo(Symbol(),MODE_TICKVALUE),
         Min_Lot=MarketInfo(Symbol(),MODE_MINLOT),           // Миним. колич. лотов 
         Max_Lot=MathFloor(MarketInfo(Symbol(),MODE_MAXLOT)),// Макс. колич. лотов 
         Free   =GetFreeMargin()-NotUsedPart,                // Свободн средства
         One_Lot=MarketInfo(Symbol(),MODE_MARGINREQUIRED);   // Стоимость 1 лота
      //Print("Step=",Step);
      //GetFreeMargin();
      stimul = LossPercent*0.01;
      if (Free > MaxUsedPart) Free = MaxUsedPart;
      double free = AccountBalance() - AccountMargin();
      Print("free = ",free);
      if (Free > free) Free = free;
      lot = stimul*Free/(StopLoss*Cor*TickValue);
      if (lot >= 0) {
         if (stimul == 3*LossPercent*0.01) {
            Print("После убытка ЛОТ в пределах % утроенного риска от SL и равен ",MathFloor(lot/Step)*Step," или ",100*stimul,"% баланса");
         } else {
            if (stimul != LossPercent*0.01) {
               Print("После убытка ЛОТ в пределах % максимального риска от SL и равен ",MathFloor(lot/Step)*Step," или ",100*stimul,"% баланса");
             } else {
               Print("ЛОТ в пределах заданного % риска от SL и равен ",MathFloor(lot/Step)*Step," или ",100*stimul,"% баланса");
             }
         }

      }
      if (lot > Max_Lot && lot >= 0) {
         lot = Max_Lot;
         Print("ЛОТ ограничен максимумом и равен ",MathFloor(lot/Step)*Step);
      }
      //Print(lot,"*",One_Lot,"=",lot*One_Lot," > ",Free);
      //Print("AccountFreeMarginMode=",AccountFreeMarginMode()," AccountFreeMargin=",AccountFreeMargin()," Free=",Free);
      if (lot*One_Lot > stimul*Free && lot >= 0) {
         lot =stimul*Free/One_Lot;
         Print("ЛОТ ограничен свободными средствами и равен ",MathFloor(lot/Step)*Step);
      }
      int level=AccountStopoutLevel(); ///// ТОЛЬКО ЕСЛИ ВЫРАЖЕН В ПРОЦЕНТАХ!!!
      if (AccountStopoutMode() == 0 && lot >= 0) {
         if (lot > Free/(level*One_Lot/100.0 + StopLoss*Cor*TickValue)) {
            lot = Free/(level*One_Lot/100.0 + StopLoss*Cor*TickValue);
            Print("ЛОТ ограничен уровнем StopOut и равен ",MathFloor(lot/Step)*Step," или ",MathRound(100*lot*StopLoss*Cor*TickValue/Free),"% баланса");
         }
      }   
      if (lot < Min_Lot && lot >= 0) {
         if (2*lot > Min_Lot) {
            lot=Min_Lot;               // Не меньше минимальн
            Print("ЛОТ ограничен минимумом и равен ",MathFloor(lot/Step)*Step);
         } else lot=0;
      }
   } else lot=Lots;

   //if (Variant == 2)lot=0.5*lot;
   //if (Variant == 0)lot=0.2*lot;

   if (Accuracy == 0) 
      lot = MathFloor(lot/Step)*Step;
   else lot = NormalizeDouble(lot,Accuracy); 
   //Alert("lot=",lot);
   if (lot < 0) lot = 0;
   return(lot);
}
 

Can you tell me if another for loop can be inserted into a for loop?

Give me a small example, if possible

 
CLAIN:

Can you tell me if another for loop can be inserted into a for loop?

give me a small example if you can

you can

for (int i = 0; i < 10; i++)
{
   for (int j = 0; j < 10; j++)
   {
      Print("i = " + i + ", j = " + j);
   }
}
 
CLAIN:

Can you tell me if another for loop can be inserted into a for loop?

give a small example if you can

you can.

         for (int j = i-1; j >= i-trend_bars; j--)
            if (Close[j] - Open[i] > ternd_level*body) {
               ObjectDelete("TrendUp");
               ObjectCreate("TrendUp",OBJ_ARROW,0,Time[i],Low[i]-50*Point);
               ObjectSet("TrendUp",OBJPROP_ARROWCODE,SYMBOL_ARROWUP);
               ObjectSet("TrendUp",OBJPROP_COLOR,Red);
               if (!Is_Pattern(i)) {
                  ObjectSet("TrendUp",OBJPROP_COLOR,Green);
                  //========процедура сдвига всего 2-x мерного массива buf на 1 индекс========
                  ArraySetAsSeries(Pattern,true); //"переворачиваем" массив
                  ArrayCopy(Pattern, Pattern, ArrayRange(Pattern,1), 0);
                  ArraySetAsSeries(Pattern,false);//возвращаем в исходное значение
                  for (int k = 0; k < pattern_bars; k++) {
                     Pattern[0][k] = pattern[k];
                  }
                  for (int m = 0; m <= size; m++) {
                     if (Pattern[m][0] == 0 && Pattern[m][1] == 0 && Pattern[m][2] == 0 && Pattern[m][3] == 0) {
                        break;
                     }   
                  }
                  pattern_count = m;
                  if (prn) 
                     if (MathMod(m, 100) == 0) Print("В работе ",m," паттернов на ",Bars," барах");
                  if (m > 0.1*Bars) {
                     for (int l = MathRound(0.1*Bars); l <= size; l++) {
                        for (int n = 0; n < 4; n++) {
                           Pattern[l][n] = 0;
                        }
                     }
                  }
               }
               lst_patt = i;
               break;
            }
 
Hello, I need a little help))

Maybe you can find an Expert Advisor in the code storeroom:

I need it to update all open charts templates (which are attached to them at the time of update (important! Not at the start of the EA)) at a certain interval (eg every 15 min).

Thanks for any help in advance)
 
Huh... Put one of these on a dozen charts once, didn't know how to get rid of it :))
 

Well, I only have 4 charts, just templates are generated from excel every 10 minutes, then I manually attach them. but it's exhausting to do it manually))

Can you tell me the name of that expert, please?

 
w-knot:

Well, I only have 4 charts, just templates are generated from excel every 10 minutes, then I manually attach them. but it's exhausting to do it manually))

Can you tell me the name of that expert, please?

It's your own crude self-writing. If you don't program it, order it from someone else.
Reason: