Drawing Candles, what's wrong? - page 2

 

Thank you Admin for merging the two posts.

I made changes to the source code, I wonders to open new thread or to delete the current and open new one.

Ok the next time I will post the updates to the same thread.


Thank you again

 
Lorentzos Roussos #:

if you mean the 10 bars from the right then change it to 

bar [0] is the oldest

But then you will also have to paint the bar that slides out of the 10 bars range

Although it works, but I am not satisfied. It is against my logic.

I there a way to make plots from right to left (New bars to old)

Thanks

 
egyptnile #:

Although it works, but I am not satisfied. It is against my logic.

I there a way to make plots from right to left (New bars to old)

Thanks

yes use ArraySetAsSeries - Array Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

otherwise if i is the index from left to right 

then i_mirror is the index from right to left

i_mirror = rates_total-1-i

Documentation on MQL5: Array Functions / ArraySetAsSeries
Documentation on MQL5: Array Functions / ArraySetAsSeries
  • www.mql5.com
The function sets the AS_SERIES flag to a selected object of a dynamic array , and elements will be indexed like in timeseries . Parameters array[]...
 
Lorentzos Roussos #:

yes use ArraySetAsSeries - Array Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

otherwise if i is the index from left to right 

then i_mirror is the index from right to left

i_mirror = rates_total-1-i

Ok that's fine.

But what makes some logical confusion, other mql5 functions such as iOpen(), iTime() .. ets, they consider bar0 is the newest created bar, from the right

Thank you again

 
egyptnile #:

Ok that's fine.

But what makes some logical confusion, other mql5 functions such as iOpen(), iTime() .. ets, they consider bar0 is the newest created bar, from the right

Thank you again

Yeah , if you are working an indicator on mt5 avoid those . Prefer the on calculate arrays.

 
egyptnile #:

Although it works, but I am not satisfied. It is against my logic.

I there a way to make plots from right to left (New bars to old)

Thanks

since you are still figuring all this out, it might help you to look at some code examples in the codebase, and here I make two versions of a moving average (each code working the same but one of them with buffers set to series so that the buffers are indexed as in MQL4)

Code Base

Portable Moving Average

Conor Mcnamara, 2025.02.03 14:35

Calculate a moving average in one function call. Code that can easily be transported between different projects.

 
Conor Mcnamara #:

since you are still figuring all this out, it might help you to look at some code examples in the codebase, and here I make two versions of a moving average (each code working the same but one of them with buffers set to series so that the buffers are indexed as in MQL4)


Thank you for your educational indicator code. it is the slope indicator in MQL4

I will try it