每个货币对的EA - 每个货币对只开一次的代码是什么?

 

对于每个货币对,我都使用一个单独的EA。

为了验证是否应该开仓,我测试是否有未结订单 "if (OrdersTotal<1)",但这将阻止所有其他货币对的开仓,我将错过机会。

换句话说。我想每个货币对只开一个头寸=多个头寸应该是可以的,但要用不同的货币对。

我应该用什么代码来代替 "if (OrdersTotal<1)"?有人能帮助我吗?请提前感谢您的帮助。

 

每个货币对 都有自己的GlobalVariable,例如 "MyEA_EURUSD"。

如果你限制EA每天进行一次交易,那么代码将是。

string sCheck = "MyEA_" + Symbol();

datetime t = TimeCurrent();

datetime tTrade = t - TimeHour(t)*60*60 - TimeMinute(t)*60 - TimeSeconds(t);

if(!GlobalVariableCheck(sCheck))GlobalVariableSet(sCheck, tTrade -PERIOD_D1 * 60);

如果(GlobalVariableGet(sCheck) < tTrade) {

OrderSend(......)。

GlobalVariableSet(sCheck, tTrade)。

}

 

对不起,我把这个问题带回了顶部,但我现在也有同样的问题。不幸的是sxTed没有回答我的问题。因为描述一个交易时间与每个货币对 的订单量是不同的。

我试图修改sxTed的线路,但我认为我在解决这个问题上失败得很厉害。

string sCheck = "MyEA_" + Symbol();      // already the first error in the code, second quotes should be at the end of the line.

//I would correct this one to:
string sCheck = "MyEA_ + Symbol()";          //However symbol() is not a function anymore ??


int start ()
{

// Closing Orders here


if(!GlobalVariableCheck(sCheck))                    //checking Globalvariable, GV available so it becomes true (independently of what kind of GV we have)...

GlobalVariableSet(sCheck, Symbol() );               //.. assigning a new GlobalVariable to the function of the current symbol the EA is attached on (does it actually work like this?)

if(GlobalVariableGet(sCheck) == Symbol()) {         // checking if our Symbol is the one which the EA is attached on --> becomes true...


// Order Criteria (Open trades here)

// What now? Actually i'm missing any kind of numbers or smth that limits the open orders per currency pair.
 
mqlfor:

对于每个货币对,我都使用一个单独的EA。

为了验证是否应该开仓,我测试是否有未结订单 "if (OrdersTotal<1)",但这将阻止所有其他货币对的开仓,我将错过机会。

换句话说。我想每个货币对只开一个头寸=多个头寸应该是可以的,但要用不同的货币对。

我应该用什么代码来代替 "if (OrdersTotal<1)"?有人能帮助我吗?请提前感谢您的帮助。


int total=OrdersTotal(); int count = 0; int magno = 12345; for(int pos=0;pos<total;pos++) { if(OrderSelect(pos,SELECT_BY_POS) == false) continue; if (OrderMagicNumber()!=
If (count < 1) { // do something - open order perhaps
} Does this help?
 
texto:

这有帮助吗?
你不需要神奇的数字......只要使用符号就可以了。
 
texto:

这有什么帮助吗?
int total=OrdersTotal();

是否限制所有货币对 的总未平仓合约?

我插入了你的代码,如下所示

int total=OrdersTotal();
int count = 0;
for(int pos=0;pos<total;pos++) 
{
    if(OrderSelect(pos,SELECT_BY_POS) == false) continue;
    if (OrderSymbol() != Symbol()) continue;
    count++;
}

if (Sell_1_1 < Sell_1_2 && CloseSell1_1 > CloseSell1_2 && count < 1) Order = SIGNAL_SELL; // Trigger for Sell

if (Buy_1_1 > Buy_1_2 && CloseBuy1_1 < CloseBuy1_2 && count < 1) Order = SIGNAL_BUY;    // Trigger for Buy


if (order == SIGNAL_BUY)
{
OrderSend(...)
}   

但它仍然只开了一个交易。sxTed想用他的全局变量告诉我们什么?

 
grey.unit:

是否限制所有货币对的总未平仓合约?

我插入了你的代码,如下所示

但它仍然只开了一个交易。sxTed想用他的全局变量告诉我们什么?

你的EA有多少个图表?
 
RaptorUK:
你的EA有多少个图表?
为了测试代码,我打开了5个图表,但我希望能打开N个图表。数量并不重要。
 
grey.unit:
为了测试该代码,我打开了5个图表,但我想打开N个图表。数量并不重要。
你是否在每个货币对上逐一测试过你的代码,以确保你的EA在每个货币对上都能打开交易,而不管其他货币对发生了什么? 也许你的EA只打开一个交易,因为它只在一个特定的货币对上打开交易 . .
 
当然,我做了。当我在欧元兑日元上有一笔交易,我手动关闭它,然后也许另一个EA在另一个货币对上开了一个交易。
 
mqlfor:

对于每个货币对,我都使用一个单独的EA。

为了验证是否应该开仓,我测试是否有未结订单 "if (OrdersTotal<1)",但这将阻止所有其他货币对的开仓,我将错过机会。

换句话说。我想每个货币对只开一个头寸=多个头寸应该是可以的,但要用不同的货币对。

我应该用什么代码来代替 "if (OrdersTotal<1)"?有人能帮助我吗?请提前感谢您的帮助。

代码是这样的。

 int Total_Order = OrdersTotal();
 for (pos = 0; pos <= Total_Order; pos ++)
      {
      if (OrderSelect (pos, SELECT_BY_POS) == true)
        {
        if (OrderSymbol () == Symbol ())
          {
          Print (":( Sorry already have that symbol opened ");
          // get outta here do something else
          break ;
          }
          else
          {
          Print ("No order opened for this symbol");
          Print ("Let\'s call waitress and order some drink :)");
          // do some order then break out and get out
          }
         }
       }
原因: