I don't understand why the hours and minutes are not populating? Is it something to do with tester mode?
DomGilberto: I don't understand why the hours and minutes are not populating? Is it something to do with tester mode?
Short_Trade_Send = OrderSend(Symbol(), OP_SELL, LotSize_Sell, Bid, 3, Short_Stop_Price, stp1, NULL, MagicNumber, 0, Green); if( Short_Trade_Send > 0 ) TradeOpenTime = GlobalVariableSet(" Open Time ", OrderOpenTime()); |
|
DomGilberto:
I'm wanting to understand how to change seconds into date and time?
. . .
I'm wanting to understand how to change seconds into date and time?
. . .
Any help on where I am being an idiot :)
Short_Trade_Send = OrderSend(Symbol(),OP_SELL,LotSize_Sell,Bid,3,Short_Stop_Price,stp1,NULL,MagicNumber,0,Green); if( Short_Trade_Send > 0 )TradeOpenTime = GlobalVariableSet(" Open Time ", OrderOpenTime());
You must use OrderSelect() before attempting to use OrderOpenTime().datetime OpenTime_Format = StrToTime( " Open Time " );
Why are you doing this? You are converting the string " Open Time " to Time. I don't think that is what you meant/want to do.
.
Damn it I knew that! God that annoys me! I think I had been looking at it too much today tbh. Thanks for pointing that out!
I don't even know why I am doing it this way anyway for what I am trying to achieve!
Just quickly playing around with it now, this is what I am trying to do! V
//+------------------------------------------------------------------+ //|Select Open Trade to work on | //+------------------------------------------------------------------+ void Manage_OpenTrade() { bool Time_Close; int PositionIndex; int TotalNumberOfOrders; TotalNumberOfOrders = OrdersTotal(); for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --) { if( ! OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue; if( OrderMagicNumber() == MagicNumber ) if ( OrderSymbol() == Symbol() ) { RefreshRates(); if( OrderOpenTime() == iTime(NULL,Quant_TimeFrame, 2) && OrderType()== OP_BUY ) { RefreshRates(); Time_Close = OrderClose(OrderTicket(),OrderLots(), Bid, 5, clrRed); if( Time_Close )Print("Buy position closed due to one hour limit"); } if( OrderOpenTime() == iTime(NULL,Quant_TimeFrame, 2) && OrderType()== OP_SELL ) { RefreshRates(); Time_Close = OrderClose(OrderTicket(),OrderLots(), Ask, 5, clrRed); if( Time_Close )Print("Sell position closed due to one hour limit"); } } } }
I am wanting to close the open position BEFORE the NEXT immediate 1 hour bar opens (i.e. 1 second before it opens is the deadline). The trade will either hit it's profit target or close based upon a 1 hour limit from the time it OrderOpenTime().
I know I am doing something wrong here. Are you able to shed some light?
Thanks!!
UPDATE: THE ABOVE WORKS.
Yea you're right! I realised that due to the fact that ticks come in intermittently, it's not a fair test in an "if" statement. Thanks for your comment!

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
"Get_Open_Time" is simply storing the open position time (incase platform has crashed and reboots it remembers).
When I am printing this all it shows is:
Any help on where I am being an idiot :)