For some reason it doesn't want to - it shows zeros.
As far as I remember, this thing never worked, and you can't get the commission for the position, you have to go through all the trades from the history, check if they belong to the selected position, and sum it up, it gets pretty messy, but somewhere there was an example code, I think from fxsaber.
As far as I remember, this thing never worked, and you can't get the commission for the position, you have to go through all the trades from the history, check if they belong to the selected position, and sum it up, it gets pretty messy, but somewhere there was a code example, I think from fxsaber.
fxsaber showed it as a calculation of all open pairs and that is the total commission
Aleksandr Egorov: well, that's the question )) why can't they make simple things simple and not calculate the commission?
Well yes, it's unclear why the developers wouldn't make a ready-made function... maybe one day they will... there used to be no i-functions and everyone was struggling too... now there is... maybe we'll wait for commissions...
Well yes, it's unclear why the developers wouldn't make a ready-made function... maybe one day they will... there used to be no i-functions and everyone was struggling too... now there is... maybe we'll wait for the commissions...
I think I have half done it, put iClose, but there is an error. it opens a new position after every bar
I have it like this
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);
}
how to calculate the commission for open orders in mt5 for each pair separately?
for some reason it won't - it shows zeros
For some reason it doesn't want to - it shows zeros.
As far as I remember, this thing never worked, and you can't get the commission for the position, you have to go through all the trades from the history, check if they belong to the selected position, and sum it up, it gets pretty messy, but somewhere there was an example code, I think from fxsaber.
As far as I remember, this thing never worked, and you can't get the commission for the position, you have to go through all the trades from the history, check if they belong to the selected position, and sum it up, it gets pretty messy, but somewhere there was a code example, I think from fxsaber.
fxsaber showed it as a calculation of all open pairs and that is the total commission
fxsaber was sending us the calculation of all the open pairs, i.e. the total commission
Right, here's the link:https://www.mql5.com/ru/forum/93879/page5
well, that's the question )) why can't they make simple things simple and not calculate the commission?
Well yes, it's unclear why the developers wouldn't make a ready-made function... maybe one day they will... there used to be no i-functions and everyone was struggling too... now there is... maybe we'll wait for commissions...
Well yes, it's unclear why the developers wouldn't make a ready-made function... maybe one day they will... there used to be no i-functions and everyone was struggling too... now there is... maybe we'll wait for the commissions...
it's probably faster to do it yourself...
for some reason does not want to show zeros
still zeros and does not want to show commission
I have it like this
i.e. it does not check if there is an open order?
The best way is to create a signal in the Indicator and then enter it into the Expert Advisor