Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 789

 
alexey1979621:
Hi all! Dear comrades, help with the following question. Standard indicator + MA indicator (only lowered to the basement). How to take the indications of MA indicator lowered into the basement? If we use a standard МА indicator, we apply a price from 0 to 6, but if we descend to the basement, we set "apply to" to 8. I suppose that we should change the MA indicator itself (but I don't know what to change there) and then use iCustom function.

I would be grateful for your help.


You take an array of the OSM indicator and ImaOnArray with all МА parameters.
 
solnce600:

Good people!!!

Help me find a bug.I'm learning about Arrays.

I created an array in a include file.

I put a reference to the include file in my Expert Advisor.

I can't understand why.

In the file location link error codes

http://clip2net.com/s/jkTd89

Thank you.

Maybe the problem is with the file name and path? Try to name the files in Latin characters and without dots.
 
solnce600:

Good people!!!

Help me find a bug.I'm learning about Arrays.

I created an array in a include file.

I put a reference to the include file in my Expert Advisor.

I can't understand why.

In the file location link error codes

http://clip2net.com/s/jkTd89

Thank you.

Suspicious path. ../Programm Files/... Actually all files should be in path like C:\Users\\***\AppData\Roaming\MetaQuotes\Terminal\******************\MQL4\Include
 
barabashkakvn:
Suspicious path. ../Programm Files/... Actually all files should be located in path like C:\Users\***\AppData\Roaming\MetaQuotes\Terminal\******************\MQL4\Include
You can actually run the terminal in the portable ;)
 
evillive:
You can actually run the terminal in portable ;)
You can use /Portable switch, but we are not telepaths, are we? And such a key is used by few people.
 

Can you please tell me how to make the indicator data display as candlesticks or just vertical bars like here:

It's not clearin the code itself how to do this! The DRAW_HISTOGRAM style just draws a vertical line on each bar from the bottom border of the window, but not a candlestick.

/// это начало ///

#property indicator_chart_window
#property indicator_buffers 6

#property  indicator_style1 STYLE_DOT
#property  indicator_width1 1
#property  indicator_color1 Sienna

#property  indicator_style2 STYLE_DOT
#property  indicator_width2 1
#property  indicator_color2 Sienna

#property  indicator_style3 STYLE_SOLID
#property  indicator_width3 2
#property  indicator_color3 DodgerBlue

#property  indicator_style4 STYLE_SOLID
#property  indicator_width4 2
#property  indicator_color4 DodgerBlue

#property  indicator_style5 STYLE_SOLID
#property  indicator_width5 1
#property  indicator_color5 DodgerBlue

#property  indicator_style6 STYLE_SOLID
#property  indicator_width6 1
#property  indicator_color6 DodgerBlue

/// это в процедуре OnInit() ///

   SetIndexBuffer(0, ForecastCloudHigh);
   SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, EMPTY, IndicatorCloudColor);
   SetIndexShift(0, ForecastBars - Offset);
   
   SetIndexBuffer(1, ForecastCloudLow);
   SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, EMPTY, IndicatorCloudColor);
   SetIndexShift(1, ForecastBars - Offset);
   
   SetIndexBuffer(2, ForecastBestPatternOpen);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, EMPTY, IndicatorBestPatternColor);
   SetIndexShift(2, ForecastBars - Offset);

   SetIndexBuffer(3, ForecastBestPatternClose);
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, EMPTY, IndicatorBestPatternColor);
   SetIndexShift(3, ForecastBars - Offset);

   SetIndexBuffer(4, ForecastBestPatternHigh);
   SetIndexStyle(4, DRAW_HISTOGRAM, STYLE_SOLID, EMPTY, IndicatorBestPatternColor);
   SetIndexShift(4, ForecastBars - Offset);
   
   SetIndexBuffer(5, ForecastBestPatternLow);
   SetIndexStyle(5, DRAW_HISTOGRAM, STYLE_SOLID, EMPTY, IndicatorBestPatternColor);
   SetIndexShift(5, ForecastBars - Offset);

/// а это уже заполнение в процедуре-обработчике ///

         ForecastBestPatternOpen[indexBar] = xcbase + ((iOpen(NULL, 0, altindex) - ycbase) * sAlt[0]);
         ForecastBestPatternClose[indexBar] = xcbase + ((iClose(NULL, 0, altindex) - ycbase) * sAlt[0]);
         ForecastBestPatternHigh[indexBar] = xcbase + ((iHigh(NULL, 0, altindex) - ycbase) * sAlt[0]);
         ForecastBestPatternLow[indexBar] = xcbase + ((iLow(NULL, 0, altindex) - ycbase) * sAlt[0]);
 
Awwl:

Can you tell me how to make the indicator data display as candlesticks or just vertical bars like here:

It's not clearin the code itself how to do this! The DRAW_HISTOGRAM style just draws a vertical line on each bar from the bottom border of the window, but not a candlestick.

The easiest way is to draw in mql5, using the drawing styleDRAW_CANDLES orDRAW_COLOR_CANDLES. Unfortunately, in mql4 you can't draw candlesticks just like that.
 
Awwl:

Can you tell me how to make the indicator data display as candlesticks or just vertical bars like here:

It's not clearin the code itself how to do this! The DRAW_HISTOGRAM style just draws a vertical line on each bar from the bottom border of the window, but not a candlestick.

If you figure out how the Heiken Ashi indicator (included with the terminal) works, you'll understand everything.
 
evillive:
If you understand how the Heiken Ashi indicator is set up (the terminal comes with it), you will understand everything.

