[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 48

 
orlovkem >> :

Maybe the comment is wrong, but the essence is true, the price level is higher than the indicator value, it should buy, but it should be done only once, and the EA will buy as long as there is money in the deposit. You just need to limit the number of deals. To make not more than one at a time, it does not work.

Do a check on the current bar and on the previous bar, then the signal will be one,

only at crossing.

I.e. if on the current bar the indicator is higher, and on the previous one was lower

it means buy, and it will be only one buy for the signal.

 
orlovkem >> :

Maybe I did not wrote it correctly, but the essence is correct, the price level has become higher than the indicator value, I need to buy and it buys, but I need to do it once, and the EA buys as long as there is money on the deposit. You just need to limit the number of deals. To make not more than one at a time, it does not work.

Are you sure the advisor is buying (selling) ? Have you tried it? Judging by the code, there shouldn't be a single trade at all, not that "it buys as long as there is money in the deposit". Or you did not write the code ?

 
xeon >> :

The easiest way to control the number of orders open at the same time

a little different - orders do not open in parallel, just after closing an order another one opens in the same direction (at this point the trade has already exhausted its power and I am in a loss)

((

 
VladislavVG >> :

Are you sure the advisor is buying (selling) ? Have you tried it? Judging by the code, there shouldn't be a single trade at all, not that "it buys as long as there is money in the deposit". Or you did not write the code ?


I wrote the code, and it buys and sells. Tried it on the strategy tester.

 
satop >> :

Do a check on the current bar and on the previous bar, then the signal will be one,

only when it crosses.

I.e., if the indicator is higher on the current bar and lower on the previous one

it means buy, and it will be only one buy for the signal.

Thanks for the tip, I think I understand what is required of me. I will try it now. Thanks again.

 
xruss >> :

slightly wrong - orders do not open in parallel, just after closing an order another one opens in the same direction (at which point the trade has already exhausted its strength and I am at a loss)

((

And if you send us the whole fragment, which is responsible for the selection of the last order and the condition of its checking, we will understand it. It is difficult to suggest something in this way. Alternatively, after the signal, simultaneously with the opening of a position, you can set a flag to prohibit the following trades of this type, and in the block of opening positions to check for its presence. If the flag is raised - the trade is skipped. Upon receipt of an opposite signal, the flag is removed, but after the first successful opening of a position, the new flag is set - forbidding opening deals of that type, for which a new signal was received. And so on.

 
orlovkem >> :

I have written the code and it both buys and sells. I tried it on the Strategy Tester.

So it's not the code you posted on the previous page. That code buys nothing and sells nothing. You can copy it, if you don't believe me, and run it in the tester.

For instance, for me it's clear that there is no pair of numbers for which the conditions a>=b and a<b are satisfied simultaneously. Judging by your expert, not only is it not obvious to you, but for you it is obvious that such numbers exist. Of course, I could be wrong - then please, if it is not difficult, give me an example of such a pair of numbers. Only in this case, a buy order will be placed using your algorithm. The same for sell.

>> Good luck.

 
Everlost писал(а) >>

And if you could post the whole fragment, which is responsible for the selection of the last order and the condition for checking it, we can work it out. It is difficult to suggest something in this way. Alternatively, after the signal, simultaneously with the opening of a position, you can set a flag to prohibit the following trades of this type, and in the block of opening positions to check for its presence. If the flag is raised - the trade is skipped. Upon receipt of an opposite signal, the flag is removed, but after the first successful opening of a position, the new flag is set - forbidding opening deals of that type, for which a new signal was received. And so on.

I'll show a bit later, but it seems to me that the flags would be cooler. How can I coding them through mql4?

Here is my code:

//Учет ордеров истории
int ORDtype=-1;
double ORDprofit=0.001;
for( i=OrdersHistoryTotal(); i>=0; i--)
{
if(OrderSelect( i, SELECT_BY_POS, MODE_HISTORY))
 {
  if(OrderSymbol()==Symbol())
  {
   if(OrderCloseTime()!=0)
   {
     ORDtype=OrderType();
     ORDprofit=OrderProfit();
   }
  }
 }
}    

....

if (( ORDtype==OP_SELL)||( ORDtype==-1)&&(( ORDprofit<=0)||( ORDprofit==0.001))...
{
...
}
if (( ORDtype==OP_BUY)||( ORDtype==-1)&&(( ORDprofit<=0)||( ORDprofit==0.001))...
{
...
}
 

I wanted to make expert do not work from 6 to 20 on the broker, checking before it switches off and waiting until it closes. Everything is working but I wish I could add alert like trading is finished when expert stops trading.

if(TimeHour(TimeCurrent()) > 6 && TimeHour(TimeCurrent()) < 20 && Worktime == true)
{
if (OrdersTotal() == 0)
Alert("Торговля закончена");
return(0);
}

it starts beeping on every tick. In this case the alert will not only hit once but also the cycle will be cut off. Please advise me which way to go, I can't figure it out...

 
Dimoncheg >> :

I wanted to make expert do not work from 6 to 20 on the broker, checking before it switches off and waiting until it closes. Everything is working but I wish I could add alert like trading is finished when expert stops trading.

if(TimeHour(TimeCurrent()) > 6 && TimeHour(TimeCurrent()) < 20 && Worktime == true)
{
if (OrdersTotal() == 0)
Alert("Торговля закончена");
return(0);
}

it starts beeping on every tick. In this case the alert will not only hit once but also the cycle will be cut off. Please advise me which way to go, I just can't figure it out...

One of the options:

if(TimeHour(TimeCurrent()) > 6 && TimeHour(TimeCurrent()) < 20 && Worktime == true)
   {
   if (OrdersTotal() == 0)
   if( NeedAlert){ Alert("Торговля закончена"); NeedAlert=false;}
   return(0);
   }
Set the bool variable NeedAlert to true when you start trading.
Reason: