Questions from Beginners MQL5 MT5 MetaTrader 5 - page 716

 
Artyom Trishkin:

Hi ... What do you mean you can't?

What's this, then? Five minutes in the editor...

It's perfect!

A team?

int j;
...
start()
{
........
      j=j+10;
      PlotIndexSetInteger(0,PLOT_SHIFT,j);
........
doesn't work((( //MT4, build 1031
 
Renat Akhtyamov:

THANK YOU!

Anyway.

Shifting the line in the indicator window to the right, beyond the zero bar, does work on the MT5 platform.

MT4 doesn't have that feature, it didn't work, whatever I did.

Also MT5 as far as I know has 3D modelling capability unlike MT4.

This is all very cool!

I broke down.

I switch to MT5!!! // And I do it urgently ;)

What is impossible? Shift the indicator buffer to the right? Yes, you can, even to the right or to the left ;) SetIndexShift().

But if you have decided to switch to MT5, go ahead;)

 
Renat Akhtyamov:

That's great!

Command?

int j;
...
start()
{
........
      j=j+10;
      PlotIndexSetInteger(0,PLOT_SHIFT,j);
........

Stupidly inverted the last ten values of the calculation buffer and output with a shift of 10 bars. Didn't even think about any optimization or anything. Just to show you:

//+------------------------------------------------------------------+
//|                                                  iCheckShift.mq4 |
//|              Copyright 2017, Artem A. Trishkin, Skype artmedia70 |
//|                       https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Artem A. Trishkin, Skype artmedia70"
#property link      "https://login.mql5.com/ru/users/artmedia70"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot BufferCurrent
#property indicator_label1  "BufferCurrent"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot BufferFuture
#property indicator_label2  "BufferFuture"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrDodgerBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2
//--- input parameters
input int      Shift=10;   // Смещение в будущее (баров)
//--- indicator buffers
double         BufferCurrent[];
double         BufferFuture[];
double         BufferCalculate[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorBuffers(3);
   SetIndexBuffer(0,BufferCurrent,INDICATOR_DATA);
   SetIndexBuffer(1,BufferFuture,INDICATOR_DATA);
   SetIndexBuffer(2,BufferCalculate,INDICATOR_CALCULATIONS);
   SetIndexShift(1,Shift);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   if(rates_total<1) return(0);
   ArraySetAsSeries(BufferCalculate,true);
   ArraySetAsSeries(BufferCurrent,true);
   ArraySetAsSeries(BufferFuture,true);
   int limit=rates_total-prev_calculated;
   if(limit>1) {
      limit=rates_total-1;
      ArrayInitialize(BufferCalculate,EMPTY_VALUE);
      ArrayInitialize(BufferCurrent,EMPTY_VALUE);
      ArrayInitialize(BufferFuture,EMPTY_VALUE);
      }
   for(int i=limit; i>=0; i--) {
      BufferCurrent[i]=(high[i]+low[i])/2.0;
      if(i<Shift) BufferCalculate[i]=(high[i]+low[i]+open[i]+close[i])/4.0;
      }
   for(int i=0; i<Shift; i++) {
      BufferFuture[Shift-i]=BufferCalculate[i];
      }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Vitalie Postolache:

What is not possible? Shift the indicator buffer to the right? Yes, you can, to the right or to the left ;)

But if you have decided to switch to MT5, go ahead ;)

I have written my code above. Right?
 
Renat Akhtyamov:
your code written above. Right?
I added it there. SetIndexShift(). And Artem wrote it more explicitly.
 
Vitalie Postolache:
I added it there. SetIndexShift(). And Artiom wrote it in more detail.

Finally! Problem solved.

int j=0;
...
start()
{
........
      j=j+10;
      SetIndexShift(0,j);

Everything works on MT4.

THANK YOU VERY MUCH!!!

 
Hello !
My question is this:
There is a MACD in the indicator window that has some "A" value calculated on the current price. What would be the formula to calculate the price value if the current MACD value became "-A" ?
 
Leo59:
Hello !
My question is this:
There is a MACD in the indicator window that has some "A" value calculated on the current price. What should be the formula that calculates the price value if the current MACD value became "-A" ?
https://ru.wikipedia.org/wiki/%D0%98%D0%BD%D0%B4%D0%B8%D0%BA%D0%B0%D1%82%D0%BE%D1%80_MACD
Индикатор MACD — Википедия
Индикатор MACD — Википедия
  • ru.wikipedia.org
Индикатор используют для проверки силы и направления тренда, а также определения разворотных точек. Строится на основе скользящих средних. Существует две модификации индикатора MACD: линейный MACD и MACD-гистограмма. Для расчёта линейного MACD из скользящей средней цены (обычно берётся экспоненциальная скользящая средняя с меньшим периодом...
 
Renat, thank you of course for your participation.... But, the question was about something else:
There is a MACD in the indicator window, which has some "A" value calculated on the current price. What should be the formula to calculate the price value if the current MACD value became "-A" ?
 
Leo59:
Renat, thank you, of course, for your participation.... But, the question was about something else:
There is a MACD in the indicator window, which has some "A" value calculated on the current price. What would be the formula to calculate the price value if the current MACD value became "-A"?
Perhaps, it would be worth showing the formula calculating when some "A" value has a positive value - it is not clear what we are talking about.
Reason: