Download MetaTrader 5

trix modified mq5 code

To add comments, please log in or register
Searching on MQL5.community is performed in all sections. Try it!
blnt06
14
blnt06 2013.02.27 10:46 

I do not know english.
I turned to Google translate.

MQ4 and mq5 codes I'm looking for an indicator in TradeInterceptor platform.

TradeInterceptor indicator attached. Name trix.

Up trend separate color.
Different color downward trend.

MQ4 and share the mq5 who know this code I would appreciate it.

 

 

 

Trix MQ4 code that you have a link from. But this is not a complete indicator of trix. I found it in the internet trix add MQ4 code.
But I do not have different colors when I train up and down the train.
Trix green line in this code up on the train. trix can add a line of code would be very happy down the red Tran.
Signal line upward trend in the green. The signal can be added to the red trend line down.  

Files:
Trix.png 128 kb
trix00.png 50 kb
TRIX.mq4 4 kb
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.02.27 22:15  
blnt06:

I do not know english.
I turned to Google translate.

MQ4 and mq5 codes I'm looking for an indicator in TradeInterceptor platform.

TradeInterceptor indicator attached. Name trix.

Up trend separate color.
Different color downward trend.

MQ4 and share the mq5 who know this code I would appreciate it.

 

Post your Job here:  MT4 & MT5 coding jobs 
phi nuts
2184
phi nuts 2013.02.28 05:24  
blnt06:

I do not know english.
I turned to Google translate.

MQ4 and mq5 codes I'm looking for an indicator in TradeInterceptor platform.

TradeInterceptor indicator attached. Name trix.

Up trend separate color.
Different color downward trend.

MQ4 and share the mq5 who know this code I would appreciate it.

Trix MQ4 code that you have a link from. But this is not a complete indicator of trix. I found it in the internet trix add MQ4 code.
But I do not have different colors when I train up and down the train.
Trix green line in this code up on the train. trix can add a line of code would be very happy down the red Tran.
Signal line upward trend in the green. The signal can be added to the red trend line down.  

Since you already know about trix in here, you can modified that code to meet your need.
blnt06
14
blnt06 2013.03.01 10:58  

trix me to train up a separate color.
I need a different color downward trend.
Code share the knowledge here, I'd appreciate it.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Gann Objects
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Gann Objects
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Gann Objects - Documentation on MQL5
phi nuts
2184
phi nuts 2013.03.04 11:26  
blnt06:

trix me to train up a separate color.
I need a different color downward trend.
Code share the knowledge here, I'd appreciate it.

There are plenty of unused variable and function in that code base, which actually  ... totally useless, but I won't comment on that in here.

Open MT5 and open it's MetaEditor by pressing F4. On MetaEditor, click "File" and click "Open Data Folder" and find MQL/indicator folder. Copy trix from code base and paste trix in indicator folder. Then open trix in MetaEditor by double clicking it.

Do this in MetaEditor :

1. Find this 4

#property indicator_type1   DRAW_LINE       
#property indicator_color1  Red

#property indicator_type2   DRAW_LINE
#property indicator_color2  Blue

And change it into

#property indicator_type1   DRAW_COLOR_LINE       
#property indicator_color1  clrWhite, clrBlue, clrRed

#property indicator_type2   DRAW_COLOR_LINE
#property indicator_color2  clrYellow, clrLime, clrLightBlue

2. Find this

//--- indicator buffers
double TriX1[],     // Dynamic array to hold the values of Trix
EXT_TriX1[],
TriX2[],            // Dynamic array to hold the values of Trix
EXT_TriX2[],
TriX3[],            // Dynamic array to hold the values of Trix Calculations
EXT_TriX3[],
TriX4[],            // Dynamic array to hold the values of Trix Calculations
EXT_TriX4[];

and change it into this

//--- indicator buffers
double TriX1[],     // Dynamic array to hold the values of Trix
TriX2[],            // Dynamic array to hold the values of Trix
TriX3[],            // Dynamic array to hold the values of Trix Calculations
TriX4[];            // Dynamic array to hold the values of Trix Calculations

We don't need all of those EXT_TriX :(

3. Find this, and change the value 1 into 2 and value 2 into 1, can you do that ?

   SetIndexBuffer(2,TriX2,INDICATOR_DATA);
   SetIndexBuffer(1,TriX3,INDICATOR_COLOR_INDEX);

 4. Find these, and delete them all, they are useless

   ArraySetAsSeries(TriX1,true);  // index Trix1 array as a time series
   ArraySetAsSeries(TriX2,true);  // index Trix1 array as a time series
   ArraySetAsSeries(TriX3,true);  // index Trix1 array as a time series
   ArraySetAsSeries(TriX4,true);  // index Trix1 array as a time series

   ArrayInitialize(TriX3,EMPTY_VALUE);    // Create Calculation Array As Value Zero
   ArrayInitialize(TriX4,EMPTY_VALUE);    // Create Calculation Array As Value Zero

5.  Find this, and add code below, between them

   (CopyBuffer(TriXHandle1,0,0,to_copy,TriX3));
   (CopyBuffer(TriXHandle2,0,0,to_copy,TriX4));
   //<<-- add code in here
//------------------------------------------------------------+
// Trix Gauge 1                                               +
//------------------------------------------------------------+

This is the code to add

   int limit;
   if (prev_calculated == 0)
       limit = prev_calculated + MathMax(Plot1, Plot2) + 1;
      else
       limit = prev_calculated - 1;

   for ( i = limit; i < rates_total; i++)
      {
      //--- now set line color for every bar
         if (TriX1 [i-1] == TriX1 [i])
            TriX3[i] = 0;
            else
            if (TriX1 [i-1] < TriX1 [i])
               TriX3[i] = 1;
               else
               TriX3[i] = 2;
               
      //--- now set line color for every bar
         if (TriX2 [i-1] == TriX2 [i])
            TriX4[i] = 0;
            else
            if (TriX2 [i-1] < TriX2 [i])
               TriX4[i] = 1;
               else
               TriX4[i] = 2;      
      }

 

6. Press F7 to compile and you may have some warning but you should not have an error if you doing it right, then try it in your MT5

 

 

blnt06
14
blnt06 2013.03.08 07:32  
I have not edit this code on your suggestions.

//+------------------------------------------------------------------+
//|                                                         TRIX.mq4 |
//|                                                                  |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

#property link "http://www.metaquotes.net"
//---- indicator settings
#property indicator_separate_window 
#property indicator_buffers 2       
#property indicator_color1 Lime
#property indicator_color2 Red

//---- input parameters
extern int Periodo = 30;
extern int Signal = 20 ;
//extern int Desplazar = 1;
//---- buffers 
double TRIX_Buffer[];
double Signal_Buffer[];
double EMA1_buffer[];
double EMA2_buffer[];
double EMA3_buffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 3 additional buffers are used for counting.
IndicatorBuffers(5);
SetIndexBuffer(2,EMA1_buffer);
SetIndexBuffer(3,EMA2_buffer);
SetIndexBuffer(4,EMA3_buffer);

//---- indicators - drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,TRIX_Buffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(1,Signal);
SetIndexBuffer(1,Signal_Buffer);


//---- name for DataWindow and indicator subwindow label
IndicatorShortName("TRIX("+Periodo+","+Signal+")");
SetIndexLabel(0,"Trix");
SetIndexLabel(1,"Signal");

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- 

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i,limit;
int counted_bars=IndicatorCounted(); // IndicatorCounted 

//---- check for possible errors
if(counted_bars<0) return(-1);

if(Bars<=Periodo) return(0); 
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=Periodo;i++) TRIX_Buffer[Bars-i]=0.0;
for(i=1;i<=Periodo;i++) Signal_Buffer[Bars-i]=0.0;
for(i=1;i<=Periodo;i++) EMA1_buffer[Bars-i]=0.0;
for(i=1;i<=Periodo;i++) EMA2_buffer[Bars-i]=0.0;
for(i=1;i<=Periodo;i++) EMA3_buffer[Bars-i]=0.0;
}

if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

for(i=0; i<limit; i++)
EMA1_buffer[i]=iMA(NULL,0,Periodo,0,MODE_EMA,PRICE_CLOSE,i);
for(i=0; i<limit; i++)
EMA2_buffer[i]=iMAOnArray(EMA1_buffer,Bars,Periodo,0,MODE_EMA,i);
for(i=0; i<limit; i++)
EMA3_buffer[i]=iMAOnArray(EMA2_buffer,Bars,Periodo,0,MODE_EMA,i);

for(i=0; i<limit-1; i++)
TRIX_Buffer[i] = (EMA3_buffer[i] - EMA3_buffer[i+1]) / EMA3_buffer[i+1] *100;

for(i=0; i<limit-1; i++)
Signal_Buffer[i]=iMAOnArray(TRIX_Buffer,Bars,Signal,0,MODE_SMA,i);

//---- done
return(0);
}
//+------------------------------------------------------------------+
blnt06
14
blnt06 2013.03.08 07:33  

Hello dear phi.nuts;
First of all, thank you very much for your efforts.
I'm working for two days, but I want to mq5 trix trix codes MQ4 and I could not.
If you bother to make MQ4 and mq5 codes Is it possible to add here?
Thank you very much.

To add comments, please log in or register