Entry EOB Target/Stop intrabar  [SOLVED]

Questions about MultiCharts and user contributed studies.
Dirk8
Posts: 26
Joined: 24 Mar 2014
Has thanked: 10 times
Been thanked: 1 time

Entry EOB Target/Stop intrabar

Postby Dirk8 » 11 Nov 2015

Hello,

I've read https://www.multicharts.com/trading-sof ... Calculated and i'm using now [IntrabarOrderGeneration=true]

So that the profit target and stoploss of X point will be executed intrabar.

Altough, the entrysignal (long/short) should be End Of Bar.

Is that possible?


MultiCharts64 Version 9.0 Release (Build 11210)

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Entry EOB Target/Stop intrabar

Postby TJ » 11 Nov 2015

Hello,

I've read https://www.multicharts.com/trading-sof ... Calculated and i'm using now [IntrabarOrderGeneration=true]

So that the profit target and stoploss of X point will be executed intrabar.

Altough, the entrysignal (long/short) should be End Of Bar.

Is that possible?


MultiCharts64 Version 9.0 Release (Build 11210)
Without your codes, if it difficult to give a definitive answer.

When you are using [IntrabarOrderGeneration=true],
and you want entrysignal to execute EOB,
you have to add BARSTATUS=2.

eg.

Code: Select all


if barstatus=2 then
begin
// your entrysignal <<--- ENTRY, you asked for EOB ENTRY only
end;

// put your intrabar signals here <<--- put your intrabar signals here OUTSIDE of the barstatus=2


Dirk8
Posts: 26
Joined: 24 Mar 2014
Has thanked: 10 times
Been thanked: 1 time

Re: Entry EOB Target/Stop intrabar

Postby Dirk8 » 11 Nov 2015

I implemented it and it indeed seems that the entry is EOB altough the [IntrabarOrderGeneration=true] is used. Which is good.

But now also the profit and the stoploss are end of bar.

In the code I used the barstatus where I should expect it counts only for entries (LE, SE) and stops (LongSL, ShortSL) to use EOB. Not for profittargets (LX, SX), those should be intrabar..

Something not correct?

Code: Select all


if MarketPosition =0 then begin

if (barstatus=2 and le) and not lx and not se then begin
buy ("Long ") next bar open;
end;

if (barstatus=2 and se) and sx = false and le = false then begin
sellshort ("Short ") next bar open;
end;
end

else if MarketPosition = 1 then begin

if lx or (barstatus=2 and Longsl) then begin
if se then begin
sellshort ("Short") next bar open;
end;
end;

if lx then begin
sell ("LongExit") next bar open;
end;

if barstatus=2 and Longsl then begin
sell ("LongSL") next bar open;
end;
end

else if MarketPosition = -1 then begin

if sx or (barstatus=2 and Shortsl) then begin
if le then begin
buy ("Long") next bar open;
end;
end;

if sx then begin
buytocover ("ShortExit") next bar open;
end;

if (barstatus=2 and Shortsl) then begin
buytocover ("ShortSL") next bar open;
end;
end;

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Entry EOB Target/Stop intrabar

Postby TJ » 11 Nov 2015

I implemented it and it indeed seems that the entry is EOB altough the [IntrabarOrderGeneration=true] is used. Which is good.

But now also the profit and the stoploss are end of bar.

In the code I used the barstatus where I should expect it counts only for entries (LE, SE) and stops (LongSL, ShortSL) to use EOB. Not for profittargets (LX, SX), those should be intrabar..

Something not correct?
::
I don't see your [IntrabarOrderGeneration=true].

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Entry EOB Target/Stop intrabar

Postby TJ » 11 Nov 2015

The devil is in the details.


Your snippet looks ok.
You just have to check every detail that is not in this snippet.

Dirk8
Posts: 26
Joined: 24 Mar 2014
Has thanked: 10 times
Been thanked: 1 time

Re: Entry EOB Target/Stop intrabar

Postby Dirk8 » 11 Nov 2015

The [IntrabarOrderGeneration=true] was above.
Because it didn't worked as expected, i tried to use the statusbar in the definition of the LE, SE and the stops. But with no different outcome.

This is the full code.

Inputs:
TargetL(11), TargetS(11), ExitL(50), ExitS(50), FixStop(20);

variables:
LE(false), LX(false), Longsl(false), SE(false), SX(false), Shortsl(false);

[IntrabarOrderGeneration=true]

LE = barstatus=2 and close > average(close,10) ;

LX = MarketPosition = 1 and barstatus=2 and c > (entryprice + TargetL) ;

Longsl = barstatus=2 and MarketPosition = 1 and Close < (EntryPrice - Exitl) ;

SE = barstatus=2 and close < average(close,10) and close < Average(close,15) ;

SX = MarketPosition = -1 and barstatus=2 and c < (entryprice - TargetS) ;
Shortsl = barstatus=2 and MarketPosition = -1 and Close > (EntryPrice + ExitS) or c > Average(close,20) ;

setexitonclose;

if MarketPosition =0 then begin

if le and not lx and not se then begin
buy ("Long ") next bar open;
end;

if se and sx = false and le = false then begin
sellshort ("Short ") next bar open;
end;
end

else if MarketPosition = 1 then begin

if lx or Longsl then begin
if se then begin
sellshort ("Short") next bar open;
end;
end;

if lx then begin
sell ("LongExit") next bar open;
end;

if Longsl then begin
sell ("LongSL") next bar open;
end;
end

else if MarketPosition = -1 then begin

if sx or Shortsl then begin
if le then begin
buy ("Long") next bar open;
end;
end;

if sx then begin
buytocover ("ShortExit") next bar open;
end;

if Shortsl then begin
buytocover ("ShortSL") next bar open;
end;
end;
Included the strategy properties
Attachments
strategy_prop.JPG
StrategyProp
(60.72 KiB) Downloaded 755 times

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Entry EOB Target/Stop intrabar

Postby TJ » 11 Nov 2015

The [IntrabarOrderGeneration=true] was above.
Because it didn't worked as expected, i tried to use the statusbar in the definition of the LE, SE and the stops. But with no different outcome.
Have you looked up the meaning and application of BARSTATUS ?


The link to Wiki is at the top of the page under the Support tab.

Dirk8
Posts: 26
Joined: 24 Mar 2014
Has thanked: 10 times
Been thanked: 1 time

Re: Entry EOB Target/Stop intrabar

Postby Dirk8 » 12 Nov 2015

Had a search on forum but not in wiki. (stupid me :-) )

I try to understand the concept of barstatus and I think this will do the trick but in practice I don't see always direct impact on the signals.

Can I combine it like here?

Code: Select all

LE = barstatus=2 and close > average(close,10) ;
LX = MarketPosition = 1 and barstatus=2 and c > (entryprice + TargetL) ;
Longsl = barstatus=1 and MarketPosition = 1 and Close < (EntryPrice - Exitl) ;
SE = barstatus=2 and close < average(close,10) and close < Average(close,15) ;
SX = MarketPosition = -1 and barstatus=2 and c < (entryprice - TargetS) ;
Shortsl = barstatus=2 and MarketPosition = -1 and Close > (EntryPrice + ExitS) or c > Average(close,20) ;
Or should I use it in the if then else condition concering the marketposition?
Like here:

Code: Select all

else if MarketPosition = 1 then begin

if lx or (Longsl and barstatus=1) then begin
if se then begin
sellshort ("Short") next bar open;
end;
end;

if lx then begin
sell ("LongExit") next bar open;
end;

if Longsl and barstatus=1 then begin
sell ("LongSL") next bar open;
end;
end

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Entry EOB Target/Stop intrabar  [SOLVED]

Postby TJ » 12 Nov 2015

Had a search on forum but not in wiki. (stupid me :-) )

I try to understand the concept of barstatus and I think this will do the trick but in practice I don't see always direct impact on the signals.

Can I combine it like here?
::
Please go back to the Wiki and read the definition of Barstatus again.

Please go back to post #2 and read my answer again.

I have edited it and highlighted the important points.

"Barstatus=2" is not a magic bullet;
applying it blindly or indiscriminately will not get the precision result you want.

Dirk8
Posts: 26
Joined: 24 Mar 2014
Has thanked: 10 times
Been thanked: 1 time

Re: Entry EOB Target/Stop intrabar

Postby Dirk8 » 14 Nov 2015

The barstatus should do the trick. Many thanks.
Consider it as solved.


Return to “MultiCharts”