简体   繁体   English

使用 MQL4 限制每对交易

[英]Limit Trade On Each Pair Using MQL4

I want to limit the number or trades/orders in MT4 using my EA in MQL4.我想在 MQL4 中使用我的 EA 来限制 MT4 中的数量或交易/订单。 I want the limit on each pair not on all Pairs, like: If the condition / logic match then 2 trades will be executed on Each currency where the EA is attached.我想要每对的限制而不是所有的对,例如:如果条件/逻辑匹配,那么将在 EA 附加的每种货币上执行 2 笔交易。

This is the code i tried, but it limits the trades on all pairs where EA has been attached.这是我尝试过的代码,但它限制了所有附加了 EA 的货币对的交易。

    //+------------------------------------------------------------------+
//|                                                         psar.mq4 |
//|                                                              MSZ |
//|                                                             nill |
//+------------------------------------------------------------------+
#property copyright "MSZ"
#property link      "nill"
#property version   "1.00"
#property strict
#define MAX_ORDERS 5
input int TP=10;
input int SL=30;
input double lot=1;
void OnTick()
  {
//---
   double SAR;
static int Ticket=0;
SAR=iSAR(Symbol(),0,0.02,0.2,0);
if(OrdersTotal()<=MAX_ORDERS)
{
    if(SAR>Open[0])
    {
    Ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,10,Ask+SL*Point,Ask-TP*Point,"Done By MSZ.Inc");
         if(Ticket<0)
         {
         Alert("Error In Opening Order");
         }
         else
         {
      Alert("Sell Order Executed");
     }
      //Alert("Its Sell Signal");

    }

   else if(SAR<Open[0])
    {
     Ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,10,Bid-SL*Point,Bid+TP*Point,"Done By MSZ.Inc");
         if(Ticket<0)
         {
         Alert("Error In Opening Order");
         }
         else
         {
      Alert("Buy Order Executed");
     }
    }
    }
    else
    {
    Alert("Orders Limits reached");
    }
  }
//+------------------------------------------------------------------+

I want that it will execute 5 orders on Each Chart where the EA is attached.我希望它会在附加了 EA 的每个图表上执行 5 个订单。

**if(OrdersTotal()<=MAX_ORDERS)**

This may send up to 6 trades due to the = sign.由于 = 符号,这可能会发送多达 6 笔交易。 It will also top up trades either buy or sell at any time until the <= condition is met.它还会在满足<=条件之前随时补足买入或卖出交易。 To clarify, are you meaning to hedge?澄清一下,你的意思是对冲吗? Your MAX_ORDERS is defined as a pre-processor directive.您的MAX_ORDERS被定义为预处理器指令。 input int MAX_ORDERS =5; to be able to change this value.能够改变这个值。

#define MAX_ORDERS 5 在 ea 脚本开头输入 this 后是否需要在脚本后面添加 **if(OrdersTotal()<=MAX_ORDERS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找到一对可以使用4个操作到达另一对的整数 - Find a pair of intergers that can be reached to another pair using 4 operations 检查是否有可能以每对连续的字符串相差 1 个字符的方式排列字符串 - Check if it's possible to arrange strings in a way that each consecutive pair of strings differ by 1 character 使用字典键对列进行分类-多值对 - Categorize a column using a Dictionary key - multiple values pair 交易日志中的连续分组加权平均值和总和 - consecutive grouped weighted avereages and sums in a trade log 使用 class 或 object 设置 object 属性的限制并触发新的 object 创建 - Using class or object to set limit on object property and trigger new object creation 使用Ruby使哈希值相互查找 - Making hashes find each other by their values using Ruby Python 使用 For Each 循环从列表中删除项目的逻辑错误 - Python Logic Error using a For Each Loop to Remove items from List 如何使用 java 打印字符串中每个字符的计数 - how to print count of each character in a string using java 将差异最小的用户与PHP / Javascript配对 - Pair users with smallest difference values with PHP / Javascript 如何简化检查一对数字是(1,2)还是(2,1)? - How to simplify checking if a pair of numbers is (1,2) or (2,1)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM