Forum

close[] vs iClose

I have a bar number that points to some specific time in history bar_number I'm running the chart in H1. Could you help me understand why: close[bar_number] returns a correct value iClose (_Symbol, PERIOD_H1, bar_number) - returns always 0.0. The error is 4401. Do you see why, since it's the same

Should I ALWAYS initialize indicator buffers?

Hello, I saw it mentioned on the forum that we should initialize all buffers. However, when I look at examples (like CCI or Envelopes) I don't see any initialization happening. Being precise, should I have the following snippet in my every indicator, in the onCalculate? if(prev_calculated == 0)

iBarShift() returns indexes in reverse

Hi, is there a way to make iBarShift to return indexes from left to right? I like to work with Arrays where 0 means the oldest bar, butiBarShift return it the other way round. Test case in OnCalculate: for ( int bar_number=prev_calculated; bar_number<rates_total; bar_number++) {

Standard library and Custom indicators

Hello all, A quick question. I'm developing a custom indicator based on multiple time frames. It uses regular indicators (like MA, CCI, Envelopes etc.). Should I use Standard Library for that? (like: https://www.mql5.com/en/docs/standardlibrary/technicalindicators/trendindicators/cienvelopes ). Or

Trying to understand iBarShift

Hello all, I have trouble understanding the basic concept of bar indexes. From what I see, bar with index 0 is the oldest one on the chart. The current one has index: rates_total - 1 I was trying to use iBarShift, but it seems to give me opposite results? This is what confuses me. In the example

CopyBuffer from another timeframe

Hi all, I'm new to MQL5 and I have a question about getting indicator data from another timeframe. Let's say I want to draw H1 Envelopes no matter what interval is displayed (M5, M15, M30 etc.). It means that for example on M15 the lines of the indicator should have the same value (or not?). For now

Storing data on open orders or some events that happened

Hello, I'd like to store some information about open orders, closed orders, their relation to each other. Mostly for money management but also it's a part of my strategy. But it seems that in MQL5 it's not an easy thing to do. Normally I would go for some database, or a JSON file. Any SQL database

Testing EA and multitimeframe indicators

Hello, I'm considering moving from MQL4 to MQL5 for one main reason - I use 4 indicators that work on different timeframes, For example I have "ind1" that shows an arrow pointing up when RSI is lower than 20 on H4 interval. "ind2" checks "ind1" and acts accordingly. But in MT4 in tester I cannot

Problem moving my indicator from MQL4

Hello, I have a problem with my indicator that I'm rewriting in MQL5. I have 3 buffers with data, all are meant to display the same symbol (but in different color). The indicator is a separate window, and in MQL4 I was displaying all symbols at 0.0. #property indicator_minimum - 1 #property

Value of Bars while scrolling back

Hello, could you explain why as I scroll back in the history, value of Bars increases? From the description I imagine that it would contain all Bars I can go back to. But when I load my indicator, I can see around 250 bars on my screen, Bars variable is equal to 3000. I start scrolling back the