• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 8:48am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 8:48am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

EA open position on demo, but not open position on real account. Any Comment 7 replies

Why does 4 hour bar close 1 hour later than daily bar? 6 replies

Open Manually, Close Automatically EA? 0 replies

Is it possible to automatically run two scripts every hour? 2 replies

program: open a position when (close-open)==** 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe

Please help! - How to automatically close open position after 1 hour?

  • Post #1
  • Quote
  • First Post: Aug 20, 2008 5:42am Aug 20, 2008 5:42am
  •  Westhardus
  • | Joined Jul 2008 | Status: Member | 2 Posts
Dear colleagues!

Could someone post piece of EA code which automatically closes open position exactly after definite time interval, for example, after 1 hour or 3600 seconds? It needed in case if open position didn't reached Take Profit or Stop Loss after exact minutes/hours.

Best regards,
Westhardus
Short Term Pain for Long Term Gain!
  • Post #2
  • Quote
  • Aug 20, 2008 8:55am Aug 20, 2008 8:55am
  •  madboy84
  • | Joined May 2007 | Status: Member | 64 Posts
same thing I need also
but with another idea, that close all positions when the float profit reach a specify $, what you think about this idea? is it possible to do it?
 
 
  • Post #3
  • Quote
  • Aug 20, 2008 9:22am Aug 20, 2008 9:22am
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
To close an order after specified time...

extern int TimeSeconds = 3600 //one hour

init()

start()

Total = TotalOrders();
OrderOpen = 0;

for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
OrderOpen = OrderOpenTime();
}
}

if(TimeCurrent() - OrderOpen > 3600) [Close The Trade]
 
 
  • Post #4
  • Quote
  • Aug 20, 2008 9:22am Aug 20, 2008 9:22am
  •  Ronald Raygun
  • Joined Jul 2007 | Status: 31 y/o Investor/Trader/Programmer | 5,016 Posts
Quoting madboy84
Disliked
same thing I need also
but with another idea, that close all positions when the float profit reach a specify $, what you think about this idea? is it possible to do it?
Ignored
Same thing as the above, but instead of using time functions you use the "OrderProfit()" function
 
 
  • Post #5
  • Quote
  • Aug 20, 2008 9:30am Aug 20, 2008 9:30am
  •  madboy84
  • | Joined May 2007 | Status: Member | 64 Posts
Quoting Ronald Raygun
Disliked
Same thing as the above, but instead of using time functions you use the "OrderProfit()" function
Ignored

thnq Ronald, I'll try that..
 
 
  • Post #6
  • Quote
  • Last Post: Aug 22, 2008 5:44am Aug 22, 2008 5:44am
  •  Westhardus
  • | Joined Jul 2008 | Status: Member | 2 Posts
To Ronald:

Thanks a lot!
Short Term Pain for Long Term Gain!
 
 
  • Platform Tech
  • /
  • Please help! - How to automatically close open position after 1 hour?
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022