想在M1周期圖形求出開盤前5根Close的均價
作者:開拓者 TB 來源:cxh99.com 發布時間:2016年08月30日
- 咨詢內容:
Params
Numeric FirstTime(9.04);
Vars
NumericSeries FirstPrice;
Begin
If(Time<FirstPrice/100)
{
FirstPrice=Close;
}
Else
{
If(Time==FirstPrice/100)
{
FirstPrice=Average(Close,BarsSinceToday+1);
}
Else
{
FirstPrice=FirstPrice[1];
}
}
Commentary("BarsSinceToday:"+Text(BarsSinceToday+1));//當天開盤的第一根K線BarsSinceToday==0;
PlotNumeric("FirstPrice",FirstPrice);
Commentary("Time:"+Text(Time));
End
顯示FirstPrice都是等于0,是什么原因???請各位高手、老師指點。
- TB技術人員:
這樣改應該是沒有問題的
Params
Numeric FirstTime(9.04);
Vars
NumericSeries FirstPrice;
Numeric FirstBars;
Begin
FirstBars=BarsSinceToday+1;
If(Time<FirstTime/100)
{
FirstPrice=Close;
}
Else
{
If(Time==FirstTime/100)
{
FirstPrice=Average(Close,FirstBars);//當FirstBars是不確定的變量時,則必須使用Average;
}
Else
{
FirstPrice=FirstPrice[1];
}
}
Commentary("BarsSinceToday:"+Text(BarsSinceToday+1));//當天開盤的第一根K線BarsSinceToday==0;
PlotNumeric("FirstPrice",FirstPrice);
End
寫代碼要細心咯,很多地方邏輯沒有錯,有筆誤也搞不出來。
- TB客服:
謝謝指點,我看了之后,想死的心都有了