Breakeven Stop with intrabar set to false executes intrabar

Questions about MultiCharts and user contributed studies.
User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Breakeven Stop with intrabar set to false executes intrabar

Postby MAtricks » 14 May 2012

I've never used a breakeven stop within a strategy before. Within the generic Breakeven Stop supplied by MC the function defaults intrabar orders to false. Backtesting proves this to be true, however while running this live, it will execute on the same bar as the entry order.

Am I missing something? I do not want intrabar orders to generate.

Code: Select all

[IntrabarOrderGeneration = false]
inputs: PositionBasis( false ), FloorAmt( 1 ) ;

if PositionBasis then
   SetStopPosition
else
   SetStopShare ;

SetBreakeven( FloorAmt ) ;


Image
Attachments
2012-05-14_1220.png
2012-05-14_1220.png (7.94 KiB) Viewed 278 times

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby TJ » 14 May 2012

MAtricks wrote:I've never used a breakeven stop within a strategy before. Within the generic Breakeven Stop supplied by MC the function defaults intrabar orders to false. Backtesting proves this to be true, however while running this live, it will execute on the same bar as the entry order.

Am I missing something? I do not want intrabar orders to generate.

Code: Select all

[IntrabarOrderGeneration = false]
inputs: PositionBasis( false ), FloorAmt( 1 ) ;

if PositionBasis then
   SetStopPosition
else
   SetStopShare ;

SetBreakeven( FloorAmt ) ;



What you are using is called Global Exits.

see notes in post #3
viewtopic.php?f=16&t=6929

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby MAtricks » 14 May 2012

Thanks for the reply. I read your suggested topic. #5 isn't relevant, but I'm assuming you mean #3 (for future readers).

These are global exits. I understand this, but is there anyway to generate the orders as they backtest? While backtesting the option for intrabar = false is utilized correctly, but in live execution the intrabar = false is executed intrabar regardless.

My question is: How can I stop this from executing intrabar? Or is there a breakeven stop programmed in EL that doesn't have this flaw?

Wouldn't I be correct to assume that while using

Code: Select all

[IntrabarOrderGeneration = false]

execution should be halted until the close of the bar? Obviously I'm incorrect according to your topic #3, but why would backtests show differently?
Last edited by MAtricks on 14 May 2012, edited 2 times in total.

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby TJ » 14 May 2012

MAtricks wrote:Thanks for the reply. I read your suggested topic. #5 isn't relevant, but I'm assuming you mean #3 (for future readers).

These are global exits. I understand this, but is there anyway to generate the orders as they backtest? While backtesting the option for intrabar = false is utilized correctly, but in live execution the intrabar = false is executed intrabar regardless.

My question is: How can I stop this from executing intrabar?

Wouldn't I be correct to assume that while using

Code: Select all

[IntrabarOrderGeneration = false]

execution should be halted until the close of the bar? Obviously I'm incorrect according to your topic #3, but why would backtests show differently?


I have corrected the above to post #3.

For non-Global Exits,
you have to code the exits specifically.

eg.

Code: Select all

if exit.condition = true then
BUYTOCOVER ("Sx1") next bar at 1000 STOP;

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby MAtricks » 14 May 2012

TJ, thanks for your replies. I'll give it a shot with a couple lines of EL.

I know we've covered the topic, but why would the generic breakeven stop have the line of code:

Code: Select all

[IntrabarOrderGeneration = false]
if this isn't possible with this stop? Odd..

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby TJ » 14 May 2012

MAtricks wrote:TJ, thanks for your replies. I'll give it a shot with a couple lines of EL.

I know we've covered the topic, but why would the generic breakeven stop have the line of code:

Code: Select all

[IntrabarOrderGeneration = false]
if this isn't possible with this stop? Odd..


The IntrabarOrderGeneration has nothing to do with Global Exits.
or should I say, Global Exits have nothing to do with IntrabarOrderGeneration.

When people need to get out, they want to get out, NOW !

In a fast market, if you wait until next bar, you might not be able to get out, let alone breaking even.

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby MAtricks » 14 May 2012

I understand the dangers of wanting to get out and not being able to.

My question is, why does the code even have that line in it?

Breakeven stops supplied by Multicharts:

Code: Select all

[IntrabarOrderGeneration = false] //WHY is this here????
inputs: PositionBasis( false ), FloorAmt( 1 ) ;

if PositionBasis then
   SetStopPosition
else
   SetStopShare ;

SetBreakeven( FloorAmt ) ;

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby TJ » 14 May 2012

MAtricks wrote:I understand the dangers of wanting to get out and not being able to.

My question is, why does the code even have that line in it?

Breakeven stops supplied by Multicharts:

Code: Select all

[IntrabarOrderGeneration = false] //WHY is this here????
inputs: PositionBasis( false ), FloorAmt( 1 ) ;

if PositionBasis then
   SetStopPosition
else
   SetStopShare ;

SetBreakeven( FloorAmt ) ;



That line is not meant for the Global Exits.

It is for the strategy as a whole.
A strategy has to be either
[IntrabarOrderGeneration = false] (default)
or
[IntrabarOrderGeneration = true]

Either way has no bearing on how the Global Exits operate.

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby MAtricks » 14 May 2012

Gotcha. Thanks for the tidbits. They're much appreciated.

I'm assuming no one has a breakeven exit that works similarly to the generic one, but one that can be controlled, ie: not exit on the entry bar which makes this function next to useless?

User avatar
Henry MultiСharts
Posts: 8443
Joined: 25 Aug 2011
Has thanked: 1207 times
Been thanked: 2703 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby Henry MultiСharts » 15 May 2012

MAtricks wrote:Gotcha. Thanks for the tidbits. They're much appreciated.

I'm assuming no one has a breakeven exit that works similarly to the generic one, but one that can be controlled, ie: not exit on the entry bar which makes this function next to useless?

Hello MAtricks,

Per SetBreakEven description:
SetBreakEven function is evaluated intra-bar and not only on close of a bar, and can exit within the same bar as the entry.

Breakeven Stop study code is open and you can modify/use it according to your needs.

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby MAtricks » 15 May 2012

Breakeven stop is intrabar, yes I understand that.

I want to know if there's a way to delay the stop from exiting on the entry bar?

From what TJ's #3 post says I shouldn't do something like:

Code: Select all

if BarsSinceEntry = 1 then begin
     Setstopposition ;
     SetBreakEven ;
end ;

User avatar
Henry MultiСharts
Posts: 8443
Joined: 25 Aug 2011
Has thanked: 1207 times
Been thanked: 2703 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby Henry MultiСharts » 15 May 2012

That is correct.

Code: Select all

 if BarsSinceEntry >= 1 then begin
     Setstopposition ;
     SetBreakEven ;
end;

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Breakeven Stop with intrabar set to false executes intra

Postby MAtricks » 15 May 2012

Thank you :)


Return to “MultiCharts”