first of all I want to apologize if you do not understand what I said, I am French and this is an automatic translation.
So, I created an indicator of relative strength for metatrader, the code is very simple, think you can bear the same for your platform?
In fact this is a first step in creating a variable that I'll call Idx:
Idx [i] = MathLog (Symbol_A) / MathLog (Symbol_B);
then the indicator that we see is:
Indicator [i]) MovingAverage (Idx, Fast) - MovingAverage (Idx, Slow)
And it colors the red zone or green depending on whether it is above 0 or not.
Here is a screen and code the indicator:)
Thks
- Code: Select all
//+------------------------------------------------------------------+
//| force relative.mq4 |
//| Copyright © 2010, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 3
extern string Paire="EURUSD";
extern int Barres=1000;
extern int Fast=1;
extern int Slow=100;
double Ma[];
double Up[];
double Down[];
double Idx[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(5);
SetIndexBuffer(0,Ma);
SetIndexStyle(0,DRAW_HISTOGRAM,0,3,LightGreen);
SetIndexDrawBegin(0, Fast);
SetIndexBuffer(1,Up);
SetIndexStyle(1,DRAW_HISTOGRAM,0,3,Wheat);
SetIndexDrawBegin(1, Fast);
SetIndexBuffer(2,Down);
SetIndexStyle(2,DRAW_LINE,0,2,Black);
SetIndexDrawBegin(2, Fast);
SetIndexBuffer(4, Idx);
IndicatorShortName("Wtfx Fr: "+Paire+" "+Fast+" "+Slow+"");
//---- indicators*/
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
//----
for (int i=0;i<Barres;i++)
{
Idx[i]=(iClose(Symbol(),0,i)/iClose(Paire,0,i));
}
for(int k=0;k<Barres-Slow;k++)
{
Ma[k]= iMAOnArray(Idx,0,Fast,0,MODE_SMA,k)-iMAOnArray(Idx,0,Slow,0,MODE_SMA,k);
if(Ma[k]<0){
Up[k]=Ma[k];
}
Down[k]=Ma[k];
}
//----
return(0);
}
//+------------------------------------------------------------------+