需要一些帮助 - 页 8

 
qgmql:

这段代码可以吗?如果不可以,请写一些代码而不是链接,我还是很困惑。


没有https://www.mql5.com/en/forum/133792/page3#550831

给出在特定符号上交易的手数的点值

 

1.有一些买入订单被打开,一个买入挂单被放置。所有订单都是同一货币对。

2.每一个开仓的订单都是以不同的价格下的,tp20。EA是否可以修改所有开仓的订单,除了最后一个,并将其止损点改为最后一个开仓订单的止损点?

例子。

Sr    type   price     tp
1     buy    1.23950   1.23750
------------------------------
#  buylimit   1.23750   1.23550

//////////////////////////////

1    buy     1.23950   1.23550 // tp modified and now equal to 2nd tp
2    buy     1.23750   1.23550 // 2nd tp
------------------------------
#  buylimit   1.23550   1.23350

//////////////////////////////

1    buy     1.23950   1.23350 // tp modified and now equal to 3rd tp
2    buy     1.23750   1.23350 // tp modified and now equal to 3rd tp
3    buy     1.23550   1.23350 // 3rd tp
------------------------------
#  buylimit   1.23350   1.23150
 

一些混乱的情况...

//Signal Filter
#define  XXX   0
#define  AAA   1
#define  BBB   2

int SignalS = XXX;

if(SignalS & AAA !=0)
OrderSend(NULL, OP_BUY, LotSize, Ask, Slippage, SL, TP, WindowExpertName(), MagicID, 0, Blue);

旧的编辑器接受突出显示的行,但新的编辑器给出警告 "表达式不是布尔值"

我试了一下...

if(SignalS && AAA !=0)
//or
if(SignalS !=0 & AAA !=0)

现在,新的编辑器同时接受这三个代码,但是......哪一个会像突出显示的那一行一样工作呢?(更方便吗?)

PS:下面的代码也被新的编辑器所接受...

if((SignalS & AAA) !=0)

新的编辑器接受所有三个,但是......哪一个会像高亮线一样工作? 如果都是真的,那么哪一个对我来说更方便

 
qgmql: 新的编辑器接受这三种方法,但是......哪种方法的效果和高亮线一样?如果都是真的,那么哪种方法对我来说更方便
  1. 不要使用位掩码
    //Signal Filter
    #define  XXX   0
    #define  AAA   1
    #define  BBB   2
    
    int SignalS = XXX;
    
    if(SignalS & AAA !=0)
    enum eSignals = {XXX, AAA, BBB};
    
    eSignals SignalS = XXX;
    
    if(SignalS == AAA)
    
    自我记录的代码。

  2. 使用位掩码。
    Build 600以上的版本!=的优先级 高于 bitwise,并且,你必须 使用
    (SignalS & AAA) !=0
    在之前的构建中,位法和 比乘法高。

    操作

    描述

    执行顺序

    ()

    []

    .

    函数调用

    引用一个数组元素

    对结构元素的引用

    从左到右

    !

    ~

    ++

    --

    (类型)

    sizeof

    逻辑上的否定

    位数否定(补码)

    符号变化

    增一

    递减1

    类型转换

    确定字节的大小

    从右到左

    *

    /

    %

    乘法

    除法

    模块除法

    从左到右

    +

    加法

    减法

    从左到右

    <<

    >>

    左移

    右移

    从左到右

    <

    <=

    >

    >=

    小于

    小于或等于

    大于

    大于或等于

    从左到右

    ==

    !=

    等于

    不等于

    从左到右

    &

    Bitwise AND操作

    从左到右

    ^

    位数排他性OR

    从左到右

    |

    位数OR操作

    从左到右

    &&

    逻辑与操作

    从左到右

    ||

    逻辑OR操作

    从左到右

    ?:

    条件性操作符

    从右到左

    =

    *=

    /=

    %=

    +=

    -=

    <<=

    >>=

    &=

    ^=

    |=

    赋值

    带赋值的乘法

    有赋值的除法

    有赋值的模块

    有任务的加法

    有赋值的减法

    赋值左移

    赋值右移

    赋值的位数和

    赋值的排他性OR

    赋值的位数OR

    从右到左

    ,

    逗号

    从左到右

    () 函数调用 从左到右 [] 指向一个数组元素
    !      逻辑否定 从右到左 - 变换符号的操作 ++ 增加 -- 减少 ~ 位数否定(补)。
    & 位操作 AND 从左到右 | 位操作 OR ^ 位操作 Exclusive OR << 左移 >> 右移
    * 乘法 从左到右 / 除法 % 模块除法
    + 加法 从左到右 - 减法
    < 小于 从左到右 <= 小于或等于 > 大于 >= 大于或等于 == 等于!= 不等于
    || 逻辑OR 从左到右
    && 逻辑和 从左到右
    = 赋值 从右到左 += 赋值加法 -= 赋值减法 *= 赋值乘法 /= 赋值除法 %= 赋值模块 >>= 赋值右移 <<= 赋值左移 &= 赋值位元和 |= 赋值位元或 ^= 赋值独占或
    , 逗号 从左到右
 

WHRoeder 我找到了你的代码(选择最后的市场订单),并添加了高亮线来检查它的TP价格,并在以前的订单上设置相同的TP价格。

int PositionIndex;    //  <-- this variable is the index used for the loop

int TotalNumberOfOrders;   //  <-- this variable will hold the number of orders currently in the Trade pool
double Ord_TP=0;
TotalNumberOfOrders = OrdersTotal();    // <-- we store the number of Orders in the variable

for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)  //  <-- for loop to loop through all Orders . .   COUNT DOWN TO ZERO !
   {
   if( ! OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue;   // <-- if the OrderSelect fails advance the loop to the next PositionIndex
   
   if( OrderMagicNumber() == MagicNo       // <-- does the Order's Magic Number match our EA's magic number ? 
      && OrderSymbol() == Symbol()         // <-- does the Order's Symbol match the Symbol our EA is working on ? 
      && ( OrderType() == OP_BUY           // <-- is the Order a Buy Order ? 
      ||   OrderType() == OP_SELL ) )      // <-- or is it a Sell Order ?
   if(OrderTakeProfit()>0) 
   Ord_TP = OrderTakeProfit(); break;
   if(OrderTakeProfit() == Ord_TP) continue;
    OrderModify(OrderTicket(),0,0,Ord_TP,0,CLR_NONE);
      //if ( ! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage ) )               // <-- try to close the order
         //Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() );  // <-- if the Order Close failed print some helpful information 
      
   } //  end of For loop

一个额外的行...

if(OrderTakeProfit()>0) 
   Ord_TP = OrderTakeProfit(); break;
   if(OrderTakeProfit() == Ord_TP) continue;
   if(OrderTakeProfit() != Ord_TP)
    OrderModify(OrderTicket(),0,0,Ord_TP,0,CLR_NONE);

如果我说错了,请指导。

(所有的市场+挂单类型都是只买 不卖,或者只卖 不买,我希望每次新的市场订单 打开时,所有市场订单 的tp都能改变)。

这对我来说真的很困难,但我想这样做。

 
你的缩进是错误的,因为你没有使用大括号
if(OrderTakeProfit()>0) 
   Ord_TP = OrderTakeProfit(); break;
   if(OrderTakeProfit() == Ord_TP) continue;
   if(OrderTakeProfit() != Ord_TP)
    OrderModify(OrderTicket(),0,0,Ord_TP,0,CLR_NONE);
你的代码实际上是什么
if(OrderTakeProfit()>0) 
   Ord_TP = OrderTakeProfit(); 
break;
/*NOTREACHED
   if(OrderTakeProfit() == Ord_TP) continue;
   if(OrderTakeProfit() != Ord_TP)
    OrderModify(OrderTicket(),0,0,Ord_TP,0,CLR_NONE);
*/
 
对我来说,事情越来越复杂了。我想我应该从头开始写代码。我将把代码的每一部分粘贴在这里。