거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Twitter에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
당사 팬 페이지에 가입하십시오
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
- 게시자:
- Vladimir Karputov
- 조회수:
- 6055
- 평가:
- 게시됨:
- 2017.01.26 09:17
- 업데이트됨:
- 2018.02.16 11:03
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
Author of the idea — Collector, author of the MQL5 code — barabashkakvn.
Signals from the iADX (Average Directional Movement Index) indicator.
Making decisions about opening and closing positions based on the iADX values:
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double ADXP,ADXC,ADXDIPP;
double ADXDIPC,ADXDIMP,ADXDIMC;
ADXP = iADXGet(MAIN_LINE, 2);
ADXC = iADXGet(MAIN_LINE, 1);
ADXDIPP = iADXGet(PLUSDI_LINE, 2);
ADXDIPC = iADXGet(PLUSDI_LINE, 1);
ADXDIMP = iADXGet(MINUSDI_LINE, 2);
ADXDIMC = iADXGet(MINUSDI_LINE, 1);
int total=0;
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions
if(m_position.SelectByIndex(i))
if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
total++;
if(total==0)
{
//--- no opened positions identified
if(m_account.FreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ",m_account.FreeMargin());
return;
}
//--- check for long position (BUY) possibility
if((ADXP<ADXC) && (ADXDIPP<ADXP) && (ADXDIPC>ADXC))
{
if(!RefreshRates())
return;
if(m_trade.Buy(Lots,m_symbol.Name(),m_symbol.Ask(),m_symbol.Bid()-ExtStopLoss*Point(),
m_symbol.Ask()+ExtTakeProfit*Point(),"adx sample"))
{
Print("BUY order opened : ",m_trade.ResultPrice());
}
else
{
Print("Error opening BUY. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription(),
", ticket of deal: ",m_trade.ResultDeal());
return;
}
}
//--- check for short position (SELL) possibility
if((ADXP<ADXC) && (ADXDIMP<ADXP) && (ADXDIMC>ADXC))
{
if(!RefreshRates())
return;
if(m_trade.Sell(Lots,m_symbol.Name(),m_symbol.Bid(),m_symbol.Ask()+ExtStopLoss*Point(),
m_symbol.Bid()-ExtTakeProfit*Point(),"adx sample"))
{
Print("SELL order opened : ",m_trade.ResultPrice());
}
else
Print("Error opening Sell. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription(),
", ticket of deal: ",m_trade.ResultDeal());
return;
}
return;
}
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions
if(m_position.SelectByIndex(i))
if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
{
if(m_position.PositionType()==POSITION_TYPE_BUY) // long position is opened
{
if(ADXP>ADXC && ADXDIPP>ADXP && ADXDIPC<ADXC)
{
m_trade.PositionClose(m_position.Ticket()); // close position
return; // exit
}
if(ExtTrailingStop>0)
{
if(!RefreshRates())
return;
if(m_symbol.Bid()-m_position.PriceOpen()>Point()*ExtTrailingStop)
{
if(m_position.StopLoss()<m_symbol.Bid()-Point()*ExtTrailingStop)
{
m_trade.PositionModify(m_position.Ticket(),m_symbol.Bid()-Point()*ExtTrailingStop,
m_position.TakeProfit());
return;
}
}
}
}
else
{
if(ADXP>ADXC && ADXDIMP>ADXP && ADXDIMC<ADXC)
{
m_trade.PositionClose(m_position.Ticket()); // close position
return; // exit
}
if(ExtTrailingStop>0)
{
if(!RefreshRates())
return;
if((m_position.PriceOpen()-m_symbol.Ask())>(Point()*ExtTrailingStop))
{
if((m_position.StopLoss()>(m_symbol.Ask()+Point()*ExtTrailingStop)) ||
(m_position.StopLoss()==0))
{
m_trade.PositionModify(m_position.Ticket(),m_symbol.Ask()+Point()*ExtTrailingStop,
m_position.TakeProfit());
return;
}
}
}
}
}
return;
}
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double ADXP,ADXC,ADXDIPP;
double ADXDIPC,ADXDIMP,ADXDIMC;
ADXP = iADXGet(MAIN_LINE, 2);
ADXC = iADXGet(MAIN_LINE, 1);
ADXDIPP = iADXGet(PLUSDI_LINE, 2);
ADXDIPC = iADXGet(PLUSDI_LINE, 1);
ADXDIMP = iADXGet(MINUSDI_LINE, 2);
ADXDIMC = iADXGet(MINUSDI_LINE, 1);
int total=0;
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions
if(m_position.SelectByIndex(i))
if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
total++;
if(total==0)
{
//--- no opened positions identified
if(m_account.FreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ",m_account.FreeMargin());
return;
}
//--- check for long position (BUY) possibility
if((ADXP<ADXC) && (ADXDIPP<ADXP) && (ADXDIPC>ADXC))
{
if(!RefreshRates())
return;
if(m_trade.Buy(Lots,m_symbol.Name(),m_symbol.Ask(),m_symbol.Bid()-ExtStopLoss*Point(),
m_symbol.Ask()+ExtTakeProfit*Point(),"adx sample"))
{
Print("BUY order opened : ",m_trade.ResultPrice());
}
else
{
Print("Error opening BUY. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription(),
", ticket of deal: ",m_trade.ResultDeal());
return;
}
}
//--- check for short position (SELL) possibility
if((ADXP<ADXC) && (ADXDIMP<ADXP) && (ADXDIMC>ADXC))
{
if(!RefreshRates())
return;
if(m_trade.Sell(Lots,m_symbol.Name(),m_symbol.Bid(),m_symbol.Ask()+ExtStopLoss*Point(),
m_symbol.Bid()-ExtTakeProfit*Point(),"adx sample"))
{
Print("SELL order opened : ",m_trade.ResultPrice());
}
else
Print("Error opening Sell. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription(),
", ticket of deal: ",m_trade.ResultDeal());
return;
}
return;
}
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions
if(m_position.SelectByIndex(i))
if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
{
if(m_position.PositionType()==POSITION_TYPE_BUY) // long position is opened
{
if(ADXP>ADXC && ADXDIPP>ADXP && ADXDIPC<ADXC)
{
m_trade.PositionClose(m_position.Ticket()); // close position
return; // exit
}
if(ExtTrailingStop>0)
{
if(!RefreshRates())
return;
if(m_symbol.Bid()-m_position.PriceOpen()>Point()*ExtTrailingStop)
{
if(m_position.StopLoss()<m_symbol.Bid()-Point()*ExtTrailingStop)
{
m_trade.PositionModify(m_position.Ticket(),m_symbol.Bid()-Point()*ExtTrailingStop,
m_position.TakeProfit());
return;
}
}
}
}
else
{
if(ADXP>ADXC && ADXDIMP>ADXP && ADXDIMC<ADXC)
{
m_trade.PositionClose(m_position.Ticket()); // close position
return; // exit
}
if(ExtTrailingStop>0)
{
if(!RefreshRates())
return;
if((m_position.PriceOpen()-m_symbol.Ask())>(Point()*ExtTrailingStop))
{
if((m_position.StopLoss()>(m_symbol.Ask()+Point()*ExtTrailingStop)) ||
(m_position.StopLoss()==0))
{
m_trade.PositionModify(m_position.Ticket(),m_symbol.Ask()+Point()*ExtTrailingStop,
m_position.TakeProfit());
return;
}
}
}
}
}
return;
}
Result on EURUSD M15, from 2016.06.01 to 2016.11.24, initial deposit - 10000:
MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/17030
![Exp_Fractal_ADX_Cloud](https://c.mql5.com/i/code/expert.png)
The trading system based on crossing of the DI+ and DI- lines of the Fractal_ADX_Cloud indicator.
![Fractal_ADX_HTF](https://c.mql5.com/i/code/indicator.png)
The Fractal_ADX indicator with the timeframe selection option available in the input parameters.
![TREND_alexcud v_2](https://c.mql5.com/i/code/expert.png)
The EA uses 15 IMA indicators and two iAC indicators.
![10 pips](https://c.mql5.com/i/code/expert.png)
Pipsing EA. Indicators are not used.