Questions from a "dummy" - page 156

 
progma137:
Thank you. It worked. I declared this variable as a global variable.

Right.

But keep in mind that LWMA needs to have one of these variables each for parallel LWMA calls. As many different parameters in LWMA, so many variables

 
How do I close a position (which is the sum of several open positions)? Is there an analogue to OrderClose(), or should I open a position in the opposite direction?
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства позиций
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства позиций
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства позиций - Документация по MQL5
 
Paladin80:

How do I close a position (which is the sum of several open positions)? Is there an analogue of OrderClose(), or should I open a position in the opposite direction?

You open in the opposite direction with the same lot for which the position is now open.

The result will be "no position".

Any position in any instrument is already the sum of all previous trades.

ZZZY Remind that a position on any tool can be only one or not exist at all.

 
stringo:

Right.

But keep in mind that for parallel LWMA calls you need to have one of these variables each. As many different parameters in LWMA, so many variables

Thanks, I'll keep that in mind.

And I have the following question.

can I add a custom indicator into OBJ_CHART and if so, how?

Переход на новые рельсы: пользовательские индикаторы в MQL5
Переход на новые рельсы: пользовательские индикаторы в MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
Я не буду перечислять все новые возможности и особенности нового терминала и языка. Их действительно много, и некоторые новинки вполне достойны освещения в отдельной статье. Вы не увидите здесь кода, написанного по принципам объектно-ориентированного программирования — это слишком серьезная тема для того, чтобы просто быть упомянутой в контексте как дополнительная вкусность для кодописателей. В этой статье остановимся подробней на индикаторах, их строении, отображении, видах, а также особенностях их написания по сравнению с MQL4.
 
progma137:

can a custom indicator be added to OBJ_CHART? and if so, how?

ChartIndicatorAdd ?
 
sergeev:
ChartIndicatorAdd ?

error 4802 indicator cannot be created

My custom indicator, put separately, works.

Переход на новые рельсы: пользовательские индикаторы в MQL5
Переход на новые рельсы: пользовательские индикаторы в MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
Я не буду перечислять все новые возможности и особенности нового терминала и языка. Их действительно много, и некоторые новинки вполне достойны освещения в отдельной статье. Вы не увидите здесь кода, написанного по принципам объектно-ориентированного программирования — это слишком серьезная тема для того, чтобы просто быть упомянутой в контексте как дополнительная вкусность для кодописателей. В этой статье остановимся подробней на индикаторах, их строении, отображении, видах, а также особенностях их написания по сравнению с MQL4.
 
progma137:

error 4802 indicator cannot be created

Then find out why it cannot be created.

and only then proceed to adding it to the chart

 
sergeev:

then work out why it's not being created.

and then move on to adding it to the chart

subWindowHandle = ChartWindowFind();
   Print("Номер подокна " + subWindowHandle);
   no = "name_object";
   // 2. создаем объект график
   bool isFlag = ObjectCreate(0, no, OBJ_CHART, subWindowHandle, 0, 0.0);
   if(isFlag){
      ObjectSetInteger(0, no, OBJPROP_CORNER, 0);
      ObjectSetInteger(0, no, OBJPROP_XDISTANCE, 0);
      ObjectSetInteger(0, no, OBJPROP_YDISTANCE, 0);
      ObjectSetInteger(0, no, OBJPROP_XSIZE, 500);
      ObjectSetInteger(0, no, OBJPROP_YSIZE, 200);
      ObjectSetInteger(0, no, OBJPROP_PERIOD, PERIOD_H8);
      ObjectSetString(0, no, OBJPROP_SYMBOL, "GBPUSD");
      
      //int handle_ind_h8 = iCustom("GBPUSD", PERIOD_H8, "Examples\\MACD", 12, 26, 9);
      //int handle_ind_h8 = iMACD("GBPUSD", PERIOD_H8, 12, 26, 9, PRICE_OPEN);
      int handle_ind_h8 = IndicatorCreate("GBPUSD", PERIOD_H8, IND_MACD);
      bool f1 = ChartIndicatorAdd(0, subWindowHandle, handle_ind_h8);
      Print(GetLastError());
      
      ChartRedraw();
   }
it's not drawing:(
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Стили рисования
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Стили рисования
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Стили рисования - Документация по MQL5
 
progma137:
It does not work:(

Does it not work with iCustom either?

1. you must have the wrong currency pair in the tester

2. Wrong timeframe.

If the tester has an indicator, everything is OK.

For visualization in real time, we have to add ChartIndicatorAdd and ChartRedraw .

 
fyords:

Doesn't the iCustom also work?

1. you must have the wrong currency pair in the tester

2. Wrong timeframe.

If the tester has an indicator, everything is OK.

For visualization in real time, you have to add ChartIndicatorAdd and ChartRedraw .

1) This is not a tester. I just create a chart type object in a separate window through the indicator

2) Here all timeframes are taken into account.

As for the visualization - don't I have it?

Reason: