거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Twitter에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
Experts

cheduecoglioni - MetaTrader 5용 expert

게시자:
Vladimir Karputov
조회수:
3767
평가:
(22)
게시됨:
2017.08.10 09:48
업데이트됨:
2018.02.27 13:24
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

The author of the ideaef91 (the beginning of the related discussion)

MQL5 code authorVladimir Karputov.

The EA waits for a TP or SL to trigger, and then opens a position in the opposite direction. It checks if there is enough money before sending a trade request. OnTradeTransaction.

For example, we have an open Buy position. Once TP or SL triggers, a new Sell position is opened. Then, after triggering of TP or SL, a new Buy position is opened.

A deal closure is monitored in "OnTradeTransaction":

//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction &trans,
                        const MqlTradeRequest &request,
                        const MqlTradeResult &result)
  {
//--- get transaction type as enumeration value 
   ENUM_TRADE_TRANSACTION_TYPE type=trans.type;
//--- if transaction is result of addition of the transaction in history
   if(type==TRADE_TRANSACTION_DEAL_ADD)
     {
      long     deal_entry        =0;
      long     deal_type         =0;
      string   deal_symbol       ="";
      long     deal_magic        =0;
      long     deal_time         =0;
      if(HistoryDealSelect(trans.deal))
        {
         deal_entry=HistoryDealGetInteger(trans.deal,DEAL_ENTRY);
         deal_type=HistoryDealGetInteger(trans.deal,DEAL_TYPE);
         deal_symbol=HistoryDealGetString(trans.deal,DEAL_SYMBOL);
         deal_magic=HistoryDealGetInteger(trans.deal,DEAL_MAGIC);
         deal_time=HistoryDealGetInteger(trans.deal,DEAL_TIME);
        }
      else
         return;
      if(deal_symbol==m_symbol.Name() && deal_magic==m_magic)
        {
         if(deal_entry==DEAL_ENTRY_OUT)
           {
            if(deal_type==DEAL_TYPE_BUY || deal_type==DEAL_TYPE_SELL)
              {
               if(deal_type==DEAL_TYPE_BUY)
                  m_close_pos_type=POSITION_TYPE_SELL;
               else if(deal_type==DEAL_TYPE_SELL)
                  m_close_pos_type=POSITION_TYPE_BUY;
               else
                  return;
               m_is_trade=true;
              }
           }
         else if(deal_entry==DEAL_ENTRY_IN)
           {
            m_is_trade=false;
           }
        }
     }
  }

    Check volume before OrderSend (consider the opening of a Buy position as an example):

    //+------------------------------------------------------------------+
    //| Open Buy position                                                |
    //+------------------------------------------------------------------+
    void OpenBuy(double sl,double tp)
      {
       sl=m_symbol.NormalizePrice(sl);
       tp=m_symbol.NormalizePrice(tp);
    
    //--- check volume before OrderSend to avoid "not enough money" error (CTrade)
       double check_volume_lot=m_trade.CheckVolume(m_symbol.Name(),InpLots,m_symbol.Ask(),ORDER_TYPE_BUY);
    
       if(check_volume_lot!=0.0)
         {
          if(check_volume_lot>=InpLots)
            {
             if(m_trade.Buy(InpLots,NULL,m_symbol.Ask(),sl,tp))
               {
                if(m_trade.ResultDeal()==0)
                  {
                   Print("Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
                         ", description of result: ",m_trade.ResultRetcodeDescription());
                  }
                else
                  {
                   Print("Buy -> true. Result Retcode: ",m_trade.ResultRetcode(),
                         ", description of result: ",m_trade.ResultRetcodeDescription());
                  }
               }
             else
               {
                Print("Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
                      ", description of result: ",m_trade.ResultRetcodeDescription());
               }
            }
          else
            {
             m_is_trade=false;
            }
         }
       else
         {
          m_is_trade=false;
         }
    //---
      }
    

    MetaQuotes Ltd에서 러시아어로 번역함.
    원본 코드: https://www.mql5.com/ru/code/18294

    Laguerre stripped of double stochastic Laguerre stripped of double stochastic

    Stripped Laguerre of double smoothed stochastic.

    Laguerre stripped of RSI Laguerre stripped of RSI

    Laguerre stripped of RSI "experiment".

    CandleRange CandleRange

    Two histograms in one window, showing the maximum average price deviation in points from the initial value.

    TotalPowerIndicatorX_HTF TotalPowerIndicatorX_HTF

    The TotalPowerIndicatorX indicator with the timeframe selection option available in the indicator input parameters.