How create bar or candle in subwindow ?? - page 2

 

Hello ;

I want just to have something like this : the picture in down

so we don't draw the histogram from zero line

 

As anyone have an idea !!

I would like just to draw or to create a bar between the 2 lines ??

I try to do this, in order to draw ome bar between 2 moving average :

#property indicator_separate_window
//#property indicator_minimum 1
//#property indicator_maximum 10
 
bool initFinished=false;
// adding a variable that will remember the initialization state.
// false - there was no initialization
// true - there was initialization
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   ObjectsDeleteAll();
   // deleting all objects
   
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{

  int    counted_bars=IndicatorCounted();
  int limit ;
  string nomligne ;
  
   if(counted_bars>0) counted_bars--;
      limit=Bars-counted_bars;
  
   if(initFinished==false)
   {
      IndicatorShortName("NiceLine");
 
      int windowIndex=WindowFind("NiceLine");
   
      if(windowIndex<0)
      {
         // if the subwindow number is -1, there is an error
         Print("Can\'t find window");
         return(0);
      }  
      
      
        for(int i = 0; i <limit; i++)
     {
     
       nomligne = StringConcatenate("ligne",i);
 
      ObjectCreate(nomligne,OBJ_TREND,windowIndex,Time[i],iMA(NULL,0,19,0,MODE_EMA,PRICE_CLOSE,i),Time[i],iMA(NULL,0,26,0,MODE_EMA,PRICE_CLOSE,i));
      // drawing a line in the indicator subwindow
              
      ObjectSet(nomligne,OBJPROP_COLOR,GreenYellow);
      ObjectSet(nomligne,OBJPROP_WIDTH,3);
 
      WindowRedraw();      
      // redraw the window to see the line   
      
      }
      
      initFinished=true;
      // drawing is finished
   }
   
   return(0);
}

but I don't understand why the result is like an horizontal line

 

here is a best example :

https://www.mql5.com/en/code/10070

remark the way that she draw the MACD Ichimoku with color blue and red !!

may be we must use the function

SetIndexDrawBegin

 

Yep, it uses Histogram . . .

SetIndexStyle(2,DRAW_HISTOGRAM,CL_Style);
   SetIndexBuffer(2,SpanA_Buffer);
   SetIndexDrawBegin(2,Kijun+a_begin-1);
   SetIndexShift(2,Kijun);
   SetIndexLabel(2,NULL);
 

need to adjust the scale and add OBJPROP_RAY=false

#property indicator_separate_window
#property indicator_minimum -0.003
#property indicator_maximum  0.003
 
extern int FastEMA   = 12,
           SlowEMA   = 26,
           SignalSMA = 9;

bool initFinished=false;
// adding a variable that will remember the initialization state.
// false - there was no initialization
// true - there was initialization
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   ObjectsDeleteAll();
   // deleting all objects
   
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{

  int    counted_bars=IndicatorCounted();
  int limit ;
  string nomligne ;
  
   if(counted_bars>0) counted_bars--;
      limit=Bars-counted_bars;
  
   if(initFinished==false)
   {
      IndicatorShortName("NiceLine");
 
      int windowIndex=WindowFind("NiceLine");
   
      if(windowIndex<0)
      {
         // if the subwindow number is -1, there is an error
         Print("Can\'t find window");
         return(0);
      }  
      
      
        for(int i=0; i<limit; i++)
     {
     
       nomligne = StringConcatenate("ligne",i);
 
      ObjectCreate(nomligne,OBJ_TREND,windowIndex,Time[i],iMACD(NULL,0,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,i),
                                                  Time[i],iMACD(NULL,0,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,i));
      // drawing a line in the indicator subwindow
              
      ObjectSet(nomligne,OBJPROP_RAY,false);
      ObjectSet(nomligne,OBJPROP_COLOR,GreenYellow);
      ObjectSet(nomligne,OBJPROP_WIDTH,3);
 
      WindowRedraw();      
      // redraw the window to see the line   
      
      }
      
      initFinished=true;
      // drawing is finished
   }
   
   return(0);
}
 
ludo31:

here is a best example :

https://www.mql5.com/en/code/10070

remark the way that she draw the MACD Ichimoku with color blue and red !!

may be we must use the function

SetIndexDrawBegin

Nope . . . you want something like this ?

 
RaptorUK:

Nope . . . you want something like this ?


Yes, like that !!

how do you do for that ??

is there an exemple for the code ??

thanks

 

I used 2 sets of 2 buffers, one for red one for blue, both DRAW_HISTOGRAM . . . the problem with the histogram being drawn from the bottom of the screen cannot be overcome, as far as I can see . . it only seems to happen when the Indicator is drawing to a separate window . . to work round the problem I used the same technique as used in the example you provided, https://www.mql5.com/en/code/10070, and that uses another buffer to colour over the part of the histogram that runs from the bottom of the screen to the lower of the 2 values that make up each histogram bar.

All the information you need is in this thread . . you need to learn how to find it . . .

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