double Ask
通货的买入价
示例:
if(iRSI(NULL,0,14,PRICE_CLOSE,0)<25)
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,
"My order #2",3,D'2005.10.10 12:30',Red);
return;
}
int Bars
返回图表中的柱数
示例:
int counter=1;
for(int i=1;i<=Bars;i++)
{
Print(Close[i-1]);
}
double Bid
通货的卖价
示例:
if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75)
{
OrderSend("EURUSD",OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,
"My order #2",3,D'2005.10.10 12:30',Red);
return(0);
}
double Close[]
返回指定索引位置的收盘价格
示例:
int handle, bars=Bars;
handle=FileOpen("file.csv",FILE_CSV|FILE_WRITE,';');
if(handle>0)
{
// write table columns headers
FileWrite(handle, "Time;Open;High;Low;Close;Volume");
// write data
for(int i=0; i
FileWrite(handle, Time[i], Open[i], High[i], Low[i], Close[i], Volume[i]);
FileClose(handle);
}
int Digits
返回当前通货的汇率小数位
示例:
Print(DoubleToStr(Close[i-1], Digits));
double High[]
返回指定索引位置的最高价格
示例:
int handle, bars=Bars;
handle=FileOpen("file.csv", FILE_CSV|FILE_WRITE, ';');
if(handle>0)
{
// write table columns headers
FileWrite(handle, "Time;Open;High;Low;Close;Volume");
// write data
for(int i=0; i
FileWrite(handle, Time[i], Open[i], High[i], Low[i], Close[i], Volume[i]);
FileClose(handle);
}
double Low[]
返回指定索引位置的最低价格
示例:
int handle, bars=Bars;
handle=FileOpen("file.csv", FILE_CSV|FILE_WRITE, ";");
if(handle>0)
{
// write table columns headers
FileWrite(handle, "Time;Open;High;Low;Close;Volume");
// write data
for(int i=0; i
FileWrite(handle, Time[i], Open[i], High[i], Low[i], Close[i], Volume[i]);
FileClose(handle);
}
double Open[]
返回指定索引位置的开盘价格
示例:
int handle, bars=Bars;
handle=FileOpen("file.csv", FILE_CSV|FILE_WRITE, ';');
if(handle>0)
{
// write table columns headers
FileWrite(handle, "Time;Open;High;Low;Close;Volume");
// write data
for(int i=0; i
FileWrite(handle, Time[i], Open[i], High[i], Low[i], Close[i], Volume[i]);
FileClose(handle);
}
double Point
返回当前图表的点值
示例:
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,Red);
datetime Time[]
返回指定索引位置的时间
示例:
int handle, bars=Bars;
handle=FileOpen("file.csv", FILE_CSV|FILE_WRITE, ';');
if(handle>0)
{
// write table columns headers
FileWrite(handle, "Time;Open;High;Low;Close;Volume");
// write data
for(int i=0; i
FileWrite(handle, Time[i], Open[i], High[i], Low[i], Close[i], Volume[i]);
FileClose(handle);
}
double Volume[]
返回指定索引位置的成交量
示例:
int handle, bars=Bars;
handle=FileOpen("file.csv", FILE_CSV|FILE_WRITE, ';');
if(handle>0)
{
// write table columns headers
FileWrite(handle, "Time;Open;High;Low;Close;Volume");
// erite data
for(int i=0; i
FileWrite(handle, Time[i], Open[i], High[i], Low[i], Close[i], Volume[i]);
FileClose(handle);
)
Applied price enumeration
价格类型枚举
示例:
Constant | Value | Description |
PRICE_CLOSE | 0 | 收盘价 |
PRICE_OPEN | 1 | 开盘价 |
PRICE_HIGH | 2 | 最高价 |
PRICE_LOW | 3 | 最低价 |
PRICE_MEDIAN | 4 | 最高价和最低价的平均价 |
PRICE_TYPICAL | 5 | 最高价、最低价和收盘价的平均价 |
PRICE_WEIGHTED | 6 | 开、收盘价和最高最低价的平均价 |
画图形状样式枚举,
形状:
Constant | Value | Description |
DRAW_LINE | 0 | Drawing line. |
DRAW_SECTION | 1 | Drawing sections. |
DRAW_HISTOGRAM | 2 | Drawing histogram. |
DRAW_ARROW | 3 | Drawing arrows (symbols). |
DRAW_NONE | 12 | No drawing. |
Constant | Value | Description |
STYLE_SOLID | 0 | The pen is solid. |
STYLE_DASH | 1 | The pen is dashed. |
STYLE_DOT | 2 | The pen is dotted. |
STYLE_DASHDOT | 3 | The pen has alternating dashes and dots. |
STYLE_DASHDOTDOT | 4 | The pen has alternating dashes and double dots. |
移动平均线模式枚举,iAlligator(), iEnvelopes(), iEnvelopesOnArray, iForce(), iGator(), iMA(), iMAOnArray(), iStdDev(), iStdDevOnArray(), iStochastic()这些会调用此枚举
Constant | Value | Description |
MODE_SMA | 0 | Simple moving average, |
MODE_EMA | 1 | Exponential moving average, |
MODE_SMMA | 2 | Smoothed moving average, |
MODE_LWMA | 3 | Linear weighted moving average. |
物件属性枚举
Constant | Value | Description |
OBJPROP_TIME1 | 0 | Datetime value to set/get first coordinate time part. |
OBJPROP_PRICE1 | 1 | Double value to set/get first coordinate price part. |
OBJPROP_TIME2 | 2 | Datetime value to set/get second coordinate time part. |
OBJPROP_PRICE2 | 3 | Double value to set/get second coordinate price part. |
OBJPROP_TIME3 | 4 | Datetime value to set/get third coordinate time part. |
OBJPROP_PRICE3 | 5 | Double value to set/get third coordinate price part. |
OBJPROP_COLOR | 6 | Color value to set/get object color. |
OBJPROP_STYLE | 7 | Value is one of STYLE_SOLID, STYLE_DASH, STYLE_DOT, STYLE_DASHDOT, STYLE_DASHDOTDOT constants to set/get object line style. |
OBJPROP_WIDTH | 8 | Integer value to set/get object line width. Can be from 1 to 5. |
OBJPROP_BACK | 9 | Boolean value to set/get background drawing flag for object. |
系列数组标识符
Constant | Value | Description |
MODE_OPEN | 0 | Open price. |
MODE_LOW | 1 | Low price. |
MODE_HIGH | 2 | High price. |
MODE_CLOSE | 3 | Close price. |
MODE_VOLUME | 4 | Volume, used in Lowest() and Highest() functions. |
MODE_TIME | 5 | Bar open time, used in ArrayCopySeries() function. |
特殊常量
Constant | Value | Description |
PERIOD_M1 | 1 | 1 minute. |
PERIOD_M5 | 5 | 5 minutes. |
PERIOD_M15 | 15 | 15 minutes. |
PERIOD_M30 | 30 | 30 minutes. |
PERIOD_H1 | 60 | 1 hour. |
PERIOD_H4 | 240 | 4 hour. |
PERIOD_D1 | 1440 | Daily. |
PERIOD_W1 | 10080 | Weekly. |
PERIOD_MN1 | 43200 | Monthly. |
0 (zero) | 0 | Time frame used on the chart. |
交易类型
Constant | Value | Description |
OP_BUY | 0 | Buying position. |
OP_SELL | 1 | Selling position. |
OP_BUYLIMIT | 2 | Buy limit pending position. |
OP_SELLLIMIT | 3 | Sell limit pending position. |
OP_BUYSTOP | 4 | Buy stop pending position. |
OP_SELLSTOP | 5 | Sell stop pending position. |
颜色表
Black | DarkGreen | DarkSlateGray | Olive | Green | Teal | Navy | Purple |
Maroon | Indigo | MidnightBlue | DarkBlue | DarkOliveGreen | SaddleBrown | ForestGreen | OliveDrab |
SeaGreen | DarkGoldenrod | DarkSlateBlue | Sienna | MediumBlue | Brown | DarkTurquoise | DimGray |
LightSeaGreen | DarkViolet | FireBrick | MediumVioletRed | MediumSeaGreen | Chocolate | Crimson | SteelBlue |
Goldenrod | MediumSpringGreen | LawnGreen | CadetBlue | DarkOrchid | YellowGreen | LimeGreen | OrangeRed |
DarkOrange | Orange | Gold | Yellow | Chartreuse | Lime | SpringGreen | Aqua |
DeepSkyBlue | Blue | Magenta | Red | Gray | SlateGray | Peru | BlueViolet |
LightSlateGray | DeepPink | MediumTurquoise | DodgerBlue | Turquoise | RoyalBlue | SlateBlue | DarkKhaki |
IndianRed | MediumOrchid | GreenYellow | MediumAquamarine | DarkSeaGreen | Tomato | RosyBrown | Orchid |
MediumPurple | PaleVioletRed | Coral | CornflowerBlue | DarkGray | SandyBrown | MediumSlateBlue | Tan |
DarkSalmon | BurlyWood | HotPink | Salmon | Violet | LightCoral | SkyBlue | LightSalmon |
Plum | Khaki | LightGreen | Aquamarine | Silver | LightSkyBlue | LightSteelBlue | LightBlue |
PaleGreen | Thistle | PowderBlue | PaleGoldenrod | PaleTurquoise | LightGrey | Wheat | NavajoWhite |
Moccasin | LightPink | Gainsboro | PeachPuff | Pink | Bisque | LightGoldenRod | BlanchedAlmond |
LemonChiffon | Beige | AntiqueWhite | PapayaWhip | Cornsilk | LightYellow | LightCyan | Linen |
Lavender | MistyRose | OldLace | WhiteSmoke | Seashell | Ivory | Honeydew | AliceBlue |
LavenderBlush | MintCream | Snow | White |
double iAC( string symbol, int timeframe, int shift)
计算 Bill Williams' Accelerator/Decelerator oscillator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
示例:
double result=iAC(NULL, 0, 1);
double iAD( string symbol, int timeframe, int shift)
计算 Accumulation/Distribution indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
示例:
double result=iAD(NULL, 0, 1);
double iAlligator( string symbol, int timeframe, int jaw_period, int jaw_shift, int teeth_period, int teeth_shift, int lips_period, int lips_shift, int ma_method, int applied_price, int mode, int shift)
计算 Bill Williams' Alligator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
jaw_period - 颚线周期
jaw_shift - 颚线位移
teeth_period - 齿线周期
teeth_shift - 齿线位移
lips_period - 唇线周期
lips_shift - 唇线位移
ma_method - 移动平均线种类
applied_price - 应用价格类型
mode - 来源模式,MODE_GATORJAW,MODE_GATORTEETH 或MODE_GATORLIPS
shift - 位移数
double jaw_val=iAlligator(NULl, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, 1);
double iADX( string symbol, int timeframe, int period, int applied_price, int mode, int shift)
计算 Movement directional index 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
applied_price - 应用价格类型
mode - 来源模式,参见指标线分类枚举
shift - 位移数
if(iADX(NULL,0,14,PRICE_HIGH,MODE_MAIN,0)>iADX(NULL,0,14,PRICE_HIGH,MODE_PLUSDI,0)) return(0);
double iATR( string symbol, int timeframe, int period, int shift)
计算 Indicator of the average true range 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
shift - 位移数
if(iATR(NULL,0,12,0)>iATR(NULL,0,20,0)) return(0);
double iAO( string symbol, int timeframe, int shift)
计算 Bill Williams' Awesome oscillator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
double val=iAO(NULL, 0, 2);
double iBearsPower( string symbol, int timeframe, int period, int applied_price, int shift)
计算 Bears Power indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
applied_price - 应用价格类型
shift - 位移数
double val=iBearsPower(NULL, 0, 13,PRICE_CLOSE,0);
double iBands( string symbol, int timeframe, int period, int deviation, int bands_shift, int applied_price, int mode, int shift)
计算 Bollinger bands indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
deviation - 背离
bands_shift - Bands位移
applied_price - 应用价格类型
mode - 来源模式,参见指标线分类枚举
shift - 位移数
if(iBands(NULL,0,20,2,0,PRICE_LOW,MODE_LOWER,0)>Low[0]) return(0);
double iBandsOnArray( double array[], int total, int period, double deviation, int bands_shift, int mode, int shift)
从数组中计算 Bollinger bands indicator 的值
:: 输入参数
array[] - 数组数据
total - 总数据数量
period - 周期
deviation - 背离
bands_shift - Bands位移
applied_price - 应用价格类型
mode - 来源模式,参见指标线分类枚举
shift - 位移数
if(iBands(NULL,0,20,2,0,PRICE_LOW,MODE_LOWER,0)>Low[0]) return(0);
double iBullsPower( string symbol, int timeframe, int period, int applied_price, int shift)
计算 Bulls Power indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
applied_price - 应用价格类型
shift - 位移数
double val=iBullsPower(NULL, 0, 13,PRICE_CLOSE,0);
double iCCI( string symbol, int timeframe, int period, int applied_price, int shift)
计算 Commodity channel index 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
applied_price - 应用价格类型
shift - 位移数
if(iCCI(NULL,0,12,0)>iCCI(NULL,0,20,0)) return(0);
double iCCIOnArray( double array[], int total, int period, int shift)
从数组中计算 Commodity channel index 的值
:: 输入参数
array[] - 数组数据
total - 总数据数量
period - 周期
shift - 位移数
if(iCCIOnArray(ExtBuffer,total,12,0)>iCCI(NULL,0,20,PRICE_OPEN, 0)) return(0);
double iCustom( string symbol, int timeframe, string name, ... , int mode, int shift)
计算 自定义指标 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
name - 自定义指标名称
... - 自定义指标参数
mode - 来源模式,参见指标线分类枚举
shift - 位移数
double val=iCustom(NULL, 0, "SampleInd",13,1,0);
double iDeMarker( string symbol, int timeframe, int period, int shift)
计算 DeMarker indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
shift - 位移数
double val=iDeMarker(NULL, 0, 13, 1);
double iEnvelopes( string symbol, int timeframe, int ma_period, int ma_method, int ma_shift, int applied_price, double deviation, int mode, int shift)
计算 Envelopes indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
ma_period - 移动平均线周期
ma_method - 移动平均线模式
ma_shift - 移动平均线位移
applied_price - 应用价格类型
deviation - 背离
mode - 来源模式,参见指标线分类枚举
shift - 位移数
double val=iEnvelopes(NULL, 0, 13,MODE_SMA,10,PRICE_CLOSE,0.2,MODE_UPPER,0);
double iEnvelopesOnArray( double array[], int total, int ma_period, int ma_method, int ma_shift, double deviation, int mode, int shift)
从数组中计算 Envelopes indicator 的值
:: 输入参数
array[] - 数组数据
total - 总数据数量
ma_period - 移动平均线周期
ma_method - 移动平均线模式
ma_shift - 移动平均线位移
deviation - 背离
mode - 来源模式,参见指标线分类枚举
shift - 位移数
double val=iEnvelopesOnArray(ExtBuffer, 0, 13, MODE_SMA, 0.2, MODE_UPPER,0 );
double iForce( string symbol, int timeframe, int period, int ma_method, int applied_price, int shift)
计算 Force index 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
ma_method - 移动平均线模式
applied_price - 应用价格类型
shift - 位移数
double val=iForce(NULL, 0, 13,MODE_SMA,PRICE_CLOSE,0);
double iFractals( string symbol, int timeframe, int mode, int shift)
计算 Fractals 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
mode - 来源模式,参见指标线分类枚举
shift - 位移数
double val=iFractals(NULL, 0, MODE_UPPER,0);
double iGator( string symbol, int timeframe, int jaw_period, int jaw_shift, int teeth_period, int teeth_shift, int lips_period, int lips_shift, int ma_method, int applied_price, int mode, int shift)
计算 Fractals 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
jaw_period - 颚线周期
jaw_shift - 颚线位移
teeth_period - 齿线周期
teeth_shift - 齿线位移
lips_period - 唇线周期
lips_shift - 唇线位移
ma_method - 移动平均线种类
applied_price - 应用价格类型
mode - 来源模式,参见指标线分类枚举
shift - 位移数
double jaw_val=iGator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_UPPER, 1);
double iIchimoku( string symbol, int timeframe, int tenkan_sen, int kijun_sen, int senkou_span_b, int mode, int shift)
计算 Ichimoku Kinko Hyo 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
tenkan_sen - 转换线
jkijun_sen - 基准线
senkou_span_b - 参考范围b
mode - 来源模式,参见指标线分类枚举
shift - 位移数
double tenkan_sen=iIchimoku(NULL, 0, 9, 26, 52, MODE_TENKANSEN, 1);
double iBWMFI( string symbol, int timeframe, int shift)
计算 Bill Williams Market Facilitation index 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
double val=iBWMFI(NULL, 0, 0);
double iMomentum( string symbol, int timeframe, int period, int applied_price, int shift)
计算 Momentum indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
applied_price - 应用价格类型
shift - 位移数
if(iMomentum(NULL,0,12,PRICE_CLOSE,0)>iMomentum(NULL,0,20,PRICE_CLOSE,0)) return(0);
double iMomentumOnArray( double array[], int total, int period, int shift)
从数组中计算 Momentum indicator 的值
:: 输入参数
array[] - 数组数据
total - 总数据数量
period - 周期
shift - 位移数
if(iMomentumOnArray(mybuffer,100,12,0)>iMomentumOnArray(mubuffer,100,20,0)) return(0);
double iMFI( string symbol, int timeframe, int period, int shift)
计算 Money flow index 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
shift - 位移数
if(iMFI(NULL,0,14,0)>iMFI(NULL,0,14,1)) return(0);
double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)
计算 Moving average indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
ma_shift - 移动平均线位移
ma_method - 移动平均线模式
applied_price - 应用价格类型
shift - 位移数
AlligatorJawsBuffer[i]=iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,i);
double iMAOnArray( double array[], int total, int period, int ma_shift, int ma_method, int shift)
从数组中计算 Moving average indicator 的值
:: 输入参数
array[] - 数组数据
total - 总数据数量
period - 周期
ma_shift - 移动平均线位移
ma_method - 移动平均线模式
shift - 位移数
double macurrent=iMAOnArray(ExtBuffer,0,5,0,MODE_LWMA,0);
double macurrentslow=iMAOnArray(ExtBuffer,0,10,0,MODE_LWMA,0);
double maprev=iMAOnArray(ExtBuffer,0,5,0,MODE_LWMA,1);
double maprevslow=iMAOnArray(ExtBuffer,0,10,0,MODE_LWMA,1);
//----
if(maprev=macurrentslow)
Alert("crossing up");
double iOsMA( string symbol, int timeframe, int fast_ema_period, int slow_ema_period, int signal_period, int applied_price, int shift)
计算 Moving Average of Oscillator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
fast_ema_period - 快均线周期
slow_ema_period - 慢均线周期
signal_period - 信号周期
applied_price - 应用价格类型
shift - 位移数
if(iOsMA(NULL,0,12,26,9,PRICE_OPEN,1)>iOsMA(NULL,0,12,26,9,PRICE_OPEN,0)) return(0);
double iMACD( string symbol, int timeframe, int fast_ema_period, int slow_ema_period, int signal_period, int applied_price, int mode, int shift)
计算 Moving averages convergence/divergence 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
fast_ema_period - 快均线周期
slow_ema_period - 慢均线周期
signal_period - 信号周期
applied_price - 应用价格类型
mode - 来源模式,参见指标线分类枚举
shift - 位移数
if(iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0)) return(0);
double iOBV( string symbol, int timeframe, int applied_price, int shift)
计算 On Balance Volume indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
shift - 位移数
double val=iOBV(NULL, 0, PRICE_CLOSE, 1);
double iSAR( string symbol, int timeframe, double step, double maximum, int shift)
计算 On Balance Volume indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
step - 步幅
maximum - 最大值
shift - 位移数
if(iSAR(NULL,0,0.02,0.2,0)>Close[0]) return(0);
double iRSI( string symbol, void timeframe, int period, int applied_price, int shift)
计算 Relative strength index 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
applied_price - 应用价格类型
shift - 位移数
if(iRSI(NULL,0,14,PRICE_CLOSE,0)>iRSI(NULL,0,14,PRICE_CLOSE,1)) return(0);
double iRSIOnArray( double array[], int total, int period, int shift)
从数组中计算 Relative strength index 的值
:: 输入参数
array[] - 数组数据
total - 总数据数量
period - 周期
shift - 位移数
if(iRSIOnBuffer(ExtBuffer,1000,14,0)>iRSI(NULL,0,14,PRICE_CLOSE,1)) return(0);
double iRVI( string symbol, int timeframe, int period, int mode, int shift)
计算 Relative Vigor index 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
mode - 来源模式,参见指标线分类枚举
shift - 位移数
double val=iRVI(NULL, 0, 10,MODE_MAIN,0);
double iStdDev( string symbol, int timeframe, int ma_period, int ma_method, int ma_shift, int applied_price, int shift)
计算 Standard Deviation indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
ma_period - 移动平均线周期
ma_method - 移动平均线模式
ma_shift - 移动平均线位移
applied_price - 应用价格类型
shift - 位移数
double val=iStdDev(NULL,0,10,MODE_EMA,0,PRICE_CLOSE,0);
double iStdDevOnArray( double array[], int total, int ma_period, int ma_method, int ma_shift, int shift)
从数组中计算 Standard Deviation indicator 的值
:: 输入参数
array[] - 数组数据
total - 总数据数量
ma_period - 移动平均线周期
ma_method - 移动平均线模式
ma_shift - 移动平均线位移
shift - 位移数
double val=iStdDevOnArray(ExtBuffer,100,10,MODE_EMA,0,0);
double iStochastic( string symbol, int timeframe, int %Kperiod, int %Dperiod, int slowing, int method, int price_field, int mode, int shift)
计算 Stochastic oscillator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
%Kperiod - %K线周期
%Dperiod - %D线周期
slowing - 减速量
method - 移动平均线种类
price_field - 价格领域参数: 0 - Low/High or 1 - Close/Close.
mode - 来源模式,参见指标线分类枚举
shift - 位移数
if(iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0)>iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0))
return(0);
double iWPR( string symbol, int timeframe, int period, int shift)
计算 Larry William's percent range indicator 的值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
period - 周期
shift - 位移数
if(iWPR(NULL,0,14,0)>iWPR(NULL,0,14,1)) return(0);
int iBars( string symbol, int timeframe)
返回制定图表的数据数
:: 输入参数
symbol - 通货标识
timeframe - 时间线
Print("Bar count on the 'EUROUSD' symbol with PERIOD_H1 is",iBars("EUROUSD",PERIOD_H1));
int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)
在制定图表中搜索数据
:: 输入参数
symbol - 通货标识
timeframe - 时间线
time - 时间
exact - 是否精确的
datetime some_time=D'2004.03.21 12:00';
int shift=iBarShift("EUROUSD",PERIOD_M1,some_time);
Print("shift of bar with open time ",TimeToStr(some_time)," is ",shift);
double iClose( string symbol, int timeframe, int shift)
返回制定图表的收盘价
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ", iOpen("USDCHF",PERIOD_H1,i),",
iHigh("USDCHF",PERIOD_H1,i),", ", iLow("USDCHF",PERIOD_H1,i),",
iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));
double iHigh( string symbol, int timeframe, int shift)
返回制定图表的最高价
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ", iOpen("USDCHF",PERIOD_H1,i),",
iHigh("USDCHF",PERIOD_H1,i),", ", iLow("USDCHF",PERIOD_H1,i),",
iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));
double iLow( string symbol, int timeframe, int shift)
返回制定图表的最低价
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ", iOpen("USDCHF",PERIOD_H1,i),",
iHigh("USDCHF",PERIOD_H1,i),", ", iLow("USDCHF",PERIOD_H1,i),",
iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));
double iOpen( string symbol, int timeframe, int shift)
返回制定图表的开盘价
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ", iOpen("USDCHF",PERIOD_H1,i),",
iHigh("USDCHF",PERIOD_H1,i),", ", iLow("USDCHF",PERIOD_H1,i),",
iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));
datetime iTime( string symbol, int timeframe, int shift)
返回制定图表的时间
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ", iOpen("USDCHF",PERIOD_H1,i),",
iHigh("USDCHF",PERIOD_H1,i),", ", iLow("USDCHF",PERIOD_H1,i),",
iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));
double iVolume( string symbol, int timeframe, int shift)
返回制定图表的成交量
:: 输入参数
symbol - 通货标识
timeframe - 时间线
shift - 位移数
Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,i),", ", iOpen("USDCHF",PERIOD_H1,i),",
iHigh("USDCHF",PERIOD_H1,i),", ", iLow("USDCHF",PERIOD_H1,i),",
iClose("USDCHF",PERIOD_H1,i),", ", iVolume("USDCHF",PERIOD_H1,i));
int Highest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)
返回制定图表的某段数据的最高值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
type - 数据类型
count - 计算范围
start - 开始点
double val;
// calculating the highest value in the range from 5 element to 25 element
// indicator charts symbol and indicator charts time frame
val=High[Highest(NULL,0,MODE_HIGH,20,4)];
int Lowest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)
返回制定图表的某段数据的最高值
:: 输入参数
symbol - 通货标识
timeframe - 时间线
type - 数据类型
count - 计算范围
start - 开始点
double val=Low[Lowest(NULL,0,MODE_LOW,10,10)];
交易函数 [Trading Functions]
int HistoryTotal( )
返回历史数据的数量
// retrieving info from trade history
int i,hstTotal=HistoryTotal();
for(i=0;i //---- check selection result if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Access to history failed with error (",GetLastError(),")"); break; } // some work with order } bool OrderClose( int ticket, double lots, double price, int slippage, color Color=CLR_NONE) 对订单进行平仓操作。 :: 输入参数 ticket - 订单编号 lots - 手数 price - 平仓价格 slippage - 最高划点数 Color - 标记颜色 示例: if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75) { OrderClose(order_id,1,Ask,3,Red); return(0); } bool OrderCloseBy( int ticket, int opposite, color Color=CLR_NONE) 对订单进行平仓操作。 :: 输入参数 ticket - 订单编号 opposite - 相对订单编号 Color - 标记颜色 示例: if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75) { OrderCloseBy(order_id,opposite_id); return(0); } double OrderClosePrice( ) 返回订单的平仓价 示例: if(OrderSelect(ticket,SELECT_BY_POS)==true) Print("Close price for the order ",ticket," = ",OrderClosePrice()); else Print("OrderSelect failed error code is",GetLastError()); datetime OrderCloseTime( ) 返回订单的平仓时间 示例: if(OrderSelect(10,SELECT_BY_POS,MODE_HISTORY)==true) { datetime ctm=OrderOpenTime(); if(ctm>0) Print("Open time for the order 10 ", ctm); ctm=OrderCloseTime(); if(ctm>0) Print("Close time for the order 10 ", ctm); } else Print("OrderSelect failed error code is",GetLastError()); string OrderComment( ) 返回订单的注释 示例: string comment; if(OrderSelect(10,SELECT_BY_TICKET)==false) { Print("OrderSelect failed error code is",GetLastError()); return(0); } comment = OrderComment(); // ... double OrderCommission( ) 返回订单的佣金数 示例: if(OrderSelect(10,SELECT_BY_POS)==true) Print("Commission for the order 10 ",OrderCommission()); else Print("OrderSelect failed error code is",GetLastError()); bool OrderDelete( int ticket) 删除未启用的订单 :: 输入参数 ticket - 订单编号 示例: if(Ask>var1) { OrderDelete(order_ticket); return(0); } datetime OrderExpiration( ) 返回代办订单的有效日期 示例: if(OrderSelect(10, SELECT_BY_TICKET)==true) Print("Order expiration for the order #10 is ",OrderExpiration()); else Print("OrderSelect failed error code is",GetLastError()); double OrderLots( ) 返回选定订单的手数 示例: if(OrderSelect(10,SELECT_BY_POS)==true) Print("lots for the order 10 ",OrderLots()); else Print("OrderSelect failed error code is",GetLastError()); int OrderMagicNumber( ) 返回选定订单的指定编号 示例: if(OrderSelect(10,SELECT_BY_POS)==true) Print("Magic number for the order 10 ", OrderMagicNumber()); else Print("OrderSelect failed error code is",GetLastError()); bool OrderModify( int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color=CLR_NONE) 对订单进行平仓操作。 :: 输入参数 ticket - 订单编号 price - 平仓价格 stoploss - 止损价 takeprofit - 获利价 expiration - 有效期 Color - 标记颜色 示例: if(TrailingStop>0) { SelectOrder(12345,SELECT_BY_TICKET); if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss() OrderModify(OrderTicket(),Ask-10*Point,Ask-35*Point,OrderTakeProfit(),0,Blue); return(0); } } } double OrderOpenPrice( ) 返回选定订单的买入价 示例: if(OrderSelect(10, SELECT_BY_POS)==true) Print("open price for the order 10 ",OrderOpenPrice()); else Print("OrderSelect failed error code is",GetLastError()); datetime OrderOpenTime( ) 返回选定订单的买入时间 示例: if(OrderSelect(10, SELECT_BY_POS)==true) Print("open time for the order 10 ",OrderOpenTime()); else Print("OrderSelect failed error code is",GetLastError()); void OrderPrint( ) 将订单打印到窗口上 示例: if(OrderSelect(10, SELECT_BY_TICKET)==true) OrderPrint(); else Print("OrderSelect failed error code is",GetLastError()); bool OrderSelect( int index, int select, int pool=MODE_TRADES) 选定订单 :: 输入参数 index - 订单索引 select - 选定模式,SELECT_BY_POS,SELECT_BY_TICKET pool - Optional order pool index. Used when select parameter is SELECT_BY_POS.It can be any of the following values: MODE_TRADES (default)- order selected from trading pool(opened and pending orders), MODE_HISTORY - order selected from history pool (closed and canceled order). 示例: if(OrderSelect(12470, SELECT_BY_TICKET)==true) { Print("order #12470 open price is ", OrderOpenPrice()); Print("order #12470 close price is ", OrderClosePrice()); } else Print("OrderSelect failed error code is",GetLastError()); int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE) 发送订单 :: 输入参数 symbol - 通货标示 cmd - 购买方式 volume - 购买手数 price - 平仓价格 slippage - 最大允许滑点数 stoploss - 止损价 takeprofit - 获利价 comment - 注释 magic - 自定义编号 expiration - 过期时间(只适用于待处理订单) arrow_color - 箭头颜色 示例: int ticket; if(iRSI(NULL,0,14,PRICE_CLOSE,0)<25) { ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green); if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); return(0); } } double OrderStopLoss( ) 返回选定订单的止损 示例: if(OrderSelect(ticket,SELECT_BY_POS)==true) Print("Stop loss value for the order 10 ", OrderStopLoss()); else Print("OrderSelect failed error code is",GetLastError()); int OrdersTotal( ) 返回总订单数 示例: int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\"); if(handle<0) return(0); // write header FileWrite(handle,"# int total=OrdersTotal(); // write open orders for(int pos=0;pos if(OrderSelect(pos,SELECT_BY_POS)==false) continue; FileWrite(handle,OrderTicket(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots()); } FileClose(handle); int OrdersTotal( ) 返回总订单数 示例: if(OrderSelect(order_id, SELECT_BY_TICKET)==true) Print("Swap for the order #", order_id, " ",OrderSwap()); else Print("OrderSelect failed error code is",GetLastError()); double OrderSwap( ) 返回指定订单的汇率 示例: if(OrderSelect(order_id, SELECT_BY_TICKET)==true) Print("Swap for the order #", order_id, " ",OrderSwap()); else Print("OrderSelect failed error code is",GetLastError()); string OrderSymbol( ) 返回指定订单的通货标识 示例: if(OrderSelect(12, SELECT_BY_POS)==true) Print("symbol of order #", OrderTicket(), " is ", OrderSymbol()); else Print("OrderSelect failed error code is",GetLastError()); double OrderTakeProfit( ) 返回指定订单的获利点数 示例: if(OrderSelect(12, SELECT_BY_POS)==true) Print("Order #",OrderTicket()," profit: ", OrderTakeProfit()); else Print("OrderSelect() âåðíóë îøèáêó - ",GetLastError()); int OrderTicket( ) 返回指定订单的编号 示例: if(OrderSelect(12, SELECT_BY_POS)==true) order=OrderTicket(); else Print("OrderSelect failed error code is",GetLastError()); int OrderType( ) 返回指定订单的类型 示例: int order_type; if(OrderSelect(12, SELECT_BY_POS)==true) { order_type=OrderType(); // ... } else Print("OrderSelect() âåðíóë îøèáêó - ",GetLastError()); 窗口函数 [Window Functions] double PriceOnDropped( ) Returns price part of dropped point where expert or script was dropped. This value is valid when expert or script dropped by mouse. Note: For custom indicators this value is undefined. 示例: double drop_price=PriceOnDropped(); datetime drop_time=TimeOnDropped(); //---- may be undefined (zero) if(drop_time>0) { ObjectCreate("Dropped price line", OBJ_HLINE, 0, drop_price); ObjectCreate("Dropped time line", OBJ_VLINE, 0, drop_time); } datetime TimeOnDropped( ) Returns time part of dropped point where expert or script was dropped. This value is valid when expert or script dropped by mouse. Note: For custom indicators this value is undefined. 示例: double drop_price=PriceOnDropped(); datetime drop_time=TimeOnDropped(); //---- may be undefined (zero) if(drop_time>0) { ObjectCreate("Dropped price line", OBJ_HLINE, 0, drop_price); ObjectCreate("Dropped time line", OBJ_VLINE, 0, drop_time); } int WindowFind( string name) 返回窗口的索引号 :: 输入参数 name - 指标简称 示例: int win_idx=WindowFind("MACD(12,26,9)"); int WindowHandle( string symbol, int timeframe) 返回窗口的句柄 :: 输入参数 symbol - 通货标识 timeframe - 时间线 示例: int win_handle=WindowHandle("USDX",PERIOD_H1); if(win_handle!=0) Print("Window with USDX,H1 detected. Rates array will be copied immediately."); bool WindowIsVisible( int index) 返回窗口是否可见 :: 输入参数 index - 窗口索引号 示例: int maywin=WindowFind("MyMACD"); if(maywin>-1 && WindowIsVisible(maywin)==true) Print("window of MyMACD is visible"); else Print("window of MyMACD not found or is not visible"); int WindowOnDropped( ) Returns window index where expert, custom indicator or script was dropped. This value is valid when expert, custom indicator or script dropped by mouse. 示例: if(WindowOnDropped()!=0) { Print("Indicator 'MyIndicator' must be applied to main chart window!"); return(false); } int WindowsTotal( ) 返回窗口数 示例: Print("Windows count = ", WindowsTotal()); int WindowXOnDropped( ) Returns x-axis coordinate in pixels were expert or script dropped to the chart. See also WindowYOnDropped(), WindowOnDropped() 示例: Print("Expert dropped point x=",WindowXOnDropped()," y=",WindowYOnDropped());/div> int WindowYOnDropped( ) Returns y-axis coordinate in pixels were expert or script dropped to the chart. See also WindowYOnDropped(), WindowOnDropped() 示例: Print("Expert dropped point x=",WindowXOnDropped()," y=",WindowYOnDropped()); ----------------------------------------------------------------- 数组函数 [Array Functions] int ArrayBsearch( double array[], double value, int count=WHOLE_ARRAY, int start=0, int direction=MODE_ASCEND) 搜索一个值在数组中的位置 此函数不能用在字符型或连续数字的数组上. :: 输入参数 array[] - 需要搜索的数组 value - 将要搜索的值 count - 搜索的数量,默认搜索所有的数组 start - 搜索的开始点,默认从头开始 direction - 搜索的方向,MODE_ASCEND 顺序搜索 MODE_DESCEND 倒序搜索 示例: datetime daytimes[]; int shift=10,dayshift; // All the Time[] timeseries are sorted in descendant mode ArrayCopySeries(daytimes,MODE_TIME,Symbol(),PERIOD_D1); if(Time[shift]>>=daytimes[0]) dayshift=0; else { dayshift=ArrayBsearch(daytimes,Time[shift],WHOLE_ARRAY,0,MODE_DESCEND); if(Period() } Print(TimeToStr(Time[shift])," corresponds to ",dayshift," day bar opened at TimeToStr(daytimes[dayshift])); int ArrayCopy( object& dest[], object source[], int start_dest=0, int start_source=0, int count=WHOLE_ARRAY) 复制一个数组到另外一个数组。 只有double[], int[], datetime[], color[], 和 bool[] 这些类型的数组可以被复制。 :: 输入参数 dest[] - 目标数组 source[] - 源数组 start_dest - 从目标数组的第几位开始写入,默认为0 start_source - 从源数组的第几位开始读取,默认为0 count - 读取多少位的数组 示例: double array1[][6]; double array2[10][6]; // fill array with some data ArrayCopyRates(array1); ArrayCopy(array2, array1,0,Bars-9,10); // now array2 has first 10 bars in the history int ArrayCopyRates( double& dest_array[], string symbol=NULL, int timeframe=0) 复制一段走势图上的数据到一个二维数组,数组的第二维只有6个项目分别是: 0 - 时间, 1 - 开盘价, 2 - 最低价, 3 - 最高价, 4 - 收盘价, 5 - 成交量. :: 输入参数 dest_array[] - 目标数组 symbol - 标示,当前所需要的通货的标示 timeframe - 图表的时间线 示例: double array1[][6]; ArrayCopyRates(array1,"EURUSD", PERIOD_H1); Print("Current bar ",TimeToStr(array1[0][0]),"Open", array1[0][1]); int ArrayCopySeries( double& array[], int series_index, string symbol=NULL, int timeframe=0) 复制一个系列的走势图数据到数组上 注: 如果series_index是MODE_TIME, 那么第一个参数必须是日期型的数组 :: 输入参数 dest_array[] - 目标数组 series_index - 想要取的系列的名称或编号,0-5 symbol - 标示,当前所需要的通货的标示 timeframe - 图表的时间线 示例: datetime daytimes[]; int shift=10,dayshift; // All the Time[] timeseries are sorted in descendant mode ArrayCopySeries(daytimes,MODE_TIME,Symbol(),PERIOD_D1); if(Time[shift]>=daytimes[0]) dayshift=0; else { dayshift=ArrayBsearch(daytimes,Time[shift],WHOLE_ARRAY,0,MODE_DESCEND); if(Period() } Print(TimeToStr(Time[shift])," corresponds to ",dayshift," day bar opened at ", TimeToStr(daytimes[dayshift])); int ArrayDimension( int array[]) 返回数组的维数 :: 输入参数 array[] - 需要检查的数组 示例: int num_array[10][5]; int dim_size; dim_size=ArrayDimension(num_array); // dim_size is 2 bool ArrayGetAsSeries(object array[]) 检查数组是否是有组织序列的数组(是否从最后到最开始排序过的),如果不是返回否 :: 输入参数 array[] - 需要检查的数组 示例: if(ArrayGetAsSeries(array1)==true) Print("array1 is indexed as a series array"); else Print("array1 is indexed normally (from left to right)"); int ArrayInitialize( double& array[], double value) 对数组进行初始化,返回经过初始化的数组项的个数 :: 输入参数 array[] - 需要初始化的数组 value - 新的数组项的值 示例: //---- 把所有数组项的值设置为2.1 double myarray[10]; ArrayInitialize(myarray,2.1); bool ArrayIsSeries( object array[]) 检查数组是否连续的(time,open,close,high,low, or volume). :: 输入参数 array[] - 需要检查的数组 示例: if(ArrayIsSeries(array1)==false) ArrayInitialize(array1,0); else { Print("Series array cannot be initialized!"); return(-1); } int ArrayMaximum( double array[], int count=WHOLE_ARRAY, int start=0) 找出数组中最大值的定位 :: 输入参数 array[] - 需要检查的数组 count - 搜索数组中项目的个数 start - 搜索的开始点 示例: double num_array[15]={4,1,6,3,9,4,1,6,3,9,4,1,6,3,9}; int maxValueIdx=ArrayMaximum(num_array); Print("Max value = ", num_array[maxValueIdx]); int ArrayMinimum( double array[], int count=WHOLE_ARRAY, int start=0) 找出数组中最小值的定位 :: 输入参数 array[] - 需要检查的数组 count - 搜索数组中项目的个数 start - 搜索的开始点 示例: double num_array[15]={4,1,6,3,9,4,1,6,3,9,4,1,6,3,9}; double minValueidx=ArrayMinimum(num_array); Print("Min value = ", num_array[minValueIdx]); int ArrayRange( object array[], int range_index) 取数组中指定维数中项目的数量。 :: 输入参数 array[] - 需要检查的数组 range_index - 指定的维数 示例: int dim_size; double num_array[10,10,10]; dim_size=ArrayRange(num_array, 1); int ArrayResize( object& array[], int new_size) 重定义数组大小 :: 输入参数 array[] - 需要检查的数组 new_size - 第一维中数组的新大小 示例: double array1[][4]; int element_count=ArrayResize(array, 20); // 数组中总项目数为80 bool ArraySetAsSeries( double& array[], bool set) 设置指数数组为系列数组,数组0位的值是最后的值。返回之前的数组状态 :: 输入参数 array[] - 需要处理的数组 set - 是否是设置为系列数组,true或者false 示例: double macd_buffer[300]; double signal_buffer[300]; int i,limit=ArraySize(macd_buffer); ArraySetAsSeries(macd_buffer,true); for(i=0; i macd_buffer[i]=iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,26,0,MODE_EMA,PRICE_CLOSE,i); for(i=0; i signal_buffer[i]=iMAOnArray(macd_buffer,limit,9,0,MODE_SMA,i); int ArraySize( object array[]) 返回数组的项目数 :: 输入参数 array[] - 需要处理的数组 示例: int count=ArraySize(array1); for(int i=0; i { // do some calculations. } int ArraySort( double& array[], int count=WHOLE_ARRAY, int start=0, int sort_dir=MODE_ASCEND) 对数组进行排序,系列数组不可进行排序 :: 输入参数 array[] - 需要处理的数组 count - 对多少个数组项进行排序 start - 排序的开始点 sort_dir - 排序方式,MODE_ASCEND顺序排列 MODE_DESCEND倒序排列 示例: double num_array[5]={4,1,6,3,9}; // now array contains values 4,1,6,3,9 ArraySort(num_array); // now array is sorted 1,3,4,6,9 ArraySort(num_array,MODE_DESCEND); // now array is sorted 9,6,4,3,1