Coding help - page 91

 
k3rn3l:
mladen..can you correct the error?

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

//| MTF_RSI.mq4 |

//| Copyright © 2006, Keris2112 |

//| |

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

#property copyright "Copyright © 2006, Keris2112"

#property link "https://www.forex-tsd.com"

//----

#property indicator_separate_window

#property indicator_buffers 3

#property indicator_color1 Red

#property indicator_color2 DodgerBlue

#property indicator_color3 White

#property indicator_level1 30

#property indicator_level2 70

#property indicator_minimum 0

#property indicator_maximum 100

//----

extern int TimeFrame=5;

extern int RSIperiod=33;

extern int applied_price=0;

extern int TimeFrame1=15;

extern int RSIperiod1=21;

extern int applied_price1=0;

extern int TimeFrame2=15;

extern int RSIperiod2=14;

extern int applied_price2=0;

//----

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicator line

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(1,DRAW_LINE);

SetIndexBuffer(2,ExtMapBuffer3);

SetIndexStyle(2,DRAW_LINE);

//---- name for DataWindow and indicator subwindow label

switch(TimeFrame)

{

case 1 : string TimeFrameStr="Period_M1"; break;

case 5 : TimeFrameStr="Period_M5"; break;

case 15 : TimeFrameStr="Period_M15"; break;

case 30 : TimeFrameStr="Period_M30"; break;

case 60 : TimeFrameStr="Period_H1"; break;

case 240 : TimeFrameStr="Period_H4"; break;

case 1440 : TimeFrameStr="Period_D1"; break;

case 10080 : TimeFrameStr="Period_W1"; break;

case 43200 : TimeFrameStr="Period_MN1"; break;

default : TimeFrameStr="Current Timeframe";

}

IndicatorShortName("MTF_RSI("+RSIperiod+") ("+TimeFrameStr+")");

}

//----

return(0);

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

//| MTF RSI |

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

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);

limit=Bars-counted_bars;

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++;

//----

ExtMapBuffer1=iRSI(NULL,TimeFrame,RSIperiod,applied_price,y);

}

datetime TimeArray1[];

int ii,limiti,yi=0,counted_bars1=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray1,MODE_TIME,Symbol(),TimeFrame1);

limiti=Bars-counted_bars1;

for(ii=0,yi=0;ii<limiti;ii++)

{

if (Time<TimeArray1[yi]) yi++;

//----

ExtMapBuffer2=iRSI(NULL,TimeFrame1,RSIperiod1,applied_price1,yi);

}

datetime TimeArray2[];

int iii,limitii,yii=0,counted_bars2=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray2,MODE_TIME,Symbol(),TimeFrame2);

limitii=Bars-counted_bars2;

for(iii=0,yii=0;iii<limitii;iii++)

{

if (Time<TimeArray2[yii]) yii++;

//----

ExtMapBuffer3=iRSI(NULL,TimeFrame2,RSIperiod2,applied_price2,yii);

}

//----

return(0);

}

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

Try out the attached one

Files:
 

Hi Mladen,

please,can you add "velo6" to the attached indicator?

I need input for color and "true-false"....see image for example.

ALWAYS THANK YOU......

Files:
euro.gif  32 kb
 

1) during trend, bollinger bands become widen.....then trend stops and there is treding range.During trading range bollinger bands contract and in this situation is very good to use stoc oversold-overbought.

this is my metastoch formula...

WIDTH:=

((Mov(C,71,S)+(2*(Std(C,71))))-

(Mov(C,71,S)-(2*(Std(C,71)))));

MEDIA:=Mov(WIDTH,15,S);

ST:=Stoch(5,3);

TIME:=BarsSince(WIDTH=0 AND

BarsSince(WIDTH<MEDIA)<=5;

CONDBUY:=ST<=30 OR (Ref(ST<=30,-1) AND H<=Ref(H,-1));

TIME AND CONDBUY

EXPLANATION:

1) I use bollinger band 71 and deviation 2

2) on bollinger band width I apply a 15 simple moving average

3) when bollinger band width is below SMA and also for 5 bars after that ,it means that market is began to trading range....

4) when there is trading range I see for stochastic below 30

Files:
 
carbonmimetic:
Hi Mladen,

please,can you add "velo6" to the attached indicator?

I need input for color and "true-false"....see image for example.

ALWAYS THANK YOU......

carbonmimetic

Here you go

Files:
 

...as I said before...ALWAYS THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

Hi Mladen

To bother you please put the code into MT4 indicators okay?

I'm anxious to test.

Thanks You

Kreangast

2013/5/25

 
Kreangast:
Hi Mladen

To bother you please put the code into MT4 indicators okay?

I'm anxious to test.

Thanks You

Kreangast

2013/5/25

Sorry

Since I do not use Amibroker I can not convert that code to metatrader 4 and to be 100% sure that it is correct (and I would hate to be responsible for some incorrectly coded indicator)

 
mladen:
Sorry Since I do not use Amibroker I can not convert that code to metatrader 4 and to be 100% sure that it is correct (and I would hate to be responsible for some incorrectly coded indicator)

Hi Mladen

Sorry ! AMI Since the problem has been resolved.

Thank you please help replace MT4.

"-BarsSince(X)=BarsLate(X)"

_SECTION_BEGIN("pfoot");

TimeFrameSet(inDaily);

TR=Max(Max((High-Low),abs(Ref(Close,-1)-High)),abs(Ref(Close,-1)-Low));

A= H-(TR*0.3);

A1=H-(TR*0.6);

A2=H-(TR*0.8);

A3=H-(TR*1.0);

//

B= L+(TR*0.3);

B1=L+(TR*0.6);

B2=L+(TR*0.8);

B3=L+(TR*1.0);

//

N=100;

H2=H==HHV(H,N);//

L2=L==LLV(L,N);//

PPF=Ref(A,-BarsSince(H2));//-BarsSince=BarsLate

PPF1=Ref(A1,-BarsSine(H2));//

PPF2=Ref(A2,-BarsSine(H2));//

PPF3=Ref(A3,-BarsSine(H2));//

//

PPFF=Ref(B,-BarsSince(L2));//

PPFF1=Ref(B1,-BarSince(L2));//

PPFF2=Ref(B2,-BarsSince(L2));//

PPFF3=Ref(B3,-BarsSince(L2));//

TimeFrameRestore();

// Plot the Support Levels Clouds and Lines //

Plot(TimeFrameExpand(PPF,inDaily ,expandLast), "R1", colorGreen, styleThick);

Plot(TimeFrameExpand(PPF1,inDaily ,expandLast), "R2", colorGreen,styleThick);

Plot(TimeFrameExpand(PPF2,inDaily ,expandLast), "R3", colorGreen,styleThick);

Plot(TimeFrameExpand(PPF3,inDaily ,expandLast), "R4", colorGreen,styleThick);

Plot(TimeFrameExpand(PPFF,inDaily ,expandLast), "S1", colorBlue, styleThick);

Plot(TimeFrameExpand(PPFF1,inDaily ,expandLast), "S2", colorBlue,styleThick);

Plot(TimeFrameExpand(PPFF2,inDaily ,expandLast), "S3", colorBlue,styleThick);

Plot(TimeFrameExpand(PPFF3,inDaily ,expandLast), "S4", colorBlue,styleThick);

_SECTION_END();

Thank you

Kreangast

 

I formulate my question here.

What is the method to reduce the number of bars that shows an indicator on the chart?

Without having to reduce the number of bars shown in the graph Metatrader.

There is some lines of code that can be applied to large number of indicators?

Thank you for your attention.

 
Antonsan:
I formulate my question here.

What is the method to reduce the number of bars that shows an indicator on the chart?

Without having to reduce the number of bars shown in the graph Metatrader.

There is some lines of code that can be applied to large number of indicators?

Thank you for your attention.

Antonsan

Please read this post : https://www.mql5.com/en/forum/180284/page31 . Will repeat the essence - you must change the limit of bars in the code. There is no other way.

Reason: