下载MetaTrader 5
要添加评论,请登录注册
购买之前您可以测试应用程序。了解如何测试!
liuxiaodong
282
liuxiaodong 2008.04.08 16:32 

_VolumeDistribute.mq4

//+------------------------------------------------------------------+
//| _VolumeDistribute.mq4 |
//| Copyright ?2007, MetaQuotes Software Corp. |
//| http://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 ;
//求出给定长度的价格的区间
int limit;
//int counted_bars=IndicatorCounted();
limit=Bars-counted_bars;
if(counted_bars>0) counted_bars--;
for(int i = limit ; 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 [i]=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 - imin )/Point ;
PV[price_Pos] = PV[price_Pos] + ivol/(imax - imin + 1 ) ;
}
}
//找出最大的交易量
double maxVolume ;
maxVolume = 0 ;
for( i = 0 ; i < iPV ; i ++ )
if( maxVolume < PV[i] ) maxVolume = PV[i] ;
Print(" maxVolume = ", maxVolume ) ;
//归一化
for( i = 0 ; i < iPV ; i ++ )
PV[i] = PV[i] / maxVolume ;
//画出图形
for( i = 0 ; i < iPV ; i ++ )
{
double EndX = Time[0] + 3600* 5 ;
double EndY = min + i* Point ;
double StartX = EndX - PV[i] * 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 );
}
//+------------------------------------------------------------------+

okwh
1629
okwh 2008.04.09 13:18  

Print("sx=",StartX," sy=", StartY, " ex=", EndX," ey=" EndY);

用这个检查坐标

topea
74
topea 2008.04.10 03:10  

没有输出



多看看例子

liuxiaodong
282
liuxiaodong 2008.04.12 12:51  
谢谢 我试试。
/
要添加评论,请登录注册