bool Buy_Condition = (close1 > EMA0[0]);
{
if(Buy_Condition) //Buy
{
if(!RefreshRates())
return;
TimeBar=time_0;
my_TP = m_symbol.Ask() + ExtTakeProfit*Point();
my_SL = m_symbol.Ask() - ExtStopLoss*Point();
my_lot = Lots;
OPENORDER("Sell");
}
}
bool Sell_Condition = (close1 < EMA0[0]);
{
if(Sell_Condition )
{
if(!RefreshRates())
return;
TimeBar=time_0;
my_TP = m_symbol.Bid() - ExtTakeProfit*Point();
my_SL = m_symbol.Bid() + ExtStopLoss*Point();
my_lot= Lots;
OPENORDER("Buy");
}
}
}
if(colorBuffer[m_bar_current+1]>colorBuffer[m_bar_current] ) //Buy
{
if(!RefreshRates())
return;
TimeBar=time_0;
CLOSEORDER("Sell");
}
if(colorBuffer[m_bar_current+1]<colorBuffer[m_bar_current] ) //Sell
{
if(!RefreshRates())
return;
TimeBar=time_0;
CLOSEORDER("Buy");
}
return;
}//--------------------------------------------------------------------void CLOSEORDER(string ord)
{
for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of open positionsif(m_position.SelectByIndex(i))
if(m_position.Symbol()==Symbol() && m_position.Magic()==m_magic)
{
if(m_position.PositionType()==POSITION_TYPE_BUY && ord=="Buy")
m_trade.PositionClose(m_position.Ticket()); // Close Buyif(m_position.PositionType()==POSITION_TYPE_SELL && ord=="Sell")
m_trade.PositionClose(m_position.Ticket()); // Close Sell
}
}
//--------------------------------------------------------------------void OPENORDER(string ord)
{
if(ord=="Sell")
if(all_positions==1)
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positionsif(m_position.SelectByIndex(i))
if(m_position.PositionType()==POSITION_TYPE_SELL)
//if(m_position.PositionType()==POSITION_TYPE_SELL)return; // Если buy, то не открываемсяif(!m_trade.Sell(my_lot,Symbol(),m_symbol.Bid(),my_SL,my_TP,""))
Print("Buy -> false. Result Retcode: ",m_trade.ResultRetcode(),
", description of result: ",m_trade.ResultRetcodeDescription(),
", ticket of deal: ",m_trade.ResultDeal());
if(ord=="Buy")
if(all_positions==1)
for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positionsif(m_position.SelectByIndex(i))
//if(m_position.PositionType()==POSITION_TYPE_BUY)if(m_position.PositionType()==POSITION_TYPE_BUY)
return; // Если buy, то не открываемсяif(!m_trade.Buy(my_lot,Symbol(),m_symbol.Ask(),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());
return;
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+//+------------------------------------------------------------------+//| 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);
}
如何在MT5中分别计算每个货币对的开仓订单的佣金?
由于某些原因,它不会 - 它显示为零
由于某些原因,它不愿意这样做--它显示的是零。
在我的记忆中,这个东西从来没有工作过,你不能得到头寸的佣金,你必须从历史上查看所有的交易,检查它们是否属于选定的头寸,并将其汇总,这变得非常混乱,但在某个地方有一个示例代码,我认为来自fxsaber。
在我的记忆中,这个东西从来没有工作过,你不能得到头寸的佣金,你必须从历史上的所有交易中,检查它们是否属于选定的头寸,并加以总结,它变得相当混乱,但在某处有一个代码例子,我想是来自fxsaber。
fxsaber 显示它是对所有开放货币对的计算,这就是总的佣金。
fxsaber 向我们发送了所有未结对子的计算结果,即总的佣金。
对了,链接在此:https://www.mql5.com/ru/forum/93879/page5
嗯,这就是问题所在))为什么他们不能把简单的事情简单化,不计算佣金?
嗯,是的,不清楚为什么开发者不做一个现成的功能......也许有一天他们会...以前没有i-functions,每个人也都在挣扎......现在有...也许我们会等着佣金......
嗯,是的,不清楚为什么开发者不做一个现成的功能......也许有一天他们会...以前没有i-functions,每个人也都在挣扎......现在有...也许我们会等着佣金......
自己做可能会更快...
由于某些原因,不愿意显示零。
仍然为零,不想显示佣金
我是这样安排的
也就是说,它不检查是否有一个开放的订单?
最好的方法是在指标中创建一个信号,然后将其输入专家顾问中。