//--------------------------------------------------------------------void OPENORDER(string ord)
{
double priceL=m_symbol.Ask();
if(ord=="Sell")
//--- check for free moneyif(m_account.FreeMarginCheck(Symbol(),ORDER_TYPE_BUY,my_lot,priceL)<0.0)
printf("We have no money. Free Margin = %f",m_account.FreeMargin());
elseif(!m_trade.Sell(my_lot,Symbol(),m_symbol.Bid(),my_SL,my_TP,""))
Print("BUY_STOP -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of Retcode: ",m_trade.ResultRetcodeDescription(),
", ticket of order: ",m_trade.ResultOrder()); // Если sell, то не открываемсяdouble priceS=m_symbol.Bid();
if(ord=="Buy")
//--- check for free moneyif(m_account.FreeMarginCheck(Symbol(),ORDER_TYPE_SELL,my_lot,priceS)<0.0)
printf("We have no money. Free Margin = %f",m_account.FreeMargin());
elseif(!m_trade.Buy(my_lot,Symbol(),m_symbol.Ask(),my_SL,my_TP,""))
Print("Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription(),
", ticket of deal: ",m_trade.ResultDeal());
return;
}
double iMAGet(constint handle,constint index)
{
double MA[];
ArraySetAsSeries(MA,true);
//--- reset error codeResetLastError();
//--- fill a part of the iMABuffer array with values from the indicator buffer that has 0 indexif(CopyBuffer(handle,0,0,index+1,MA)<0)
{
//--- if the copying fails, tell the error codePrintFormat("Failed to copy data from the iMA indicator, error code %d",GetLastError());
//--- quit with zero result - it means that the indicator is considered as not calculatedreturn(0.0);
}
return(MA[index]);
}
//+------------------------------------------------------------------+//| Refreshes the symbol quotes data |//+------------------------------------------------------------------+bool RefreshRates()
{
//--- refresh ratesif(!m_symbol.RefreshRates())
return(false);
//--- protection against the return value of "zero"if(m_symbol.Ask()==0 || m_symbol.Bid()==0)
return(false);
//---return(true);
}
//+------------------------------------------------------------------+//| Get Time for specified bar index |//+------------------------------------------------------------------+datetimeiTime(constint index,string symbol=NULL,ENUM_TIMEFRAMES timeframe=PERIOD_CURRENT)
{
if(symbol==NULL)
symbol=Symbol();
if(timeframe==0)
timeframe=Period();
datetime Time[];
datetime time=0;
ArraySetAsSeries(Time,true);
int copied=CopyTime(symbol,timeframe,index,1,Time);
if(copied>0)
time=Time[0];
return(time);
}
//+------------------------------------------------------------------+//| Get value of buffers |//+------------------------------------------------------------------+bool iGetArray(constint handle,constint buffer,constint start_pos,
constint count,double &arr_buffer[])
{
bool result=true;
if(!ArrayIsDynamic(arr_buffer))
{
PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__);
return(false);
}
ArrayFree(arr_buffer);
//--- reset error codeResetLastError();
//--- fill a part of the iBands array with values from the indicator bufferint copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer);
if(copied!=count)
{
//--- if the copying fails, tell the error codePrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d",
__FILE__,__FUNCTION__,count,copied,GetLastError());
//--- quit with zero result - it means that the indicator is considered as not calculatedreturn(false);
}
return(result);
}
void TrailingOrder()
{
if(InpTrailingOrderLimit==0)
return;
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positionsif(m_position.SelectByIndex(i))
if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
{
if(m_position.PositionType()==POSITION_TYPE_BUY)
{
if(m_position.PriceCurrent()-m_position.PriceOpen()>ExtTrailingOrderLimit+ExtTrailingOrderStep)
if(m_position.StopLoss()<m_position.PriceCurrent()-(ExtTrailingOrderLimit+ExtTrailingOrderStep))
{
if(!m_trade.PositionModify(m_position.Ticket(),
m_symbol.NormalizePrice(m_position.PriceCurrent()-ExtTrailingOrderLimit),
m_position.TakeProfit()))
Print("Modify ",m_position.Ticket());
OPENORDER("Buy");
}
}
else
{
if(m_position.PriceOpen()-m_position.PriceCurrent()>ExtTrailingOrderLimit+ExtTrailingOrderStep)
if((m_position.StopLoss()>(m_position.PriceCurrent()+(ExtTrailingOrderLimit+ExtTrailingOrderStep))) ||
(m_position.StopLoss()==0))
{
if(!m_trade.PositionModify(m_position.Ticket(),
m_symbol.NormalizePrice(m_position.PriceCurrent()+ExtTrailingOrderLimit),
m_position.TakeProfit()))
Print("Modify ",m_position.Ticket());
OPENORDER("Sell");
}
}
}
}
void Trailing()
{
if(InpTStop==0)
return;
if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
{
if(m_position.PositionType()==POSITION_TYPE_BUY)
{
if(m_position.PriceCurrent()-m_position.PriceOpen()>ExtTStop+ExtTStep)
if(m_position.StopLoss()<m_position.PriceCurrent()-(ExtTStop+ExtTStep))
{
if(!m_trade.PositionModify(m_position.Ticket(),
m_symbol.NormalizePrice(m_position.PriceCurrent()-ExtTStepShift),
m_position.TakeProfit()))
Print("Modify ",m_position.Ticket(),
" Position -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
}
}
else
{
if(m_position.PriceOpen()-m_position.PriceCurrent()>ExtTStop+ExtTStep)
if((m_position.StopLoss()>(m_position.PriceCurrent()+(ExtTStop+ExtTStep))) ||
(m_position.StopLoss()==0))
{
if(!m_trade.PositionModify(m_position.Ticket(),
m_symbol.NormalizePrice(m_position.PriceCurrent()+ExtTStepShift),
m_position.TakeProfit()))
Print("Modify ",m_position.Ticket(),
" Position -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription());
}
}
}
}
你好。
你能告诉我是否有可能在EA参数中增加一列评论或解释...???
谢谢你。
是的,但你需要源头。
谢谢你!我不知道MQL有这方面的功能。我正准备创造我自己的。但在此之前,我决定在论坛上询问。
你好。
你能告诉我是否有可能在EA参数中增加一列评论或解释...???
谢谢你。
你什么时候才能学会阅读文件?
这是研究语言的错误方法所造成的后果。如果你用文档工作,而不是用编码从.........,阅读资源上的帮助,你会读到它。而且你不用问。
我知道我的回答会被人说教......。你知道,就像你做的...我想我说过。"谢谢你",但没有...你必须写一些东西...如果你从文档中知道了这个功能,那就好办了。但是,如果你不正确地了解代码,你可以上上下下地研究MQL文档,但在实践中用处不大......!
我无意中发现了这个错误
创建两个坐标略有不同的相同的按钮
它看起来像这样
但结果是,只有第一个按钮对OnChartEvent 有反应,第二个没有。
我是这样做的,当跟踪一个合同时,因为止盈,等于500,止损等于150。
我不了解MQL5,但我认为
我无意中发现了这个错误
创建两个坐标略有不同的相同的按钮
它看起来像这样
但结果是,只有第一个按钮对OnChartEvent 有反应,第二个没有。
你能看到处理程序中的代码吗?
还有,为什么参数中会有-73,这不是很清楚......?
我可以看到处理程序中的代码吗?
还有,为什么参数里有-73,不是很清楚......?
它没有发出任何错误。
在这些坐标中,按钮是颠倒的,因为按钮的长度是从X点开始计算的+/-。