Volume indicator with division in buy and sell

robertomargot

Trader
Sep 4, 2019
11
0
17
53
Hey guys,

Could anyone help to modify this indicator? I would like it to display the buy and sell volume side by side on each candle, similar to the attached figure.
As it stands, it overlaps buy and sell.

I would be happy if someone could help me with this, but if someone also adds the real volume, it would be great.

Thank you very much!

MQL4:
//+------------------------------------------------------------------+
//|                                          TicksSeparateVolume.mq4 |
//|                                   //|  http://www.metaquotes.net |
//+------------------------------------------------------------------+
//-----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_minimum 0
 
#property indicator_color1 SteelBlue
#property indicator_color2 Red
 
double UpTicks[];
double DownTicks[];
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorShortName("TicksVolume("+Symbol()+")");
 
   SetIndexBuffer(0,UpTicks);
   SetIndexBuffer(1,DownTicks);
 
   SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
 
   SetIndexLabel(0,"UpTicks");
   SetIndexLabel(1,"DownTicks");
 
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
 
   ObjectDelete("UpTicks1");
   ObjectDelete("DownTicks1");
   ObjectDelete("UpTicks2");
   ObjectDelete("DownTicks2");
 
  Comment("");
 
  return(0);
  }
//+------------------------------------------------------------------+
//| Ticks Volume Indicator                                           |
//+------------------------------------------------------------------+
int start()
  {
 
   ObjectDelete("UpTicks1");
   ObjectDelete("DownTicks1");
   ObjectDelete("UpTicks2");
   ObjectDelete("DownTicks2");
 
   int i,counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
 
 
//----
   for(i=0; i<limit; i++)
     {
      UpTicks[i]=(Volume[i]+(Close[i]-Open[i])/Point)/2;
      DownTicks[i]=Volume[i]-UpTicks[i];
     }
 
string BV="BUY VOLUME : "+DoubleToStr(UpTicks[0],0)+"";
string SV="SELL VOLUME: "+DoubleToStr(DownTicks[0],0)+"";
 
 
   ObjectCreate("UpTicks2", OBJ_LABEL, WindowFind("TicksVolume("+Symbol()+")"), 0, 0);
   ObjectSetText("UpTicks2",StringSubstr((BV),0), 15, "Tahoma Bold" ,White);
   ObjectSet("UpTicks2", OBJPROP_CORNER, 0);
   ObjectSet("UpTicks2", OBJPROP_XDISTANCE, 5);
   ObjectSet("UpTicks2", OBJPROP_YDISTANCE, 15);
 
   ObjectCreate("DownTicks2", OBJ_LABEL, WindowFind("TicksVolume("+Symbol()+")"), 0, 0);
   ObjectSetText("DownTicks2",StringSubstr((SV),0), 15, "Tahoma Bold" ,White);
   ObjectSet("DownTicks2", OBJPROP_CORNER, 0);
   ObjectSet("DownTicks2", OBJPROP_XDISTANCE, 5);
   ObjectSet("DownTicks2", OBJPROP_YDISTANCE, 35);
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

Attachments

Last edited by a moderator:

Enivid

Administrator
Staff member
Nov 30, 2008
16,550
922
144
Odessa
www.earnforex.com
This is a very weird way of calculating buy volume:
MQL4:
(Volume[i]+(Close[i]-Open[i])/Point)/2;

As for displaying two histogram bars for each candlestick - that's not possible in MT4 using standard indicator outputs. Perhaps, this could be accomplished using chart objects, but this isn't anything trivial.
 

WUJIE

Newbie
Dec 3, 2021
2
0
1
36
大家好,

有没有可以吗?我希望它在每根蜡烛上并排显示出交易量,无影无踪。
就当前,同时又重叠交换。

如果有人能帮我解决这个问题,我会很高兴的,但如果有人还添加了适合我的问题,就一起完成。

非常感谢!

[代码=mql4]
//+-------------------------------------------------------- --------- --------- --------- -----------+
//| TicksSeparateVolume.mq4 |
//| //| http://www.metaquotes.net |
//+-------------------------------------------------------- --------- --------- --------- -----------+
//-----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_minimum 0

#property indicator_color1 SteelBlue
#property indicator_color2 红色

双UpTicks[];
自己下滴答[];

//+-------------------------------------------------------- --------- --------- --------- -----------+
//| 自定义指标初始化函数 |
//+-------------------------------------------------------- --------- --------- --------- -----------+
内部初始化()
{
IndicatorShortName("TicksVolume("+Symbol()+")");

SetIndexBuffer(0,UpTicks);
SetIndexBuffer(1,DownTicks);

SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
SetIndexStyle(1,DRAW_HISTOGRAM,0,2);

SetIndexLabel(0,"UpTicks");
SetIndexLabel(1,"DownTicks");

返回(0);
}
//+-------------------------------------------------------- --------- --------- --------- -----------+
//| 自定义指标去初始化功能|
//+-------------------------------------------------------- --------- --------- --------- -----------+
int deinit()
{

ObjectDelete("UpTicks1");
ObjectDelete("DownTicks1");
ObjectDelete("UpTicks2");
ObjectDelete("DownTicks2");

评论(””);

返回(0);
}
//+-------------------------------------------------------- --------- --------- --------- -----------+
//| 滴答交易量指标|
//+-------------------------------------------------------- --------- --------- --------- -----------+
可能开始()
{

ObjectDelete("UpTicks1");
ObjectDelete("DownTicks1");
ObjectDelete("UpTicks2");
ObjectDelete("DownTicks2");

int i,counted_bars=IndicatorCounted();
//---- 确认可能的错误
if(counted_bars<0) return(-1);
//---- 最终计数的柱线将被重计数
if(counted_bars>0) counted_bars--;
int limit=条形计数法
_酒吧;





//----

for(i=0; i<limit; i++)

{

涨价=(
成交+(盘量-开盘)/点)/2;
DownTicks = 成交量-UpTicks ;
}


string BV="买入量:"+DoubleToStr(UpTicks[0],0)+"";
string SV="压缩量:"+DoubleToStr(DownTicks[0],0)+"";



ObjectCreate("UpTicks2", OBJ_LABEL, WindowFind("TicksVolume("+Symbol()+")"), 0, 0);
ObjectSetText("UpTicks2",StringSubstr((BV),0), 15, "Tahoma Bold",White);
ObjectSet("UpTicks2", OBJPROP_CORNER, 0);
ObjectSet("UpTicks2", OBJPROP_XDISTANCE, 5);
ObjectSet("UpTicks2", OBJPROP_YDISTANCE, 15);

ObjectCreate("DownTicks2", OBJ_LABEL, WindowFind("TicksVolume("+Symbol()+")"), 0, 0);
ObjectSetText("DownTicks2",StringSubstr((SV),0), 15, "Tahoma Bold" ,White);
ObjectSet("DownTicks2", OBJPROP_CORNER, 0);
ObjectSet("DownTicks2", OBJPROP_XDISTANCE, 5);
ObjectSet("DownTicks2", OBJPROP_YDISTANCE, 35);

//----
返回(0);
}
//+-------------------------------------------------------- --------- --------- --------- -----------+
[/代码]

Hey guys,

Could anyone help to modify this indicator? I would like it to display the buy and sell volume side by side on each candle, similar to the attached figure.
As it stands, it overlaps buy and sell.

I would be happy if someone could help me with this, but if someone also adds the real volume, it would be great.

Thank you very much!

MQL4:
//+------------------------------------------------------------------+
//|                                          TicksSeparateVolume.mq4 |
//|                                   //|  http://www.metaquotes.net |
//+------------------------------------------------------------------+
//-----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_minimum 0
 
#property indicator_color1 SteelBlue
#property indicator_color2 Red
 
double UpTicks[];
double DownTicks[];
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorShortName("TicksVolume("+Symbol()+")");
 
   SetIndexBuffer(0,UpTicks);
   SetIndexBuffer(1,DownTicks);
 
   SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
 
   SetIndexLabel(0,"UpTicks");
   SetIndexLabel(1,"DownTicks");
 
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
 
   ObjectDelete("UpTicks1");
   ObjectDelete("DownTicks1");
   ObjectDelete("UpTicks2");
   ObjectDelete("DownTicks2");
 
  Comment("");
 
  return(0);
  }
//+------------------------------------------------------------------+
//| 滴答交易量指标 |
//+-------------------------------------------------------- -------------------+
整数开始()
  {
 
   ObjectDelete("UpTicks1");
   ObjectDelete("DownTicks1");
   ObjectDelete("UpTicks2");
   ObjectDelete("DownTicks2");
 
   int i,counted_bars=IndicatorCounted();
//---- 检查可能的错误
   if(counted_bars<0) return(-1);
//---- 最后计数的柱线将被重新计数
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
 
 
//----
   for(i=0; i<limit; i++)
     {
      UpTicks[i]=(Volume[i]+(Close[i]-Open[i])/Point)/2;
      DownTicks[i]=Volume[i]-UpTicks[i];
     }
 
string BV="买入量:"+DoubleToStr(UpTicks[0],0)+"";
string SV="卖出量:"+DoubleToStr(DownTicks[0],0)+"";
 
 
   ObjectCreate("UpTicks2", OBJ_LABEL, WindowFind("TicksVolume("+Symbol()+")"), 0, 0);
   ObjectSetText("UpTicks2",StringSubstr((BV),0), 15, "Tahoma Bold",White);
   ObjectSet("UpTicks2", OBJPROP_CORNER, 0);
   ObjectSet("UpTicks2", OBJPROP_XDISTANCE, 5);
   ObjectSet("UpTicks2", OBJPROP_YDISTANCE, 15);
 
   ObjectCreate("DownTicks2", OBJ_LABEL, WindowFind("TicksVolume("+Symbol()+")"), 0, 0);
   ObjectSetText("DownTicks2",StringSubstr((SV),0), 15, "Tahoma Bold" ,White);
   ObjectSet("DownTicks2", OBJPROP_CORNER, 0);
   ObjectSet("DownTicks2", OBJPROP_XDISTANCE, 5);
   ObjectSet("DownTicks2", OBJPROP_YDISTANCE, 35);
 
//----
   返回(0);
  }
//+-------------------------------------------------------- -------------------+
[/代码]
[/QUOTE]
成交量[i](收盘[i]、开盘[i])单位不一样,量与价怎么可以直接相加?