The built-in Heiken Ashi looks a bit underdeveloped (I wonder if it's just me on the 745?), but it's clear how it works. And it is unclear how WmiFor is built!

In the Heiken Ashi code a candle is drawn from 4 bar histograms:

#property indicator_separate_window
#property indicator_buffers 4
#property  indicator_color1 Red
#property  indicator_color2 White
#property  indicator_color3 Red
#property  indicator_color4 White
#property  indicator_width1 1
#property  indicator_width2 1
#property  indicator_width3 3
#property  indicator_width4 3

//---
input color ExtColor1 = Red;    // Shadow of bear candlestick
input color ExtColor2 = White;  // Shadow of bull candlestick
input color ExtColor3 = Red;    // Bear candlestick body
input color ExtColor4 = White;  // Bull candlestick body
//--- buffers
double ExtLowHighBuffer[];
double ExtHighLowBuffer[];
double ExtOpenBuffer[];
double ExtCloseBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
void OnInit(void)
  {
   IndicatorShortName("Heiken Ashi");
   IndicatorDigits(Digits);
//--- indicator lines
   SetIndexStyle(0,DRAW_HISTOGRAM,0,1,ExtColor1);
   SetIndexBuffer(0,ExtLowHighBuffer);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,1,ExtColor2);
   SetIndexBuffer(1,ExtHighLowBuffer);
   SetIndexStyle(2,DRAW_HISTOGRAM,0,3,ExtColor3);
   SetIndexBuffer(2,ExtOpenBuffer);
   SetIndexStyle(3,DRAW_HISTOGRAM,0,3,ExtColor4);
   SetIndexBuffer(3,ExtCloseBuffer);
//---
   SetIndexLabel(0,"Low/High");
   SetIndexLabel(1,"High/Low");
   SetIndexLabel(2,"Open");
   SetIndexLabel(3,"Close");
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtLowHighBuffer);
   SetIndexBuffer(1,ExtHighLowBuffer);
   SetIndexBuffer(2,ExtOpenBuffer);
   SetIndexBuffer(3,ExtCloseBuffer);
//--- initialization done
  }

That is, as the buffer number increases (from 0 to 3), new bars are drawn on top of the old ones. The order is as follows:

LowHigh - HighLow - Open - Close.

The order of candlesticks should be the following for them to look as they should be, with their bodies and tails:

max(Open,Close)//thick colour line// - min(Open,Close)//thick white// - High//thick colour line// - Low//thick white//.

Let's compile the indicator, put it on the chart, and see all the problems (see picture).

But this method, like Heiken Ashi, has a disadvantage - under each "candle" we get a white loop in the background colour that covers everything lower. But with WmiFor everything is perfect! Undocumented features?

First picture - Heiken Ashi (placed in a separate window), second picture - WmiFor, background is in light green for clarity.

 
Forexman77:

The question has not been dismissed. So, first of all.

A maximum is found, then a line is plotted against it. The distance between this maximum line and the current minimum is checked. If it exceeds "Rmax", an arrow is set on the bar where the maximum is found. The arrow is placed but not there. To make it clear, I added the buffer "BufferLow[i]" that shows the difference and its data can be seen in the explorer window.

That's the way it always is. You can't wait for snow in winter) I did it myself.

If anyone was tormented by such a similar idea, here's the code:

#property copyright "Kamil Gazizullin"
#property link      "forexman77@yandex.ru"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 5
#property  indicator_color1 Magenta
#property  indicator_color2 Aqua
#property  indicator_color3 SlateBlue
#property  indicator_color4 SlateBlue
#property  indicator_color5 clrNONE
//--- input parameters
extern int       Period_=10;
extern double diapazon  =0.003;
//--- buffers
double Max[];
double Min[];
double MaxIndex[];
double MinIndex[];
double rAZNOST[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(5);
   SetIndexBuffer(0,MaxIndex);
   SetIndexBuffer(1,MinIndex);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,116);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,116);
   SetIndexEmptyValue(0,0.0);
   SetIndexBuffer(2,Max);
   SetIndexBuffer(3,Min);
   SetIndexBuffer(4,rAZNOST);
   IndicatorDigits(Digits+1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int counted_bars=IndicatorCounted(),limit, i,k,r,p,t,f;
    double minimum,maximum,Dmax,Dmin;
   if(counted_bars>0)
      counted_bars--;  
   limit=Bars-counted_bars;
   for(i=0;i<limit;i++)
   {
      maximum=High[iHighest(NULL,0,MODE_HIGH,Period_,i)];
      minimum=Low[iLowest(NULL,0,MODE_LOW,Period_,i)];
      Max[i]=maximum;
      Min[i]=minimum;
   }
   for(i=0;i<limit;i++)
   {
      k=iHighest(NULL,0,MODE_HIGH,Period_,i);
      t=iLowest(NULL,0,MODE_LOW,Period_,i);
      Dmax=Max[i]-Low[i];
      Dmin=High[i]-Min[i];
      if (Dmax > diapazon){p=k;for(r=p;r>=k;r--)MaxIndex[k]=Max[k];}
      if (Dmin > diapazon){p=t;for(f=p;f>=t;f--)MinIndex[t]=Min[t];}
      if (MaxIndex[i]==Max[i+1])MaxIndex[i]=0;
      if (MinIndex[i]==Min[i+1])MinIndex[i]=0;
      rAZNOST[i]=Max[i]-Min[i];
   }
   return(0);
  }