出現錯誤 哪一位懂了 幫忙修改一下
#property copyright ""
#property link ""
#property description ""
#property strict
#include
#property indicator_chart_window
#property indicator_buffers 9
#property indicator_plots 9
//画中轨
#property indicator_label1 "中轨"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrMagenta
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//画上轨
#property indicator_label2 "上轨"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrMagenta
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
//画下轨
#property indicator_label3 "下轨"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrMagenta
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
//画做多趋势箭头
#property indicator_label4 "做多趋势"
#property indicator_type4 DRAW_ARROW
#property indicator_color4 clrBlue
#property indicator_style4 STYLE_SOLID
#property indicator_width4 1
//画做空趋势箭头
#property indicator_label5 "做空趋势"
#property indicator_type5 DRAW_ARROW
#property indicator_color5 clrRed
#property indicator_style5 STYLE_SOLID
#property indicator_width5 1
//画做多信号箭头
#property indicator_label6 "做多信号"
#property indicator_type6 DRAW_ARROW
#property indicator_color6 clrBlue
#property indicator_style6 STYLE_SOLID
#property indicator_width6 1
//画做空信号箭头
#property indicator_label7 "做空信号"
#property indicator_type7 DRAW_ARROW
#property indicator_color7 clrRed
#property indicator_style7 STYLE_SOLID
#property indicator_width7 1
//画做多止损线
#property indicator_label8 "做多止损线"
#property indicator_type8 DRAW_LINE
#property indicator_color8 clrRed
#property indicator_style8 STYLE_SOLID
#property indicator_width8 1
//画做空止损线
#property indicator_label9 "做空止损线"
#property indicator_type9 DRAW_LINE
#property indicator_color9 clrBlue
#property indicator_style9 STYLE_SOLID
#property indicator_width9 1
//--- indicator parameters
input int 中轨周期=20;
input int InpBandsShift=0; // Bands Shift
input double 中轨偏离=2;
//引用SOTP的外部参数
input double MoneyRisk=1.00; // Offset Factor
input int Signal=1; // Display signals mode: 1-Signals & Stops; 0-only Stops; 2-only Signals;
input int Line=0.11;
//--- buffers
double 中轨[];
double 上轨[];
double 下轨[];
double 做多趋势画箭头[];
double 做空趋势画箭头[];
double 做多信号箭头[];
double 做空信号箭头[];
double 做多止损线[];
double 做空止损线[];
double ExtStdDevBuffer[];
double b上轨[];
double b下轨[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
//--- 1 additional buffer used for counting.
IndicatorBuffers(12);
IndicatorDigits(Digits);
//--- middle line
SetIndexBuffer(0,中轨);
SetIndexShift(0,InpBandsShift);
//--- upper band
SetIndexBuffer(1,上轨);
SetIndexShift(1,InpBandsShift);
//--- lower band
SetIndexBuffer(2,下轨);
SetIndexShift(2,InpBandsShift);
//--- work buffer
SetIndexBuffer(3,做多趋势画箭头);
SetIndexShift(3,InpBandsShift);
SetIndexBuffer(4,做空趋势画箭头);
SetIndexShift(4,InpBandsShift);
SetIndexBuffer(5,做多信号箭头);
SetIndexShift(5,InpBandsShift);
SetIndexBuffer(6,做空信号箭头);
SetIndexShift(6,InpBandsShift);
SetIndexBuffer(7,做多止损线);
SetIndexShift(7,InpBandsShift);
SetIndexBuffer(8,做空止损线);
SetIndexShift(8,InpBandsShift);
SetIndexBuffer(9,ExtStdDevBuffer);
SetIndexBuffer(10,b上轨);
SetIndexBuffer(11,b下轨);
SetIndexArrow(3,233);
SetIndexArrow(4,234);
SetIndexArrow(5,241);
SetIndexArrow(6,242);
//--- check for input parameter
if(中轨周期1)
pos=prev_calculated-1;
else
pos=0;
//--- main cycle
for(i=pos; i上轨[i+1]) trend=1;
if (Close[i]0 && 下轨[i]上轨[i+1]) 上轨[i]=上轨[i+1];
b上轨[i]=上轨[i]+0.5*(MoneyRisk-1)*(上轨[i]-下轨[i]);
b下轨[i]=下轨[i]-0.5*(MoneyRisk-1)*(上轨[i]-下轨[i]);
if(trend>0 && b下轨[i][b]b上轨[i+1]) b上轨[i]=b上轨[i+1];
if (trend>0)
{
if (Signal>0 && 做多趋势画箭头[i+1]==-1.0)
{
做多信号箭头[i]=b下轨[i];
做多趋势画箭头[i]=b下轨[i];
if(Line>0) 做多止损线[i]=b下轨[i];
}
else
{
做多趋势画箭头[i]=b下轨[i];
if(Line>0) 做多止损线[i]=b下轨[i];
做多信号箭头[i]=-1;
}
if (Signal==2) 做多趋势画箭头[i]=0;
做空信号箭头[i]=-1;
做空趋势画箭头[i]=-1.0;
做空止损线[i]=EMPTY_VALUE;
}
if (trend0 && 做空趋势画箭头[i+1]==-1.0)
{
做空信号箭头[i]=b上轨[i];
做空趋势画箭头[i]=b上轨[i];
if(Line>0) 做空止损线[i]=b上轨[i];
}
else
{
做空趋势画箭头[i]=b上轨[i];
if(Line>0)做空止损线[i]=b上轨[i];
做空信号箭头[i]=-1;
}
if (Signal==2) 做空趋势画箭头[i]=0;
做多信号箭头[i]=-1;
做多趋势画箭头[i]=-1.0;
做多止损线[i]=EMPTY_VALUE;
}
}
//---- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
//| Calculate Standard Deviation |
//+------------------------------------------------------------------+
double StdDev_Func(int position,const double &price[],const double &MAprice[],int period)
{
//--- variables
double StdDev_dTmp=0.0;
//--- check for position
if(position>=period)
{
//--- calcualte StdDev
for(int i=0; i<period; i++)
StdDev_dTmp+=MathPow(price[position-i]-MAprice[position],2);
StdDev_dTmp=MathSqrt(StdDev_dTmp/period);
}
//--- return calculated value
return(StdDev_dTmp);
}
//+------------------------------------------------------------------+ |