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

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

3 Bar Fractal with mid-bar and bar on each side 8 replies

How to send order at the close of the bar? 36 replies

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

Need help!! Close order on this bar close 5 replies

Pin bar, pin bar, pin bar 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe

How to close order on BAR close?

  • Post #1
  • Quote
  • First Post: Nov 28, 2009 5:18am Nov 28, 2009 5:18am
  •  LuboLabo
  • Joined Sep 2008 | Status: Order Flow Trader | 878 Posts
I need help, I would like to close the order at close of the same bar of open position.
There's a way to do this?

Thanks.

Lubo
If I know how, I tell You!! Few but Good!!
  • Post #2
  • Quote
  • Nov 28, 2009 7:15am Nov 28, 2009 7:15am
  •  LuboLabo
  • Joined Sep 2008 | Status: Order Flow Trader | 878 Posts
Anyone?
If I know how, I tell You!! Few but Good!!
  • Post #3
  • Quote
  • Edited at 8:56am Nov 28, 2009 8:51am | Edited at 8:56am
  •  Horrigan
  • | Joined May 2009 | Status: Pip sniper | 102 Posts
Try do this on open next bar, for example, you opened position when new candle has lit, or when progresses, and you want to close at close of THE same bar or on open of new one. Use this part of code (the variables, their initalize and reset value you may solve, I hope. This is for 1hr charts, the daily has the similar logic


if ( pos_open==true && Hour() == OpenHour+1)

{
OrderClose(ticket,....,....,....,.... blah blah)
}

The bool var pos_open you may manage by OrderSelect and OrderCloseTime ==0, as true, else false
The var OpenHour you initialize at the IF body where you open the position
(Example:

if(pos_open==false && ......&&......&&..... ) //your entry rules
{
OrderSend(NULL, OP_BUY, Lots, Ask, 0, Bid-SL*Point, Bid+PT*Point);
OpenHour=Hour();
}

It's clear and understandable?

P.S. for Daily, or other TF you can use the similar logic, replace only Hour() Minute() or Day() - as new candle lights
Do you want an EA for your own profitable system? E-mail or PM me.
  • Post #4
  • Quote
  • Nov 28, 2009 10:47am Nov 28, 2009 10:47am
  •  LuboLabo
  • Joined Sep 2008 | Status: Order Flow Trader | 878 Posts
thanks for the code, and I think it's better >= instead ==
I have tried also this.
if(TimeCurrent() >= Time[0] + (Period() * 60 - 1)) ......Close Trade

But I still get orderclose error 138.....requote, I don't understand why..

Any ideas?

Lubo.
If I know how, I tell You!! Few but Good!!
  • Post #5
  • Quote
  • Nov 28, 2009 11:39am Nov 28, 2009 11:39am
  •  Horrigan
  • | Joined May 2009 | Status: Pip sniper | 102 Posts
>= maybe better than ==, but the order you close only once, so this is irrelevant, what you wrote it... you may get orderclose error when you realize close by elseway (SL, PT hit, for example), or the EA is trying close position with wrong ticket number. Try re-check the orderSelect passage, try recompile without it, simply try attempt/error. I now work on another PC, where I have not some functionable EA, from what I can get you a code.

I had here only right OrderSelect, you may edit it for your needs


if(OrderSelect(position1,SELECT_BY_TICKET)==true)
{
OrderSelect(position1, SELECT_BY_TICKET);
if(OrderCloseTime() ==0)
{
total1=1;
}

else
{
total1=0;
}
}
else total1=0; //nikdy pozice 1 nebyla
if(OrderSelect(position2,SELECT_BY_TICKET)==true)
{
OrderSelect(position2,SELECT_BY_TICKET);
if(OrderCloseTime() ==0)
{
total2=1;
}
else
{
total2=0;
}
}
else total2=0;

EDIT: the re-quote you try slove by the "slippage" argument
Do you want an EA for your own profitable system? E-mail or PM me.
  • Post #6
  • Quote
  • Nov 28, 2009 2:43pm Nov 28, 2009 2:43pm
  •  LuboLabo
  • Joined Sep 2008 | Status: Order Flow Trader | 878 Posts
Quoting Horrigan
Disliked
>= maybe better than ==, but the order you close only once, so this is irrelevant, what you wrote it... .....
Ignored
I think is rilevant coz if the next bar is missed the position is not closed....
If I know how, I tell You!! Few but Good!!
  • Post #7
  • Quote
  • Last Post: Nov 29, 2009 4:18am Nov 29, 2009 4:18am
  •  Horrigan
  • | Joined May 2009 | Status: Pip sniper | 102 Posts
Quoting LuboLabo
Disliked
I think is rilevant coz if the next bar is missed the position is not closed....
Ignored
Yes, I agree, this i relevanton M1 or similar charts, on higher TF (for example 1hr) you have usualy more than 500 tick, so the EA calls the start() function more than 500 times. We were disunderstood about TF that you play But, you're right, the operator more than or equal is more secure wiriting

Were you solve the problem with closing position??

Another (maybe stupid) idea: I had once upon a time some problem with similar signs as yours (OrderSend Error : (i think) 128) - I tried all what is possible - nothing, errors still occurs. I was get angry (very, very angry) the code, what and where it stayed I erased and entrie EA re-wrote. The code looks identically, but in old was some hidden error or problem. To current days I don't know where, but by this (drastic) procedure I solved it.

If you don't see some way, try return on start you way and procced step by step

Sorry, my English is horrible, but I hope you can understood it. (And I must do something with it )
Do you want an EA for your own profitable system? E-mail or PM me.
  • Platform Tech
  • /
  • How to close order on BAR close?
  • 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 / ©2021