Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1896

 
Valeriy Yastremskiy #:

A[0]=Bid;

for(i=0;i<60;i++){A[i+1]=A[i]}

I did it, it works.

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(prev_calculated==0) {
    ArrayInitialize(Buffer1,EMPTY_VALUE);
  }
  double b=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  Buffer1[0]=b;
  for(int j=10; j>0; j--) {
    Buffer1[j]=Buffer1[j-1];
  }
  return(rates_total);
}

---

Something tells me I can do without the loop.

Is it so?

 
Vitaly Muzichenko #:

I did it, it works.

---

Something tells me you can do without the cycle.

Is this true?

In timeseries this loop is hidden. it makes no difference which side to move. it makes more sense to me from 0. I haven't seen any shift functions in MKL. It's an index job. It is first in, last out. It does in python. It doesn't seem to exist in MCL.

 

Here's what's wrong?

It starts to work fine, but on each new bar there is an offset and out of range.

How to avoid it?

---

P.S. I think that's it, it's working fine, I've added

  if(rates_total-prev_calculated==1) {
    Buffer1[H+1]=EMPTY_VALUE;
  }
 
Vitaly Muzichenko #:

Here's what's wrong?

It starts to work fine, but on each new bar there is an offset and out of range.

How to avoid it?

---

P.S. Seems to work fine, added

On the smaller side of the index check for less than zero, on the larger side, for more than the array dimensionality. Zeroing of array or last value is kinda not logical on every tick.

 
Valeriy Yastremskiy #:

on the smaller side of the index check for less than zero, on the larger side, for more than the array dimension. Zeroing the array or the last value isn't logical.

Array for all available history, I don't need that.

I literally need 50-100 bars.

Like this


 

Good afternoon .

I am displaying the value of the daily fractal in the form of its value or a vertical line. The line is not displayed and the value is 0.

Here is a piece of code

 double FractalDayUpper = iFractals(Symbol(), PERIOD_D1, MODE_UPPER, 0);
   ObjectCreate("signal00",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("signal00",OBJPROP_XDISTANCE,600);
   ObjectSet("signal00",OBJPROP_YDISTANCE,100);
   ObjectSetText("signal00",DoubleToString(FractalDayUpper,5),18,"Times New Roman", clrRed);


Please tell me what's wrong.

 
EVGENII SHELIPOV #:

Good afternoon .

I am displaying the value of the daily fractal in the form of its value or a vertical line. The line is not displayed and the value is 0.

Here is a piece of code


Please tell me what's wrong.

Because the value is 0. The fractal is formed after n candlesticks.

 
Vitaly Muzichenko #:

Array for all available history, I don't need that.

I literally need 50-100 bars.

Like this.


What is the point of the indicator? If it's not a secret of course) The problem is in the time display. I.e. it's not real tick time, it's number time. Each number on its own bar of the TF.

 
Valeriy Yastremskiy #:

What is the point of the indicator? If it's no secret of course) The problem there is of course in the time display. I.e. it's not the real ticking time, but the numbered time. Each number on its own bar of TF.

The point, to see the last ticks on the open chart :)

P.S. * Change of Ask and Bid

As in Market Watch


 
Tretyakov Rostyslav #:

Because the value is 0. A fractal is formed after n candles

A fractal is formed if there is no new extremum and after three bars those are 0, 1, 2.

double FractalDayUpper = iFractals(Symbol(), PERIOD_D1, MODE_UPPER, 2);
   ObjectCreate("signal00",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("signal00",OBJPROP_XDISTANCE,600);
   ObjectSet("signal00",OBJPROP_YDISTANCE,100);

Nothing has changed.

Or something is wrong again.