麻烦问下我的bias指标只有刚设置的时候会执行,但是到下一个k线形成后就不会更新新的bias指标了,我是个菜鸟,不过也试过很多办法都不行,请问这是为什么,请不吝赐教下,万分感谢!
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_separate_window//
#property indicator_buffers 3//
#property indicator_plots 3
//--- plot fast
#property indicator_label1 "fast"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrBlanchedAlmond
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- plot medium
#property indicator_label2 "medium"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrYellow
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
//--- plot slow
#property indicator_label3 "slow"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrFuchsia
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
//--- input parameters
input int day1st=34;
input int day2nd=55;
input int day3rd=89;
//--- indicator buffers
double fastBuffer[];
double mediumBuffer[];
double slowBuffer[];//
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0,fastBuffer);
SetIndexBuffer(1,mediumBuffer);
SetIndexBuffer(2,slowBuffer);
return(INIT_SUCCEEDED);
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
if(rates_total<day1st || rates_total<day2nd || rates_total<day3rd)
{
return(0);
}
int i=0;
int limit;
limit=rates_total-prev_calculated;
if(prev_calculated>0)limit++;
//double Ask;
// double Bid;
//if(iOpen(NULL,0,0)==Ask || iOpen(NULL,0,0)==Bid)
for(i=0;i<=limit;i++)
{
fastBuffer= 100*(Close- iMA(NULL,0,day1st,0,MODE_SMA,PRICE_CLOSE,i))/iMA(NULL,0,day1st,0,MODE_SMA,PRICE_CLOSE,i);
mediumBuffer= 100*(Close- iMA(NULL,0,day2nd,0,MODE_SMA,PRICE_CLOSE,i))/iMA(NULL,0,day2nd,0,MODE_SMA,PRICE_CLOSE,i);
slowBuffer= 100*(Close- iMA(NULL,0,day3rd,0,MODE_SMA,PRICE_CLOSE,i))/iMA(NULL,0,day3rd,0,MODE_SMA,PRICE_CLOSE,i);
}
return(rates_total);
}
|