求编程高手帮忙刚学编程遇到个问题求教,先多谢了

 

我学习mql4编程时间不长,之前没有编程基础,在网上找了个《MQL4课程》学习之后对ea编程有了初步的了解,但遇到一个问题,教程中用来举例而编写了一个简单的指标,指标的全部代码是:

//+------------------------------------------------------------------+
//| 我的第一个指标.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
string short_name = "我的第一个指标正在运行!";
IndicatorShortName(short_name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//---- check for possible errors
if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
if (counted_bars>0) counted_bars--;
int pos=Bars-counted_bars;
double dHigh , dLow , dResult;
Comment("嗨,在主窗口这儿!");
//---- main calculation loop
while(pos>=0)
{
dHigh = High[pos];
dLow = Low[pos];
dResult = dHigh - dLow;
ExtMapBuffer1[pos]= dResult ;
pos--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
代码的意思我大体都懂,其中有两句代码
if (counted_bars>0) counted_bars--;和
int pos=Bars-counted_bars;

比如图表上有20根k线,第20根k线是正在跳动的k线,想恳请高手帮忙把例子中的值代入上面两句代码中

恳请高手帮忙,在此我先多谢了
 
huiyoucai:

我学习mql4编程时间不长,之前没有编程基础,在网上找了个《MQL4课程》学习之后对ea编程有了初步的了解,但遇到一个问题,教程中用来举例而编写了一个简单的指标,指标的全部代码是:

代码的意思我大体都懂,其中有两句代码
if (counted_bars>0) counted_bars--;和
int pos=Bars-counted_bars;

比如图表上有20根k线,第20根k线是正在跳动的k线,想恳请高手帮忙把例子中的值代入上面两句代码中

恳请高手帮忙,在此我先多谢了

1. 技術策略分析程式交易檢驗代(EXCEL VBAMatlabTradeStationHTS、奇孤)

2. 程式交易(Programming Trading)系統開發

3. 策略交易(Stratragy Trading)系統開發

4. 系統交易(System Trading)系統開發

5. 演算法交易

6. Excel-VBA巨集在財務金融程式開發

7. Matlab財務金融程式開發

8. 網路上金融資料收集程式(財務報表、歷史資料)

9. 客製金融相關的系統

10. 客製自動下單機

11. 客製跟單機

12. MetaTrader 4 慧能交易(EA)、腳本(Script)、自定指標(Indicator)

13. MetaTrader 4 DDL跟單機、Log檔跟單機(多重帳號、不同的平台(MetaTrader 4MetaTrader GCGForex.comAlpari UKMIG)

14. MetaTrader 4 Script Utils (公用程式集

E-MAIL : Jason__chang33@hotmail.com

MSN : Jason__chang33@hotmail.com

Skype : KueiTsai

Messager : Jason.chang@yahoo.com.tw

QQ : 896946829

Mobil : +886930740129

 

我自己有写好的程式,回测都没问题,但是实际去下单,它该进场反而没进场,是不是应该进场时,是不是要用滑价的方式进场?
就是也要把滑价的问题也考虑进去吗?

 

k线有两种形式,一种是已经形成的,一种是为形成的,其实这有了IndicatorCounted()就是为了区分已经形成的K图,bars是有多少K图就算多少K图,包括正在形成的新的K图,把这个理解了,其他就是计算的问题了。

他们的手册翻译有一些问题,不好理解。可以联系:1031130533

原因: