我试图访问MQL5中之前的值或图表的随机性。但我只知道如何计算当前。
我想做的是:
int stochastic_output = iStochastic(_Symbol,PERIOD_M1,5,3,3,MODE_SMA,STO_LOWHIGH);
但我不知道如何获得前15支蜡烛的价值或之前的3分钟。请帮助我如何获得它。
答案 0 :(得分:1)
//--- inputs
input int Candles=15;
input int NeededCandle=3;
// --- global variables
int stoch_handle;
int OnInit(){
stoch_handle=iStochastic(_Symbol,PERIOD_M1,5,3,3,MODE_SMA,STO_LOWHIGH);
if(stoch_handle==INVALID_HANDLE)
return(INIT_FAILED);
}
void OnTick(){
double main[],signal[];
ArrayResize(main,Candles);
ArraySetAsSeries(main,true);
ArrayResize(signal,Candles);
ArraySetAsSeries(signal,true);
if(CopyBuffer(stoch_handle,MAIN_LINE,0,Candles,main)!=Candles)
return;
if(CopyBuffer(stoch_handle,SIGNAL_LINE,0,Candles,signal)!=Candles)
return;
printf("%i - main=%.2f, signal=%.2f",__LINE__,main[NeededCandle-1],signal[NeededCandle-1]);
}
答案 1 :(得分:1)
有一种简单的方法可以做到这一点。
您需要的是使用@Query("select new map (a.slocation) from Account a where a.slocation !=null group by slocation")
复制前15支蜡烛的每分钟数据
参见示例:
CopyBuffer
以上输出:
double K[],D[];
ArraySetAsSeries(K,true);
ArraySetAsSeries(D,true);
int stochastic_output = iStochastic(_Symbol,PERIOD_M1,5,3,3,MODE_SMA,STO_LOWHIGH);
CopyBuffer(stochastic_output,0,0,15,K);
CopyBuffer(stochastic_output,1,0,15,D);
Print("K size: ",ArraySize(K));
Print("D size: ",ArraySize(D));
希望这会对你有所帮助。