Moneymanagement Tool as an indicator. How to get the information about the secondary currency? - page 2

 

You can try looking through the list of Window functions for a solution. https://docs.mql4.com/windows.

I do-not work much with graphical objects. When I do need text information on the screen, I usually comment them with line_breaks which places them in a column on the left side. Then I use objects to fill the back_ground so that the chart does-not clash with my text, like the green_box below.

You can also try shifting the chart some_more by using the triangle highlighted in the picture. You can then place all your information within the column on the Right_Side without conflicting with the chart.

 
That is a really good idea to place it on the left side. I will also do that! The only thing I don't like very much is the small Comment-Font. Is it possible to draw a some Label-Objects over the Object you fill the background with or do they cause conflicts?
 
mar: That is a really good idea to place it on the left side. I will also do that! The only thing I don't like very much is the small Comment-Font. Is it possible to draw a some Label-Objects over the Object you fill the background with or do they cause conflicts?

Yes. At one point I wanted to make the font_bigger but couldn't. I resulted to drawing object labels. The only problem I had at the time was the name conflict. What I mean is the chart has 2_layers, the foreground and the background. You cannot draw these objects on the background because your candles will mask them because candles are drawn on the foreground. When everything is on the foreground, the objects are drawn according to their name. ObjectNames starting with A are drawn before names starting with B and so-on. I do-not remember if A went on top of Z or vice-versa. Just keep that in mind.

So start the name of your background squares with something like ZZ_Background. If they're landing on top of your Text_Objects then name them something like AA_Background. I believe mines was ZZ_Background+i. The codes are buried somewhere in my archives and I'm too lazy to find it.

 
Haha, lazy guy! No problem, ubzen... Is is a very valueable information for me that they work in alphabetical order. Then I know how to fix an error if it occurs. Thanks a lot!
 

ubzen, there is something I don't understand. I wanted to make an indicator with three moving averages. SMA 20, 50, 100. When SMA20 > SMA50 and EMA50 > SMA 100, I want to print a blue histogram between SMA20 and SMA50. And the same the other way: when SMA20 < SMA 50 and SMA50 < SMA 100, the histogram between 20 and 50 should be red. The moving averages themselves are no problem. But I have a question about the histogram: I read here in the forum that I need two buffers for a histogram (upper and lower value). Right now I have 5 buffers: 3 for the SMAs and two for the histograms (blue and red). Do I need another two buffers for the histogram? I am confused because I already have the values for the histogram. It is SMA20 and SMA50. I am not sure how to go on now and how to draw the histogram. I just know that the histogram bars should be drawn between the SMA20 and SMA50 if the conditions are met. Maybe you can give me a tip how to go on?


EDIT: I tried a little bit and one histogram works! But not the other and I have no idea why... I also don't understand why I can remove the line "LongZoneLow[i] = SMA50[i];" completely and I still get the same results, although the lower value for the histogram would be missing then... questions over questions...?!?

This is what I have so far:

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Green
#property indicator_color2 Yellow
#property indicator_color3 Red
#property indicator_color4 Navy
#property indicator_color5 Navy
#property indicator_color6 Maroon
#property indicator_color7 Maroon

double SMA20[], SMA50[], SMA100[], LongZoneHigh[], LongZoneLow[], ShortZoneHigh[], ShortZoneLow[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0, SMA20);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(1, SMA50);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(2, SMA100);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(3, LongZoneHigh);
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 4);
   SetIndexBuffer(4, LongZoneLow);
   SetIndexStyle(4, DRAW_HISTOGRAM, STYLE_SOLID, 4);
   SetIndexBuffer(5, ShortZoneHigh);
   SetIndexStyle(5, DRAW_HISTOGRAM, STYLE_SOLID, 4);
   SetIndexBuffer(6, ShortZoneLow);
   SetIndexStyle(6, DRAW_HISTOGRAM, STYLE_SOLID, 4);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int 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=limit-1; i >= 0; i--)
   {
      SMA20[i] = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, i);
      SMA50[i] = iMA(NULL, 0, 50, 0, MODE_SMA, PRICE_CLOSE, i);
      SMA100[i] = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, i);
      if (SMA20[i] > SMA50[i] && SMA50[i] > SMA100[i])
      {
         LongZoneHigh[i] = SMA20[i];
         LongZoneLow[i] = SMA50[i];
      }
      if (SMA20[i] < SMA50[i] && SMA50[i] < SMA100[i])
      {
         ShortZoneHigh[i] = SMA50[i];
         ShortZoneLow[i] = SMA20[i];
      }
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
mar:

ubzen, there is something I don't understand. I wanted to make an indicator with three moving averages. SMA 20, 50, 100. When SMA20 > SMA50 and EMA50 > SMA 100, I want to print a blue histogram between SMA20 and SMA50. And the same the other way: when SMA20 < SMA 50 and SMA50 < SMA 100, the histogram between 20 and 50 should be red. The moving averages themselves are no problem. But I have a question about the histogram: I read here in the forum that I need two buffers for a histogram (upper and lower value). Right now I have 5 buffers: 3 for the SMAs and two for the histograms (blue and red). Do I need another two buffers for the histogram? I am confused because I already have the values for the histogram. It is SMA20 and SMA50. I am not sure how to go on now and how to draw the histogram. I just know that the histogram bars should be drawn between the SMA20 and SMA50 if the conditions are met. Maybe you can give me a tip how to go on?

This is what I have so far:


histogram on main chart ??

think this is nicer looking .... arrows on middle MA

3 MA

 
Hey deVries, definitely a nice idea! But I am learning to code right now and therefore I would like to know how to do it.
 
I am totally confused that there are only histograms between the SMA20 and the SMA100 and not between the SMA20 and the SMA50 like it should be... ?!?!
 
mar:
Hey deVries, definitely a nice idea! But I am learning to code right now and therefore I would like to know how to do it.

no arrow buffervalue will be .......
arrows on middle MA value == .......

.

if (SMA20[i] > SMA50[i] && SMA50[i] > SMA100[i]) fill buffer 4 color green

if (SMA20[i] < SMA50[i] && SMA50[i] < SMA100[i]) fill buffer 5 color red

 

Sorry, I don't get the point.. My questions are:

Why do I get a navy-colored buffer between SMA20 and SMA100 and not between SMA20 and SMA50? Why does the indicator use the SMA100 value as the lower line?

Why is there no maroon-colored buffer when SMA20 < SMA 50 and SMA 50 < SMA 100? It is exactly the same code but nothing happens...?!?

Reason: