//+------------------------------------------------------------------+
//| FFMS.mq4 |
//| Copyright 2012, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 6
extern int FastMA1_Period = 5;
extern int FastMA1_Method = 3;
extern int FastMA1_Mode = 5;
extern int FastMA2_Period = 2;
extern int FastMA2_Method = 1;
extern int SlowMA1_Period = 24;
extern int SlowMA1_Method = 3;
extern int SlowMA1_Mode = 5;
extern int SlowMA2_Period = 2;
extern int SlowMA2_Method = 1;
extern int TopBand_Period = 5;
extern int TopBand_Method = 0;
extern int TopBand_Mode = 2;
extern int BottomBand_Period = 5;
extern int BottomBand_Method = 0;
extern int BottomBand_Mode = 3;
double MomentumCurr[];
double MomentumPrev[];
double Bullish[];
double Bearish[];
double BullishConfluence[];
double BearishConfluence[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,MomentumCurr);
SetIndexBuffer(1,MomentumPrev);
SetIndexBuffer(2,Bullish);
SetIndexBuffer(3,Bearish);
SetIndexBuffer(4,BullishConfluence);
SetIndexBuffer(5,BearishConfluence);
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_NONE);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_HISTOGRAM);
SetIndexStyle(4,DRAW_HISTOGRAM);
SetIndexStyle(5,DRAW_HISTOGRAM);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double FastMA1;
double FastMA2;
double SlowMA1;
double SlowMA2;
double TopBand;
double BottomBand;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=0; i<limit; i++)
FastMA1 = iMA(NULL, 0, FastMA1_Period, 0, FastMA1_Method, FastMA1_Mode, i);
FastMA2 = iMAOnArray(FastMA1,0,FastMA2_Period,0,FastMA2_Method,i);
SlowMA1 = iMA(NULL, 0, SlowMA1_Period, 0, SlowMA1_Method, SlowMA1_Mode, i);
SlowMA2 = iMAOnArray(SlowMA1,0,SlowMA2_Period,0,SlowMA2_Method,i);
TopBand = iMA(NULL, 0, TopBand_Period, 0, TopBand_Method, FastMA1_Mode, i);
BottomBand = iMA(NULL, 0, BottomBand_Period, 0, BottomBand_Method, BottomBand_Mode, i);
MomentumCurr[i] = (FastMA2 - SlowMA2);
MomentumPrev[i] = (MomentumCurr[i+1]);
for(i=0; i<limit; i++)
{
if ((MomentumCurr[i] > MomentumPrev[i]) && (Close[i] > TopBand))
{
Bullish[i] = MomentumCurr[i];
Bearish[i] = 0.0;
BullishConfluence[i] = 0.0;
BearishConfluence[i] = 0.0;
}
if ((MomentumCurr[i] < MomentumPrev[i]) && (Close[i] < BottomBand))
{
Bullish[i] = 0.0;
Bearish[i] = MomentumCurr[i];
BullishConfluence[i] = 0.0;
BearishConfluence[i] = 0.0;
}
if ((MomentumCurr[i] > MomentumPrev[i]) && (Close[i] > TopBand))
{
Bullish[i] = 0.0;
Bearish[i] = 0.0;
BullishConfluence[i] = MomentumCurr[i];
BearishConfluence[i] = 0.0;
}
if ((MomentumCurr[i] < MomentumPrev[i]) && (Close[i] < BottomBand))
{
Bullish[i] = 0.0;
Bearish[i] = 0.0;
BullishConfluence[i] = 0.0;
BearishConfluence[i] = MomentumCurr[i];
}
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+
- HELP ME! HISTORY VOLATILITY CONNORS RASCHKE RATIO 100/6
- Keltner Channel : Could some please program this for me !
- Help on RSI please.
this is my first attempt at mlq4 and i cant figure out why this indicator wont display the histogram
please point out my mistakes lol
Please use SRC button to post your code
LanBar: what is wrong here
- Not Using SRC
for(int i=0; i<limit; i++) FastMA1 = iMA(NULL, 0, FastMA1_Period, 0, FastMA1_Method, FastMA1_Mode, i); FastMA2 = iMAOnArray(FastMA1,0,FastMA2_Period,0,FastMA2_Method,i); SlowMA1 = iMA(NULL, 0, SlowMA1_Period, 0, SlowMA1_Method, SlowMA1_Mode, i); SlowMA2 = iMAOnArray(SlowMA1,0,SlowMA2_Period,0,SlowMA2_Method,i);
Using iMAOnArray with a variable not an array- Counting up the arrays won't be set before the iMAOnArray
for(i=0; i<limit; i++) { if ((MomentumCurr[i] > MomentumPrev[i]) && (Close[i] > TopBand))
TopBand is from a newer bar, so your indicator repaints - meaning it is useless
Thanks WHRoeder ... for your help and your candor let me give this another shot and I will repost
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register