2

问题是,当我的指标发出信号时,我想打开订单。我怎样才能做到这一点?

我一直在努力,iCustom()但并不令人满意。

我尝试在 EA 中使用GlobalVariableSet()指标和GlobalVariableGet()方法,但它没有正常工作。

请帮忙。

4

2 回答 2

1

语法是:

int signal = iCustom(NULL, 0, "MyCustomIndicatorName",
...parameters it takes in...,
...the buffer index you want from the custom indicator...,
...shift in bars);

假设您编写了一个名为“myMA”的自定义移动平均线指标,它仅将一个周期作为其外部变量之一。该指标根据用户提供的时间段和每根柱线的收盘价计算简单的移动平均线。该指标将其计算值存储在一个数组MAValues[]中,该数组被分配给如下索引:SetIndexBuffer(0, MAValues);

那么,要获得周期为 200 的当前柱的移动平均线,您可以编写:

double ma_current_bar = iCustom(NULL, 0, "myMA", 200, 0, 0);

然后,一旦您有了这个值,您就可以根据您确定的一些交易标准对其进行检查,并在满足时开立订单。例如,如果您想在当前柱的移动平均线等于当前卖价的情况下开多头头寸,您可以这样写:

if (ma_current_bar == Ask){
    OrderSend(Symbol(), OP_BUY, 1, Ask, *max slippage*, *sl*, *tp*, NULL, 0, 0, GREEN);
}

这只是示例代码,请勿在实时 EA 中使用。

于 2013-12-15T00:02:15.743 回答
1

语法是:

double  iCustom(
   string       symbol,           // symbol
   int          timeframe,        // timeframe
   string       name,             // path/name of the custom indicator compiled program
   ...                            // custom indicator input parameters (if necessary)
   int          mode,             // line index
   int          shift             // shift
   );

Alligator.mq4这是使用自定义鳄鱼指标的示例(在 MT 平台中应该默认可用)。

double Alligator[3];
Alligator[0] = iCustom(NULL, 0, "Alligator", 13, 8, 8, 5, 5, 3, 0, 0);
Alligator[1] = iCustom(NULL, 0, "Alligator", 13, 8, 8, 5, 5, 3, 1, 0);
Alligator[2] = iCustom(NULL, 0, "Alligator", 13, 8, 8, 5, 5, 3, 2, 0);

13, 8, 8, 5, 5, 3指标本身定义的自定义鳄鱼的相应输入参数在哪里:

//---- input parameters
input int InpJawsPeriod=13; // Jaws Period
input int InpJawsShift=8;   // Jaws Shift
input int InpTeethPeriod=8; // Teeth Period
input int InpTeethShift=5;  // Teeth Shift
input int InpLipsPeriod=5;  // Lips Period
input int InpLipsShift=3;   // Lips Shift

并且mode是指标中定义的相应行索引:

SetIndexBuffer(0, ExtBlueBuffer);
SetIndexBuffer(1, ExtRedBuffer);
SetIndexBuffer(2, ExtLimeBuffer);
于 2015-06-19T12:31:42.597 回答