Questions from Beginners MQL5 MT5 MetaTrader 5 - page 716
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi ... What do you mean you can't?
What's this, then? Five minutes in the editor...
It's perfect!
A team?
...
start()
{
........
j=j+10;
PlotIndexSetInteger(0,PLOT_SHIFT,j);
........
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;)
That's great!
Command?
...
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);
}
//+------------------------------------------------------------------+
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 ;)
your code written above. Right?
I added it there. SetIndexShift(). And Artiom wrote it in more detail.
Finally! Problem solved.
...
start()
{
........
j=j+10;
SetIndexShift(0,j);
Everything works on MT4.
THANK YOU VERY MUCH!!!
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" ?
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
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" ?
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"?