[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 1127

 
drknn:
Thank you very much for your help =)
 
Alexandr24:
Thank you very much for your help =)


Don't forget that in the tester the indicator doesn't throw up the alert window, but instead writes alert messages in the logs. It's better to debug such pieces of code with scripts - it's faster.

Also, the indicator messages, oddly enough, are not written in the tester to the tester logs, but to the realtime logs.

 
How do I consider commission when testing an EA in the tester?
 
Seems to be taken into account as the tester uses all the settings of a particular broker. A search will tell you more accurately.
http://www.google.ru/search?as_sitesearch=mql4.com&as_q=%EA%EE%EC%E8%F1%F1%E8%FF+%E2+%F2%E5%F1%F2%E5%F0%E5
 
Abzasc:

There is no "straightforward" way of doing this.

You could do it this way.

Or here's another way


Thank you!
 

I don't quite understand how the conditions work.

I decided to find out how a fractal indicator works, what is MODE_UPPER and MODE_LOWER difference, and wrote the following code

int start()
{int y;
y= WindowFirstVisibleBar();Alert ("y",y);
for (;y>=0;y--)
{ double up=iFractals(Symbol(),PERIOD_M15,MODE_UPPER,y);
double down=iFractals(Symbol(),PERIOD_M15,MODE_LOWER,y);
if (up>=1|down>=1){
Alert("Previous upper fractal is:", up, " Previous lower fractal is:", down);Alert ("y",y);}}

WindowFirstVisibleBar() gives the number of bars on the chart, this thing works if you cross out if (up>=1||down>=1) from the EA, it gives a nice series of counted bars, only there are so many.

It's like a || sign or, the operator seems to do the brackets {} if at least one of the conditions is true, or both are true at once, right?

Nothing's changed at all for me!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I think I got it right. Help me out!!!!!!!

 
Dimka-novitsek:

I don't quite understand how the conditions work.

I decided to understand how a fractal indicator works, what is the difference between MODE_UPPER and MODE_LOWER.

int start()
{int y;
y= WindowFirstVisibleBar();Alert ("y",y);
for (;y>=0;y--)
{ double up=iFractals(Symbol(),PERIOD_M15,MODE_UPPER,y);
double down=iFractals(Symbol(),PERIOD_M15,MODE_LOWER,y);
if (up>=1||down>=1){
Alert("Previous upper fractal is:", up, " Previous lower fractal is:", down);Alert ("y",y);}}

WindowFirstVisibleBar() gives the number of bars on the chart, this thing works if you cross out if (up>=1|down>=1), it gives a nice series of calculated bars, but there are a lot of them.

It's like a || sign or, the operator seems to do the brackets {} if at least one of the conditions is true, or both are true at once, right?

Nothing's changed at all for me!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I think everything is correct. Help me!!!!!!!



normal code place via counter-alt - M - faster response...no exclamations.
 
via counter-alt - M - And more details?
 
Dimka-novitsek:

It's like ||

https://docs.mql4.com/ru/basis/operations/bool

A logical OR operation.

Zy counter-alt - M is like SRC push button and code through it.

 
drknn:

I have tried the code you suggested. The result is always the same - it keeps opening trades during the day. Again, I would like to keep on/off option.

Here are the tried variants:

extern bool WaitForNewDay = true;

void init()

{

SMB=Symbol();

return;

}

void start()

{

bool Trade=true;

if(WaitForNewDay){if(HistoryBuy(MAGICMA)+HistorySell(MAGICMA)!=0) Trade=false;}

if(CalculateCurrentOrders(Symbol())==0 && Trade)

{CheckForOpen(); return;}

}

//-----------------------------------------------------------------

int HistoryBuy(int MAGICMA)

{int BuyOrders=0;

for (int i=OrdersHistoryTotal()-1;i>=0;i--) {

if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){

Print(" ",GetLastError()," ",i);

}

else {

if(OrderSymbol()!= SMB || OrderMagicNumber()!= MAGICMA){ continue;}

if(OrderType()==OP_BUY){

if(OrderOpenTime()>=iTime(SMB,PERIOD_D1,0)){

BuyOrders++;

}

}

}

}

return(BuyOrders);

}

//-----------------------------------------------------------------

int HistorySell(int MAGICMA){

int SellOrders=0;

for (int i=OrdersHistoryTotal()-1;i>=0;i--){

if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){

Print(" ",GetLastError()," ",i);

}

else {

if(OrderSymbol()!=SMB || OrderMagicNumber()!=MAGICMA){ continue;}

if(OrderType()==OP_SELL){

if(OrderOpenTime()>=iTime(SMB,PERIOD_D1,0)){

SellOrders++;

}

}

}

}

return(SellOrders);

}

//////////////Other option/////////////////////

extern bool WaitForNewDay = true;

Trade=true;

void init()

{

SMB=Symbol();

if(WaitForNewDay) {Trade=false;}

return;

}

void start()

{

if(WaitForNewDay) {if(HistoryBuy(MAGICMA)+HistorySell(MAGICMA)==0) Trade=true;}

if(CalculateCurrentOrders(Symbol())==0 && Trade)

{CheckForOpen(); Trade=false; return;}

}

Reason: