MA ribbon MTF

Indicators coded by community members
Message
Author
kenjiho
Posts: 1
Joined: Wed Jul 10, 2013 10:51 pm

MA ribbon MTF

#1 Postby kenjiho » Wed Mar 25, 2015 8:35 pm

Hi,
Please help me convert mt4 indicator to Forex tester 2 indicator
I can not upload the file,please see the code below.
Thanks.

***********************************************************************************

//+------------------------------------------------------------------+
//| MA ribbon.mq4 |
//| mladenfx@gmail.com |
//| |
//| original idea by Jose Silva |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link "mladenfx@gmail.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Bisque
#property indicator_color2 PowderBlue
#property indicator_color3 DarkOrange
#property indicator_color4 DarkGreen
#property indicator_width1 5
#property indicator_width2 5
#property indicator_width3 1
#property indicator_width4 1

//
//
//
//
//

extern int MA1Period = 21;
extern int MA1Method = MODE_EMA;
extern int MA1Price = PRICE_CLOSE;
extern int MA2Period = 8;
extern int MA2Method = MODE_EMA;
extern int MA2Price = PRICE_CLOSE;
extern int TimeFrame = 240;
extern string note_TimeFrames_ = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-currentTF";

//
//
//
//
//

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];
string IndicatorFileName;

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
string short_name;
SetIndexBuffer(0,buffer3); SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(1,buffer4); SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(2,buffer1);
SetIndexBuffer(3,buffer2);
switch(TimeFrame)
{
case 1: string TimeFrameStr = "M1" ; break;
case 5 : TimeFrameStr = "M5" ; break;
case 15 : TimeFrameStr = "M15"; break;
case 30 : TimeFrameStr = "M30"; break;
case 60 : TimeFrameStr = "H1" ; break;
case 240 : TimeFrameStr = "H4" ; break;
case 1440 : TimeFrameStr = "D1" ; break;
case 10080 : TimeFrameStr = "W1" ; break;
case 43200 : TimeFrameStr = "MN1"; break;
default : TimeFrameStr = "TF0";
}

TimeFrame = MathMax(TimeFrame,Period());
IndicatorFileName = WindowExpertName();
short_name=("Ma Ribbon Filled("+TimeFrameStr+")") ;
IndicatorShortName(short_name);
return(0);
}
int deinit()
{
return(0);
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

int start()
{
int counted_bars=IndicatorCounted();
int limit,i;

if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

if (TimeFrame != Period())
{
limit = MathMax(limit,TimeFrame/Period());
for(i=0; i<limit; i++)
{
int y = iBarShift(NULL,TimeFrame,Time[i]);
buffer1[i] = iCustom(NULL,TimeFrame,IndicatorFileName,MA1Period,MA1Method,MA1Price,MA2Period,MA2Method,MA2Price,0,y);
buffer2[i] = iCustom(NULL,TimeFrame,IndicatorFileName,MA1Period,MA1Method,MA1Price,MA2Period,MA2Method,MA2Price,1,y);
buffer3[i] = iCustom(NULL,TimeFrame,IndicatorFileName,MA1Period,MA1Method,MA1Price,MA2Period,MA2Method,MA2Price,2,y);
buffer4[i] = iCustom(NULL,TimeFrame,IndicatorFileName,MA1Period,MA1Method,MA1Price,MA2Period,MA2Method,MA2Price,3,y);
}
return(0);
}

//
//
//
//
//

for(i=limit; i>=0; i--)
{
buffer1[i] = iMA(NULL,0,MA1Period,0,MA1Method,MA1Price,i);
buffer2[i] = iMA(NULL,0,MA2Period,0,MA2Method,MA2Price,i);
buffer3[i] = buffer1[i];
buffer4[i] = buffer2[i];
}
return(0);
}

**************************************************************************************************************

Return to “Indicators”

Who is online

Users browsing this forum: No registered users and 1 guest