How to implement the closing of positions one at a time after N minutes ? - page 4

 
Vitaly Muzichenko:

My point is thatclose can only be either 0(false) or 1(true), there is no other.

I will show you the function again, i gave it to you today, it worked out today and i will leave it at that.

Forum on trading, automated trading systems and testing trading strategies

How to implement closing of one position after N-minutes ?

Natalya Dzerzhinskaya, 2017.11.22 19:17


(OrderCloseTime()> 0) works, I will leave it that way then

Thanks again)))


Also closes fine, but after closing it writes error 4108"Invalid ticket number."



 
Vitaly Muzichenko:

My point is thatclose can only be either 0(false) or 1(true), there is no other option.

The same, for reliability, is better to write:

to be safe.

you should always(!!!) use the value found for it in the function, to make sure we use the correct and necessary function parameters

 
Renat Akhtyamov:

Once again, here's the function, I gave it to you today, you worked it out today, and that's the end of it.

Saying thank you doesn't mean you're right, you're an adult and you should realise that.

This is like going to a service station and saying thank you to the repairman, saying that the car drives fine after the repair, but the valves are knocking. Do you understand?

That's it - gone).

 

teachers are all over the place.... everyone who cares....

i'm the only one who knows not to mess around with the trading functions

everything must be done 5+

Every mistake is a waste of money!

 
Taras Slobodyanik:
It is possible to close orders immediately if you have searched through them.
Why should we search for the time? Compare - close - next.

The condition there is to find only one order that is open first. And without a complete search of orders it is impossible to know that such-and-such order is the oldest.

 
Renat Akhtyamov:

teachers are all over the place.... everyone who cares....

i'm the only one who knows not to mess around with the trading functions

Everything has to be 5+.

every mistake is a loss of money!

Renat, this condition will not hold even in the apocalypse, you can check it:

                  if(OrderSelect(MyTicketBuy, SELECT_BY_TICKET)==true)
                  {
                     close=OrderClose(MyTicketBuy,OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),0,clrRed);
                     if(close<0){if(Fun_Error(GetLastError())==1)return;}
                  }
                  if(OrderSelect(MyTicketSell, SELECT_BY_TICKET)==true)
                  {
                     close=OrderClose(MyTicketSell,OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),0,clrBlue);
                     if(close<0){if(Fun_Error(GetLastError())==1)return;}
                  }
 
Vitaly Muzichenko:

Renate, this condition won't hold even in an apocalypse, you can check:

well the man used my code!!!!

the error popped up?????

Vitaly, stop it...

or go torture yourself if you don't believe me.

 
Ihor Herasko:

The condition there is to find only one order that is open first. And without a complete search of orders it is impossible to find out that such and such order is the oldest.

According to the condition, it cannot be open more than 5 minutes, that is, you can freely search in order, and close older than 5 minutes, it will be the oldest.

 
Renat Akhtyamov:

well, the man used my code!!!!

error popped out?????


That's the thing, it (the error) will never be visible. Even if it appears. The close variable must be of the bool type, which never has a value less than zero.

 
Renat Akhtyamov:

Well, the man used my code!!!!

error thrown up?????

It's not about used or not used.

Once again:

Forum on trading, automated trading systems and trading strategy testing

How to implement closing of position after N-minutes ?

Vitaly Muzichenko, 2017.11.22 20:28

Under what conditions can this ever work, at least once every 100 years ?

                  if(OrderSelect(MyTicketBuy, SELECT_BY_TICKET)==true)
                  {
                     close=OrderClose(MyTicketBuy,OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),0,clrRed);
                     if(close<0){if(Fun_Error(GetLastError())==1)return;}
                  }
                  if(OrderSelect(MyTicketSell, SELECT_BY_TICKET)==true)
                  {
                     close=OrderClose(MyTicketSell,OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),0,clrBlue);
                     if(close<0){if(Fu n_Error(GetLastError())==1)return;}
                  }

Reason: