Some mql4 coding problems - page 2

 

Raptor

i know u r acting ignorant & funny!

so u dont use technical indicator?..thts funny! i bliv no one lose by sharing!..well if u dont want to share atleast express ur coding style` correcting th codes posted?..i ll appreciate tht!..there r thousands n thousands of indicator on the webn if u google it u ll find it~..th Qs is all this indicator r hidden behin a MQL4 language n its not easy for a beginner~hopd u undertsand..can u show th algorithm of 3color indi..i ll appreciate it Tnx

 
//+------------------------------------------------------------------+
//|                                                 Hello World2.mq4 |
//|                                             original  heelflip43 |
//|                                                                  |
//+------------------------------------------------------------------+
#property link      ""
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
/*
The main function which you need have before it can compile is start().
When viewing this in the MetaEditor, have a read of the help file in the toolbox.
*/
int init()
  {
//---- 
Print("init() Hello World");
Alert("This works as well. Hello World");
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);      
   PlaySound("ok.wav"); // This can only be in terminal_dir\sounds directory or subdirectories
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Print("deinit() Hello World");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   Print("start() Hello World");
   int counted_bars=IndicatorCounted();
   if (counted_bars < 0) return(-1);
   if (counted_bars < 100)   counted_bars = 100;
for (int pos = Bars-1; pos >= 0; pos--){
//--- buffers
ExtMapBuffer1[pos]=iClose(NULL/*Or Symbol()*/,0,pos);
ExtMapBuffer2[pos]=EMPTY_VALUE;
ExtMapBuffer3[pos]=EMPTY_VALUE;

if(ExtMapBuffer1[pos+1] > ExtMapBuffer1[pos])
     {
      ExtMapBuffer2[pos+1]=ExtMapBuffer1[pos+1];
      ExtMapBuffer2[pos]=ExtMapBuffer1[pos];
     }
if(ExtMapBuffer1[pos+1] < ExtMapBuffer1[pos])     
     {
      ExtMapBuffer3[pos+1]=ExtMapBuffer1[pos+1];
      ExtMapBuffer3[pos]=ExtMapBuffer1[pos];
     }     
      
}
//----
   return(0);
  }
//+------------------------------------------------------------------+

If dn    5 > 4  red line     buffer2[5] value        buffer2[4]value    to get line between two points 

if up    5 < 4  green line       buffer3[5] value  buffer3[4]value      to get line between two points 

if 5>4  then 4 < 3     3 >2   then we get situation both buffer at 3 and 4 have value line get color last buffer 

 
MirTD:

Raptor

i know u r acting ignorant & funny!

so u dont use technical indicator?..thts funny! i bliv no one lose by sharing!..well if u dont want to share atleast express ur coding style` correcting th codes posted?..i ll appreciate tht!..there r thousands n thousands of indicator on the webn if u google it u ll find it~..th Qs is all this indicator r hidden behin a MQL4 language n its not easy for a beginner~hopd u undertsand..can u show th algorithm of 3color indi..i ll appreciate it Tnx

I was being very, very serious. I don't use Technical Indicators and I have never written one from scratch.  I have already explained how I would go about having a multi coloured line,  if you want me to write the code for you then you need to wait for me to have time to do it,  probably end of next year,  if that's OK ?
 
Instead of
if(ExtMapBuffer1[pos+1] < ExtMapBuffer1[pos])     
     {
      ExtMapBuffer3[pos+1]=ExtMapBuffer1[pos+1];
      ExtMapBuffer3[pos]=ExtMapBuffer1[pos];
     }     
      
Try
if(ExtMapBuffer1[pos+1] < ExtMapBuffer1[pos])     // New high?
     {
      ExtMapBuffer3[pos]=ExtMapBuffer1[pos];      // Show it.
      if (ExtMapBuffer3[pos+1] == EMPTY_VALUE)    // Change of direction.
         ExtMapBuffer2[pos] = ExtMapBuffer3[pos]; // Join the lines.
     }     
      
 

deVries 

this works as well Hello World INDEED! many tnx n God bless u! i hav not go thru th logic of the code,i ll later but it works!(copy n paste)easy n the only way for beginner!WHRoeder,i ll try the variation n see,tnx.

Raptor,u r simply difficult ;) 

 

deVries

i think th code u shw up here is special..ofcourse u may hv knwn..i like ur 'simple' code..though i do nt till now studied al the logics of ur code bt i think we r on same observational wavelenth~(simplicity is best n desirable by any1 who has xperince analysis paralysi~)..ppl say trend is a friend..rite,no doubt but observation is the best friend!..this is a good trend following system! n its not very lagging if one can provided th filter..i hv developed 4-5 indi of this shorts in othr prog lang n used in combo n its powerful~i tell u this is quite reliable..bt learnin neva stops in forex or any othr fin instru ..wht is ur take on this? ..tnx

 
//+------------------------------------------------------------------+
//|                                                 Hello World2.mq4 |
//|                                             original  heelflip43 |
//|                                                                  |
//+------------------------------------------------------------------+
#property link      ""
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_color3 Green
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
/*
The main function which you need have before it can compile is start().
When viewing this in the MetaEditor, have a read of the help file in the toolbox.
*/
int init()
  {
//---- 
Print("init() Hello World");
Alert("This works as well. Hello World");
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);      
   PlaySound("ok.wav"); // This can only be in terminal_dir\sounds directory or subdirectories
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Print("deinit() Hello World");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   Print("start() Hello World");
   int counted_bars=IndicatorCounted();
   if (counted_bars < 0) return(-1);
   if (counted_bars < 100)   counted_bars = 100;
for (int pos = Bars-1; pos >= 0; pos--){
//--- buffers
ExtMapBuffer1[pos]=iMA(NULL,0,6,0,MODE_EMA,PRICE_CLOSE,pos);
ExtMapBuffer2[pos]=EMPTY_VALUE;
ExtMapBuffer3[pos]=EMPTY_VALUE;

if(ExtMapBuffer1[pos] > ExtMapBuffer1[pos+1])
     {
      ExtMapBuffer3[pos+1]=ExtMapBuffer1[pos+1];
      ExtMapBuffer3[pos]=ExtMapBuffer1[pos];
     }
if(ExtMapBuffer1[pos] < ExtMapBuffer1[pos+1])     
     {
      ExtMapBuffer2[pos+1]=ExtMapBuffer1[pos+1];
      ExtMapBuffer2[pos]=ExtMapBuffer1[pos];
     }     
      
}
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

deVries

small rewrite to ur 'simple' but 'Brilliant logic' code using the EMA6 n changin th pos index with emphasis on NOW...it lloks beautiful on Daily EURUSD chart..the stuff every trend following technical theory taught as basics~ simple yet effective..ur assistance is timely n i m thinkin to use it as th base logic of 3color indi based on more complicated conditions..also,i think thers some small glitch in th logic though..lemme examine more n point out later..the solution may b in those codlet by WHRoeder,i dont knw til now!

 
MirTD: small rewrite to ur 'simple' but 'Brilliant logic' code using the EMA6 n changin th pos index with emphasis on NOW...it lloks beautiful on Daily EURUSD chart..the stuff every trend following technical theory taught as basics~ simple yet effective..ur assistance is timely n i m thinkin to use it as th base logic of 3color indi based on more complicated conditions..also,i think thers some small glitch in th logic though..lemme examine more n point out later..the solution may b in those codlet by WHRoeder,i dont knw til now!

Write English. Capitalize. No run on sentences. No phone speak - you have a full key board in front of you and no text limit.

I saw that and stopped reading. You want help write English. I'm certainly not going to use any effort trying decipher that.

 
MirTD:

deVries

small rewrite to ur 'simple' but 'Brilliant logic' code using the EMA6 n changin th pos index with emphasis on NOW...it lloks beautiful on Daily EURUSD chart..the stuff every trend following technical theory taught as basics~ simple yet effective..ur assistance is timely n i m thinkin to use it as th base logic of 3color indi based on more complicated conditions..also,i think thers some small glitch in th logic though..lemme examine more n point out later..the solution may b in those codlet by WHRoeder,i dont knw til now!


There is also the possibillity to make a dotted line (arrows)  you can give with each bar every dot the color and width you want

Sometimes this will give a cleaner look to the situation on the chart then a closed line between bars 

https://www.mql5.com/en/forum/102390