Questions from Beginners MQL5 MT5 MetaTrader 5 - page 271
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
so only the first value is filled in with the index [0].
thank you. saved me a sleepless weekend).
vicmos thank you.
it fills everything with one value, like the ArrayFill(...)/ function
Good day to all! Such a problem - the compiler gives a warning. I don't want to ignore it, can you help me find a way out?
It is cursing specifically at the last line, says:"possible loss of data due to type conversion". How to correctly normalize the real type in this case?
Good day to all! Such a problem - the compiler gives a warning. I don't want to ignore it, can you help me find a way out?
It is cursing specifically at the last line, says:"possible loss of data due to type conversion". How to correctly normalize the real type in this case?
Good day all! Such a problem - the compiler gives a warning. I don't want to ignore it, can you help me find a way out?
It is cursing specifically at the last line, says:"possible loss of data due to type conversion". How to correctly normalize the real type in this case?
And one more thing: ArrayMaximum and ArrayMinimum returns the index of the element found. So the correct way is this:
Also: ArrayMaximum and ArrayMinimum return the index of the element found. So the correct way is like this:
It does not correctly calculate the take profit level based on the amount of losses of the closed orders. It turns out the 1st order = 1; 2nd order = 2; 3rd order = 3; 4th order = 4. We need to calculate the number of pips to cover the loss on all previous orders and gain 10% of the total loss.
Actually, the Expert Advisor just considers the amount of each closed order to be equal to the supposedly pending order, i.e. its calculations show that if the pending 5th order equals 5 lots, all previous losing orders were equal to 5 lots and, therefore, the loss is calculated with the corresponding wrong profit level. In other words, if the total volume of 4 orders equals 10 lots, then the Expert Advisor will simply multiply 4 orders by the volume of the 5th pending order and obtain a total volume of 20 lots......What should we correct in the code?
// Function which calculates Take Level based on Loss Level of closed trades
//=================================================================================================
double TakeProfitCalculate(double lot,int type)
{
int n,i;
double prf,ttp;
prf=MathAbs(BuyLevel-SellLevel)/Point*LOT*MarketInfo(Symbol(),MODE_TICKVALUE);//
if(No!=0) for(i=OrdersHistoryTotal()-1;i>=0;i--)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) continue;
if(OrderSymbol()!=Symbol() || OrderMagicNumber()<MAGIC || OrderMagicNumber()>MAGIC+200 || OrderType()>OP_SELL) continue;
n=OrderMagicNumber()-MAGIC;
prf+=(OrderProfit()+OrderSwap()+OrderCommission());
if(n==0) break;
}
prf=MathAbs(prf*(100+ProfitPercent)/100);
ttp=prf*Point/(LOT*MarketInfo(Symbol(),MODE_TICKVALUE))
if(type==OP_BUY) return(NRu(BuyLevel+ttp)); else return(NRd(SellLevel-ttp))
}