找到一个筹码分布指标,但是运行不了,求助。 新评论 郑美援 2011.08.15 16:29 源码如下: //+------------------------------------------------------------------+ //| _VolumeDistribute.mq4 | //| Copyright ?2007, MetaQuotes Software Corp. | //| https://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright ?2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window extern int maxLen = 1000 ; int iPV ; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- for(int i =0 ; i < iPV ; i ++) { string str = DoubleToStr( i, 0 ) ; ObjectDelete(str) ; } //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); double PV[] ; double imax = 0 ; double imin = 0 ; double max = 0 ; double min = 10000 ; //求出给定长度的价格的区间 for(int i = 0 ; i < maxLen ; i ++) { imax = iHigh(Symbol(), PERIOD_M1, i ) ; imin = iLow(Symbol(), PERIOD_M1, i ) ; //Print( " imax = ", imax ) ; //Print( " imin = ", imin ) ; if( max < imax ) max = imax ; if( min > imin ) min = imin ; } //定义所需的price-volume 数组 iPV = (max - min )/Point; Print( " iPV = ", iPV) ; ArrayResize(PV, iPV) ; for( i =0 ; i < iPV ; i ++ ) PV =0 ; //计算各个价位的交易量 for(i = 0 ; i < maxLen ; i ++) { imax = iHigh(Symbol(), PERIOD_M1, i ) ; imin = iLow (Symbol(), PERIOD_M1, i ) ; double ivol = iVolume( Symbol(), PERIOD_M1, i )*Point ; for(double price = imin ; price <= imax ; price ++) { int price_Pos = (price - min )/Point ; PV[price_Pos] = PV[price_Pos] + ivol/(imax - imin + 1 ) ; } } //找出最大的交易量 double maxVolume ; maxVolume = 0 ; for( i = 0 ; i < iPV ; i ++ ) if( maxVolume < PV ) maxVolume = PV ; Print(" maxVolume = ", maxVolume ) ; //归一化 for( i = 0 ; i < iPV ; i ++ ) PV = PV / maxVolume ; //画出图形 for( i = 0 ; i < iPV ; i ++ ) { double EndX = Time[0] + 3600* 5 ; double EndY = min + i* Point ; double StartX = EndX - PV * 3600 * 4 ; double StartY = EndY ; string ObjName = DoubleToStr(i, 0 ) ; ObjectDelete(ObjName); ObjectCreate(ObjName, OBJ_TREND, 0, StartX, StartY, EndX, EndY); ObjectSet(ObjName, OBJPROP_RAY, 0); ObjectSet(ObjName, OBJPROP_COLOR, Red); } return( 0 ); } //+------------------------------------------------------------------+ a kind of CYQ but it cannot display WHY? 一种筹码分布指标 不显示 请给看看哪里的问题? 这么个简单的程序为什么画不出线呢?请教牛牛们。 请问有高手免费写這個Label吗? 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
源码如下:
//| _VolumeDistribute.mq4 |
//| Copyright ?2007, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
extern int maxLen = 1000 ;
int iPV ;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
for(int i =0 ; i < iPV ; i ++)
{
string str = DoubleToStr( i, 0 ) ;
ObjectDelete(str) ;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
double PV[] ;
double imax = 0 ;
double imin = 0 ;
double max = 0 ;
double min = 10000 ;
//求出给定长度的价格的区间
for(int i = 0 ; i < maxLen ; i ++)
{
imax = iHigh(Symbol(), PERIOD_M1, i ) ;
imin = iLow(Symbol(), PERIOD_M1, i ) ;
//Print( " imax = ", imax ) ;
//Print( " imin = ", imin ) ;
if( max < imax ) max = imax ;
if( min > imin ) min = imin ;
}
//定义所需的price-volume 数组
iPV = (max - min )/Point;
Print( " iPV = ", iPV) ;
ArrayResize(PV, iPV) ;
for( i =0 ; i < iPV ; i ++ )
PV =0 ;
//计算各个价位的交易量
for(i = 0 ; i < maxLen ; i ++)
{
imax = iHigh(Symbol(), PERIOD_M1, i ) ;
imin = iLow (Symbol(), PERIOD_M1, i ) ;
double ivol = iVolume( Symbol(), PERIOD_M1, i )*Point ;
for(double price = imin ; price <= imax ; price ++)
{
int price_Pos = (price - min )/Point ;
PV[price_Pos] = PV[price_Pos] + ivol/(imax - imin + 1 ) ;
}
}
//找出最大的交易量
double maxVolume ;
maxVolume = 0 ;
for( i = 0 ; i < iPV ; i ++ )
if( maxVolume < PV ) maxVolume = PV ;
Print(" maxVolume = ", maxVolume ) ;
//归一化
for( i = 0 ; i < iPV ; i ++ )
PV = PV / maxVolume ;
//画出图形
for( i = 0 ; i < iPV ; i ++ )
{
double EndX = Time[0] + 3600* 5 ;
double EndY = min + i* Point ;
double StartX = EndX - PV * 3600 * 4 ;
double StartY = EndY ;
string ObjName = DoubleToStr(i, 0 ) ;
ObjectDelete(ObjName);
ObjectCreate(ObjName, OBJ_TREND, 0, StartX, StartY, EndX, EndY);
ObjectSet(ObjName, OBJPROP_RAY, 0);
ObjectSet(ObjName, OBJPROP_COLOR, Red);
}
return( 0 );
}
//+------------------------------------------------------------------+