【问题标题】:Why my OrderSend function returns a price higher than the candle high price?为什么我的 OrderSend 函数返回的价格高于蜡烛最高价?
【发布时间】:2020-07-06 22:55:24
【问题描述】:

我正在尝试编写具有 2 个移动平均线的 Ea,并且我希望它在它们交叉时发送订单。 卖单看起来不错,但对于 1 分钟图表中的买单,我用来发送订单的卖价不在蜡烛价格范围内。实际上,我在 OrderEntry 函数之前和 OrderSend() 之后执行了 Print("Ask=",Ask)。它们等于蜡烛上方的某个价格 - [高] 和之前的蜡烛 - [关闭] 但是当我尝试更高的时间范围时,它会更接近蜡烛,并且在每日时间范围内,订单的要价将在蜡烛范围内(高-低)。有人知道为什么会这样吗?

void CheckForMaTrade(){
   
   double PreviousFast = iMA(NULL,0,FastMaPeriod,FastMaShift,FastMaMethod,FastMaAppliedTo,2);
   double CurrentFast = iMA(NULL,0,FastMaPeriod,FastMaShift,FastMaMethod,FastMaAppliedTo,1);   
   double PreviousSlow = iMA(NULL,0,SlowMaPeriod,SlowMaShift,SlowMaMethod,SlowMaAppliedTo,2);   
   double CurrentSlow = iMA(NULL,0,SlowMaPeriod,SlowMaShift,SlowMaMethod,SlowMaAppliedTo,1);
   
   if(PreviousFast<PreviousSlow && CurrentFast>CurrentSlow)
      OrderEntry(0);       
   if(PreviousFast>PreviousSlow && CurrentFast<CurrentSlow)
      OrderEntry(1);
}

void OrderEntry(int direction){
   if(direction == 0){
      double bsl=0;
      double btp=0;
         if(StopLoss != 0)
            bsl = Ask-(StopLoss*pips);   
         if(TakeProfit != 0)
            btp = Ask+(TakeProfit*pips);
         if(OpenOrdersThisPair(Symbol()) < 10 )
            OrderSend(NULL,OP_BUY,LotSize,Ask,0,bsl,btp,NULL,MagicNumber,0,Gold);        
   } 

enter image description here

【问题讨论】:

    标签: mql4


    【解决方案1】:

    在 MT4 中,蜡烛图仅由 BID 价格绘制。不考虑 ASK 价格。因此,Ask > 最高出价是可能的。

    【讨论】:

    • 感谢 Daniel Kniaz 提供此信息。我在测试仪中对其进行了测试,但后来我在模拟账户上使用了它,它工作正常,但我不知道为什么。谢谢人:-)
    猜你喜欢
    • 1970-01-01
    • 2020-10-02
    • 2022-07-22
    • 2020-01-28
    • 2021-05-10
    • 1970-01-01
    • 1970-01-01
    • 2016-01-26
    • 2016-09-25
    相关资源
    最近更新 更多