# Who has extra buffer? or half? 4 Rsioma - page 2

3203

here's how magic was done:

code before:

.......

double marsioma[];

double marsiomaXSig[];

string short_name;

//+------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------+

........

SetIndexLabel(2,"TrendUp");

SetIndexLabel(6,"Up/DnXsig");

IndicatorShortName(short_name);

SetIndexDrawBegin(0,RSIOMA);

SetIndexDrawBegin(1,RSIOMA);

SetIndexDrawBegin(2,RSIOMA);

SetIndexDrawBegin(3,RSIOMA);

SetIndexDrawBegin(4,RSIOMA);

SetIndexDrawBegin(5,RSIOMA);

SetIndexDrawBegin(6,RSIOMA);

SetIndexDrawBegin(7,RSIOMA);

//----

drawLine(BuyTrigger,"BuyTrigger", BuyTriggerColor);

..............

//+----------------------------------------------------+

//+-----------------------------------------------------+

int start()

{

int i, ii;

int counted_bars=IndicatorCounted();

double rel,negative,positive;

//----

if(Bars<=RSIOMA) return(0);

//---- initial zero

if(counted_bars<1)

for(i=1;i<=RSIOMA;i++) {RSIBuffer=0.0;}

//----

ii=Bars-RSIOMA-1;

if(counted_bars>=RSIOMA) ii=Bars-counted_bars-1;

i = ii;

while(i>=0)

{ MABuffer1=iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,i);

i--; }

i=ii;

while(i>=0)

{ RSIBuffer=iRSIOnArray(MABuffer1,0,RSIOMA,i);

if(RSIBuffer>50) bup = 6;

if(RSIBuffer<50) bdn = -6;

3203

code after:

..................

datetime lastBarTime;

string short_name;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

SetIndexLabel(2,"TrendUp");

SetIndexLabel(6,"Up/DnXsig");

for (int i=0;i<indicator_buffers;i++) SetIndexDrawBegin(i,RSIOMA);

//

// additional buffer(s)

ArraySetAsSeries(MABuffer1,true);

ArrayResize(MABuffer1,Bars);

ArrayInitialize(MABuffer1,EMPTY_VALUE);

lastBarTime = EMPTY_VALUE;

//

drawLine(BuyTrigger,"BuyTrigger", BuyTriggerColor);

..............

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted();

int i, limit;

if(Bars<=RSIOMA) return(0);

if(counted_bars<1) for(i=1;i<=RSIOMA;i++) RSIBuffer=0.0;

if (lastBarTime != Time[0]) {

lastBarTime = Time[0];

ArrayResize(MABuffer1,Bars);

ArrayInitialize(MABuffer1,EMPTY_VALUE); counted_bars=0;

}

limit=Bars-RSIOMA-1;

if(counted_bars>=RSIOMA) limit=Bars-counted_bars-1;

for(i=limit;i>=0;i--)

MABuffer1=iMA(Symbol(),0,RSIOMA,0,RSIOMA_MODE,RSIOMA_PRICE,i);

for(i=limit;i>=0;i--)

{

RSIBuffer=iRSIOnArray(MABuffer1,0,RSIOMA,i);

if(RSIBuffer>50) bup = 6;

if(RSIBuffer<50) bdn = -6;

1411

fxbs:
Rsioma (RSI of MA) needs one more buffer 4 signals

may be if some wizard have nothing better to do...

i know somehow it possible avoid 8 buff restriction through Maonarray, but i couldn't - didn't finish wizard's school

plus one buffer used only 4 RSI calc... (code, link and indi below)

PS very nice little indi - rsioma

more: Thread RSI of MA pos126 https://www.mql5.com/en/forum/177347/page9

Well, it is like that:

we have 8 buffers avaliable in metatrader, but buffers are special arrays that allows us to draw something on the chart. So we could use them to draw:

1) rsioma

2) marsiona

3) green histogram

4) red histogram

5) pink histogram

6) blue histogram

7) short signal dot (up or down)

8) long signal dot (up or down)

To do something like that you need:

1) use an array instead of buffer array. This will require from you to define an double array in the global section for the moving average calculation, then at the begining of the start function - resize it to full buffer size, then fill it with iMA function and use like a buffer. In this way you will have one free buffer to draw.

OR

2) leave everything as it is, write a function that will draw ARROW OBJECT with code choosen by you (arrow, dot or something else from wingdings) and manage those arrows. It means that this function should draw arrow on right window with value that you would usualy assign to buffer.

Both solutions are very easy. I could do it if you could write when and which arrow/dot should be draw - and please attach screenshot (eg. draw in paint).

1411

In fact, I see that Mladen done a good job. And modified this indicator already. In his version you have 1 buffer free to go (take a look that this indicator is using buffers from 0 to 6 and we can use from 0 to 7) so you can use it to generate the signal that you want just as a usual buffer.

BTW great hint Mlanden with that ArraySetAsSeries

105252

...

Glad I could help a little bit

3203

Kalenzo:
...... use an array instead of buffer array. This will require from you to define an double array in the global section for the moving average calculation, then at the begining of the start function - resize it to full buffer size, then fill it with iMA function and use like a buffer. In this way you will have one free buffer to draw.

Hi, Kalenzo! Could you show on simple example how to change buffer array to double array, please? (not like I'm going to add dozen more buffers to Rsioma - no way!)

105252

An addition to ArraySeAsSerries

Kalenzo:
BTW great hint Mlanden with that ArraySetAsSeries

Actualy (unfortunately) there is an addition :

Metatrader obviously treats arrays declared as index and a simple array diferently:

ArrayResize fills the added cells with EMPTY_VALUE (if you did not declare differently by SetIndexEmptyValue)

But when, for example iMa references that cell from index it is returned 0, and from your array it gets EMPTY_VALUE (=2147483647) so anyone trying to use arrays as indexes must make sure that if array is going to be used in internal functions, all EMPTY_VALUEs are replaced with 0

So far this is what I found out abbout this issue

3203

This means - Kalenzo gives GreenLight on arsioma v3

your version, Mladen!

3203

And since it's your version, could you consider to add CountedBars and refreshing bufers options?

(autentic - by the author himself) (and I can do all the hard work - desiding on the colors?)

mladen:
You might consider adding a bars number restriction (it would make the code faster)

and if you add

{

RSIBuffer=iRSIOnArray(MABuffer1,0,RSIOMA,i);

//

//

// this code

//

//

"bup = EMPTY_VALUE; bdn = EMPTY_VALUE;"

"sup = EMPTY_VALUE; sdn = EMPTY_VALUE;"

if(RSIBuffer > 50) bup = 6;

you will avoid some repainting when changing time frames or accounts

glad that could help

regards

mladen
105252

The lates

The latest version of RSIOMA

Files:
To add comments, please log in or register