When I am using a daychart, limit entry, setprofittarget and stoploss. How do I prevent a second reentry of a position when the TP or a SL is hit (within a big move)?
The first idea was to use in the settings intrabarordergeneration with the option only 1 entry per bar but then every tick the limit order was generated and deleted – so not really a API friendly way.
how to have only 1 entry per bar
-
- Posts: 74
- Joined: 25 Aug 2007
- Been thanked: 6 times
Re: how to have only 1 entry per bar
There is an option in the properties for automated trading : Enter only once per bar.
Re: how to have only 1 entry per bar
If your limit orders (for entry either long or short) are being cancelled because conditions for those orders are constantly changing you need to hold values so that when the limit is sent it does not cancel.
If you do use the setting as pointed out to only allow one entry per bar, you may still need some back up logic. I was using that with an ES and ZB scalping system (two different systems) and there were times where I would flip from a short position (exit the position) to a long entry in literally the same tick, and I was still able to get two entries per bar. It was a few millisecond time difference and for whatever reason the broker did not write back to MC quick enough.
If you do use the setting as pointed out to only allow one entry per bar, you may still need some back up logic. I was using that with an ES and ZB scalping system (two different systems) and there were times where I would flip from a short position (exit the position) to a long entry in literally the same tick, and I was still able to get two entries per bar. It was a few millisecond time difference and for whatever reason the broker did not write back to MC quick enough.
-
- Posts: 15
- Joined: 11 Nov 2014
- Has thanked: 5 times
Re: how to have only 1 entry per bar
I'm dealing with this problem too... I was thinking about implementing some logic also since the "One Entry per bar" setting doesn't seem to work very well. Here's the pseudo code I was planning on implementing:If your limit orders (for entry either long or short) are being cancelled because conditions for those orders are constantly changing you need to hold values so that when the limit is sent it does not cancel.
If you do use the setting as pointed out to only allow one entry per bar, you may still need some back up logic. I was using that with an ES and ZB scalping system (two different systems) and there were times where I would flip from a short position (exit the position) to a long entry in literally the same tick, and I was still able to get two entries per bar. It was a few millisecond time difference and for whatever reason the broker did not write back to MC quick enough.
Code: Select all
//Buying condition true
If condition1 and BC = False then begin
buy next bar at limit;
end;
//Selling condition true
If condition2 and BC = False then begin
sellshort next bar at limit;
end;
If MP<>0 then begin
BC = True;
end;
//If entry signal true at prior bar, but false for current bar, BC = True, and MP = 0 (position already closed out)
If condition1[1] and condition2[1] and !condition1 and !condition2 and BC = True and MP = 0 then begin
BC = False;
end;