Questions from Beginners MQL5 MT5 MetaTrader 5 - page 604

 
new-rena:

Counter question.

Do you think the movement on any currency pair: chart, bid and ask prices and so on, depend on a set of your variables?

The rate movement does not depend on the variables, but a trader tries to find regularities in the movement, and on this basis he selects variables (input data) for opening, holding and closing positions. After all, the trading system is a set of rules intended for profitable work. Perhaps, distribution of profits and losses is random, but their proportion is different and, therefore, profitable trading systems are formed. That must be so.
 
Евгений:
The movement of the rate does not depend on the variables, but the trader tries to find patterns in the movement, and on this basis he chooses the variables (input data) for opening, maintaining and closing the position. After all, the trading system is a set of rules intended for profitable work. Perhaps, distribution of profits and losses is random, but their proportion is different and, therefore, profitable trading systems are formed. I guess so.
Basically, you have answered your own question. That is, on the same price movement you can get the following; profit-loss = CONST
 
suggest a function on the restriction, in the Expert Advisor I want to put a ban on selling or buying from the moving average.
 
KoltRU:
Please advise function to limit, in Expert Advisor I want to put a ban on selling or buying from a moving average.
I made it simpler, I added a condition on opening
 

This is a nuisance. The array reference is not passed to the function.

void GetIndValue(int IndNo, int Vol, double *out[]){;};

With this double *out[] - no matter how you write it, all the errors occur.

'BatIndicators.mqh' BatIndicators.mqh 1 1

'*' - pointer cannot be used BatIndicators.mqh 18 45

'out' - arrays are passed by reference only BatIndicators.mqh 18 46

2 error(s), 0 warning(s) 3 1

either one or the other or both. I remember there was no problem before, or it's in C. )


 
Yuriy Asaulenko:

This is annoying. The array reference is not passed to the function.

With this double *out[] - no matter how you write it, all the errors occur.

'BatIndicators.mqh' BatIndicators.mqh 1 1

'*' - pointer cannot be used BatIndicators.mqh 18 45

'out' - arrays are passed by reference only BatIndicators.mqh 18 46

2 error(s), 0 warning(s) 3 1

either one or the other or both. I remember there was no problem before, or it's in C. )


Try it like this

void GetIndValue(int IndNo, int Vol, double &out[]){}
 
Andrey Barinov:

Try this

Thank you.
 

//--- get the number of the new subwindow, in which we will try to add indicator

int subwindow=(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL);

This is the code I'm looking at https://www.mql5.com/ru/docs/chart_operations/chartindicatoradd

The example shows how to put an indicator in a subwindow. If you don't need a subwindow, just use the muwig example to show how to do it?

Документация по MQL5: Операции с графиками / ChartIndicatorAdd
Документация по MQL5: Операции с графиками / ChartIndicatorAdd
  • www.mql5.com
Операции с графиками / ChartIndicatorAdd - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexander Antoshkin:

//--- get the number of a new subwindow, in which we will try to add an indicator

int subwindow=(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL);

This is the code I'm looking at https://www.mql5.com/ru/docs/chart_operations/chartindicatoradd

The example shows how to put an indicator in a subwindow. If you don't need a subwindow, just use the muwig example to show how to do it?

If you want to add the indicator to the main window, then:

sub_window

[in] Subwindow number of the chart. 0 means main chart window. To add an indicator to a new window, the parameter must be one more than the index of the last existing window, i.e. equal toCHART_WINDOWS_TOTAL. If the parameter value exceedsCHART_WINDOWS_TOTAL value, a new window will not be created, the indicator will not be added.

 
Karputov Vladimir:

If you need to add an indicator to the main window, then:

//+------------------------------------------------------------------+
//|                                                         0000.mq5 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

input int MA_Period=21; 
input int MA_Shift=0; 
input ENUM_MA_METHOD MA_Method=MODE_SMA;

int MA_handle=INVALID_HANDLE; 
//+------------------------------------------------------------------+ 
//| Expert initialization function                                   | 
//+------------------------------------------------------------------+ 
int OnInit() 
  { 
  
   MA_handle=iCustom(NULL,0,"Examples\\Custom Moving Average",  MA_Period,  MA_Shift, MA_Method,  PRICE_CLOSE  );
//--- попробуем добавить индикатор на график 
AddIndicator();

   return(INIT_SUCCEEDED); 
  } 

//+------------------------------------------------------------------+ 
//| Функция проверки и добавления индикатора на график               | 
//+------------------------------------------------------------------+ 
bool AddIndicator() { if(MA_handle==INVALID_HANDLE) 
{ Print(__FUNCTION__,"  Создаем индикатор ");

 MA_handle=iCustom(NULL,0,"Examples\\Custom Moving Average",  MA_Period,  MA_Shift, MA_Method,  PRICE_CLOSE  );
if(MA_handle==INVALID_HANDLE) 
{ 
 Print("Не удалось создать индикатор . Код ошибки ",GetLastError()); 
 } 
  }     
//--- сбросим код ошибки 
   ResetLastError(); 
//--- накладываем индикатор на график 
  
   Print("Mа построен "); 
//--- получим номер нового подокна, в которое добавим индикатор  
   int subwindow=(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL); 
   PrintFormat("Добавляем индикатор на окно %d графика",subwindow); 
   if(!ChartIndicatorAdd(0,subwindow,MA_handle)) 
     { 
      PrintFormat("Не удалось добавить индикатор  на окно %d графика. Код ошибки  %d", 
                  subwindow,GetLastError()); 
     } 
   return(true); 
  } 
void OnDeinit(const int reason)
{
MA_handle=iCustom(NULL,0,"Examples\\Custom Moving Average",  MA_Period,  MA_Shift, MA_Method,  PRICE_CLOSE  );

Hello Vladimir.

I must have phrased my question incorrectly.

I don't need a sub-window, the indicator should be placed on the price chart, like a standard chart

I regard it as an example and try to understand .

I want the indicator mounted on the chart to have its own number, so that the necessary number of copies can be created on the chart using the "Add" button ..... I want to delete one selected by the "cross" button ........ (I don't want to describe them yet))

Reason: