[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 162

 
Vinin:


Ok, I'll bring a little bit of logic

Cycle is executed regardless of condition if(NewBar())


I don't need it to depend on NewBAR(). This function is needed to avoid placing orders in piles. Please tell me why my code (in its last variant) works better.

works, but as soon as I do the same for SELLSTOP trades stop opening at all?

 

Dear Sirs, I am a newbie!

I've started to write my first ever EA...... and I can't finish it.

At the moment I am testing it in the strategy tester.

It's very simple.

At the opening of 10 hour candle, I place pending order at a distance of say 60 pips from the opening price of this 10 hour candle.

I have had some success with it.

But I have to delete the pending order, if it has not transformed in one hour from the moment it was placed

into a market order.

Here is my code.

int start()
{
double Price=Ask+60*Point;
double SL=Price-30*Point;
double TP=Price + 15*Point;
if(OrdersTotal()==0 && Hour()==10 && Minute()== 00 )
OrderSend("EURUSD",OP_BUYSTOP,0.1,Price,0,SL,TP, "fjdu",123,TimeCurrent( ) + 3600);

}

This code successfully compiles; the tester doesn't show any errors.

But the expiration parameter does not work, i.e. pending orders not converted into market ones within 1 hour are not deleted.

I changed value 3600 to 3600000.... but nothing happens.

I would be very grateful if you could tell me what my mistake is.

 
solnce600:
the expiration parameter does not work

Most likely, the broker does not support it. To be sure, you can go like this:

int i,ot = OrdersTotal();

for(i=ot-1;i>=0;i--)
{
   if(!OrderSelect()) continue;
   if(OrderMagicNumber()!=123) continue;
   
   if(OrderType()==OP_BUYSTOP && TimeCurrent()-OrderOpenTime()>3600)
   {
      OrderDelete(OrderTicket());
   }
}
 
solnce600:

Dear Sirs, I am a newbie!

I started to write my first ever EA...... and I can't finish it.

At the moment I am testing it in the strategy tester.

It's very simple.

At the opening of 10 hour candle, I place pending order at a distance of say 60 pips from the opening price of this 10 hour candle.

I have had some success with it.

But I have to delete the pending order, if it has not transformed in one hour from the moment it was placed

into a market order.

Here is my code.

int start()
{
double Price=Ask+60*Point;
double SL=Price-30*Point;
double TP=Price + 15*Point;
if(OrdersTotal()==0 && Hour()==10 && Minute()== 00 )
OrderSend("EURUSD",OP_BUYSTOP,0.1,Price,0,SL,TP, "fjdu",123,TimeCurrent( ) + 3600);

}

This code successfully compiles and tests.

But the expiration parameter does not work, i.e. pending orders not converted into market ones within 1 hour are not deleted.

I changed value 3600 to 3600000.... but nothing happens.

I would be very grateful if you could tell me what my mistake is.

What prevents you from making the condition to delete the same by the hour and minute? The DC may not meet your expiry.
 
borilunad:
And what prevents you from making a condition to delete at the same hour and minute? DC may not meet your expiry.


alsu:

Most likely, the broker does not support it. To be sure, you can do this:



I have a terminal Alpari.On the demo account I manually set the pendulum and put the expiry time - 1 hour. All was OK.

I read that if the broker doesn't support this parameter, there would be an error.... but there is no error.

Tests are running ... but the order is not deleted.

 
borilunad:
And what prevents you from making the condition to delete by the same hour and minute? The DC may not meet your expiry.

What about by the hour and minute?

Thank you.

 
solnce600:

How about by the hour and by the minute?

Thank you.



What should be substituted for the expiration parameter ?

 
solnce600:

And by an hour and a minute, how is that?

Thank you.

It's the same as you opened it, only an hour later at 11:00. That's what you have! That's not how I do it, but it doesn't change the point.
 
borilunad:
The same as you opened it, only one hour later at 11. I'm doing it differently, but it doesn't change the point.

Sorry for being dumb, but I haven't understood whether I need to change anything in this parameter or not.

If so, I would appreciate it if you could insert the expiration parameter in my code as needed, and paste the entire line in the text of your answer.

Thank you.

 
solnce600:

Sorry for being dumb, but I haven't understood whether I need to change anything in this parameter or not.

If so, I'd appreciate it if you could insert the expiration parameter in my code as needed, and paste the entire line in the text of your reply.

Thank you.



I can suggest the following variant:

if(Hour()==11 && OrdersTotal()>0)

{

if(OrderSelect(0,SELECT_BY_POS)==true)

{

if(OrderType()==OP_BUYSTOP)

{

OrderDelete(OrderTicket());

}

}

}

And you don't use the expiry parameter. The disadvantage is that when trading, the computer must be running with the internet connected and the terminal switched on in order for the position to close.

Reason: