Questions from Beginners MQL4 MT4 MetaTrader 4 - page 75

 
Vitaly Muzichenko:
And if the profit is +1, and the swaps and commissions are -5, then it can still be considered profitable?
If the profit is +1 and the swaps are -5, then it can still be considered profitable.)
 
Nikolay Gaylis:
If I'm not mistaken - I just don't even use this theme...)

counts, but the issue here is that as a programmer, you should not have the same division as for a tester or real.

The full piece:

OrderProfit()+OrderSwap()+OrderCommission()
 
Nikolay Gaylis:
If I' m wrong ... I just don't even use that theme).

You have been sneakily and maliciously deceived, everything counts ))))
 
Good afternoon. Can you tell me how to add a non-standard indicator in MT-4 for android?
Sincerely, Alexander.
 
Vitaly Muzichenko:
Here's everything about time

Thank you! [Laughs] It turned out like this, it turns out to be simple.
extern int     hbG = 18;                 // Часы начала
extern int     mb = 29;                  // Минуты начала
extern int     heG = 18;                 // Часы окончания
extern int     me = 50;                  // Минуты окончания

bool isTradeTimeInt()
{
 int hb = hbG + (TimeGMTOffset()/3600);
 int he = heG + (TimeGMTOffset()/3600);
 datetime db, de;        // Время начала и окончания работы
 int hc;                 // Часы текущего времени торгового сервера
 
 db=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+ IntegerToString(hb) +":"+IntegerToString(mb));
 de=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+IntegerToString(he)+":"+IntegerToString(me));
 hc=TimeHour(TimeCurrent());
 if(db >= de)
 {
  if(hc >= he)
   de+=24*60*60;
  else
   db-=24*60*60;
 }
 if(HOUR==true)
 {
  if(TimeCurrent()>=db && TimeCurrent()<=de)
   return(true);
  else
  {
   if(CountTrades()==0)
    return(false);
  }
 }
 return(true);
}
 
Vitalie Postolache:

You have been sneakily and maliciously deceived, it all counts ))))

Thank you... I'll keep that in mind, it might come in handy).
 

Help, guys, I've been struggling for the second day, I can't figure out what the problem is.

I need to program the search for a peak on the indicator -

I do it this way -

if ( ( (value[1]) < (value[2]) && (value[2]) > (value[3]) )

{

peak = 1;

}

else peak = 0;


In general, I compare the value on the middle candle and if it is greater than the neighboring ones, the peak is found.

But the problem is that it works somehow half-way - it finds the peak but when values of the indicator keep increasing

it draws a new peak every time for some reason even though it shouldn't! At the same time, when the indicator drops consistently, everything is all right, it doesn't draw any peaks.

I cannot understand what the problem is.


Here is a screenshot. If peak = 0, a vertical line is drawn on the next candle after the peak. Everything is correct. But when the indicator grows, they are also drawn for some reason.


 
Vitalie Postolache:
How do you calculate the profit?

I thought it would be (Long(1) or Short(-1)) * (Exit Price - Entry Price)-SpreadTester.
And swaps are paid, if I understood correctly, when the position is moved past midnight. And not all brokers, some hold swaps only on Wednesday.
In any case, in my TS to be tested I will probably forcibly close positions held up to midnight.
However, how to calculate profit in points correctly in testing? I do not understand what the tester calculates in dollars.
 
John Smith:

Help, guys, I've been struggling for the second day, I can't figure out what the problem is.

I need to program a search for a peak on the indicator.

I can't figure out what the problem is.

Most likely you have a mix up of past indicator values. If you have a new current value with index [0], then for correct comparison all past values should increase by 1.
 
MikeZv:

I thought it would be (Long(1) or Short(-1)) * (Outside PriceInside Price)-SpreadTester.
And swaps are paid, if I understood correctly, when the position is moved past midnight. And not all brokers, some hold swaps only on Wednesday.
In any case, in my TS to be tested I will probably forcibly close positions held up to midnight.
However, how to calculate profit in points correctly in testing? I do not understand what the tester calculates in dollars.


So if you look closely at your trades, there is just a mismatch on the ones that have been carried overnight. It would be logical to count the swap as well.

All brokers hold swaps for forex every night, on Wednesday the swap is doubled.

Profit in points does not take into account swap, it is simply (Exit-PriceInPrice)/Point and swap should be added somehow, but it will not be profit in pips and something else.