Look at the open trade and determine the time it was opened, then check the current time, subtract one from the other, if the result is greater than the time period you want the order open for close the order.
A question for you, what is this meant to accomplish ?
if (true) ticket = OrderSend(Symbol(), OP_BUY, BaseLot, Ask, 4, 0, 0, "buy every", MAG_BUY, 0, Blue); else ticket = OrderSend(Symbol(), OP_BUY, BaseLot, Ask, 4, S_L, T_P, "buy every", MAG_BUY, 0, Blue);
true is always true . . what else could it ever be ?
opening... what is the trick in order to delay close function for a day
Similarly... i had an "ahaaaa" moment the other day in regards of how to trade every 1h, every day.... but AM totally stupid how to get it done in a similar way on the let say weekly or monthly basis.
for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() ){ // and my pair. if (TimeCurrent() - OrderOpenTime() > 24*60*60){ // Order older than 24 hours. // or // if (Time[0] > OrderOpenTime()){ // Order older than one bar.
- Change time frames on the chart.
- Change time frames on the chart.
1. TY.
2. true... and difficult to back test.
also..... whats ur rate if hired???
Look at the open trade and determine the time it was opened, then check the current time, subtract one from the other, if the result is greater than the time period you want the order open for close the order.
A question for you, what is this meant to accomplish ?
true is always true . . what else could it ever be ?
answer urself... compile it without it:)
answer urself... compile it without it:)
It's your code, and you are asking for help with it . . . my point was . . . what is the point of code that is never executed ?
int ticket = -1; if (true) ticket = OrderSend(Symbol(), OP_SELL, BaseLot, Bid, 4, 0, 0, "sell every", MAG_SELL, 0, Red); else ticket = OrderSend(Symbol(), OP_SELL, BaseLot, Bid, 4, S_L, T_P, "sell every", MAG_SELL, 0, Red);
does the same as . . .
int ticket = -1; ticket = OrderSend(Symbol(), OP_SELL, BaseLot, Bid, 4, 0, 0, "sell every", MAG_SELL, 0, Red);
It's your code, and you are asking for help with it . . . my point was . . . what is the point of code that is never executed ?
does the same as . . .
i see, i am sorry, there is also a function dealing with stp/ecn.... /not included/ to cover both scenarios. its the way i try to code.... through functions as much as possible for simplicity and flexibility.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi ALL, i have a little problem with my simple ea and i cant get around.... basicly it open sell and buy trade every day, this bit is working however for obvious reason it close trades second after opening... what is the trick in order to delay close function for a day like in this ea or any other fixed amount of day weeks.... of course i could just buy sell, and next day check if any opened trades exist and close them if, but for some reason i need it proposed way... if possible...
Similarly... i had an "ahaaaa" moment the other day in regards of how to trade every 1h, every day.... but AM totally stupid how to get it done in a similar way on the let say weekly or monthly basis.
all suggestions welcome... Thank you.