Question on Intrabar & bar magnifier

Questions about MultiCharts and user contributed studies.
aczk
Posts: 67
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Question on Intrabar & bar magnifier

Postby aczk » 09 Nov 2012

Hi
Testing a Daily start that buys on the open and exits on the close of the same bar.

I understand that with the bar magnifier the results become more precise, but what about the intrabarordergeneration. With it my 5% stop just wrecks the strategy. Does it mean my stop would not be executed?

Confused?

User avatar
Henry MultiСharts
Posts: 8520
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2741 times

Re: Question on Intrabar & bar magnifier

Postby Henry MultiСharts » 09 Nov 2012

Here is how the scripts are calculated in MultiCharts 8.0:

Realtime normal mode. The script is calculated on the bar close. Order is placed on this bar close/ next bar open. Order is filled on any tick price within the next bar.

In realtime with IOG enabled the script is calculated tick by tick. Order is placed on the next tick. Order is filled on any tick price within the bar.

Calculation on historical data. Regular mode. No IOG. No Bar Magnifier. The script is calculated on the bar close. It is considered that all prices were within the bar (Price movement assumption is used). Order filled on any price within the bar.

Calculation on historical data. IOG enabled. No Bar Magnifier. The script is calculated four times on OHLC. It is considered that all prices were within the bar (Price movement assumption is used). Order filled on any price within the bar with the step (minmove/pricescale).

Calculation on historical data. No IOG. With Bar Magnifier enabled. The script is calculated 1 time on main data series close. MultiCharts considers that there were only OHLC values of the detailed data series->order is filled only on OHLC prices.

Calculation on historical data. IOG and Bar Magnifier enabled. The script is calculated on the Open value of the main data series, then OHLC of each bar of the detailed data series selected in bar magnifier, then on the Close of the main data series. Order is filled only on these O-OHLC-C values.
These users thanked the author Henry MultiСharts for the post (total 2):
sptraderJoshM

aczk
Posts: 67
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Re: Question on Intrabar & bar magnifier

Postby aczk » 11 Nov 2012

so let me see if I understand this correctly in terms of the stops on the daily chart/strategy (after entering at the open on a market order)!?

It is a simple stop:

Code: Select all

if MarketPosition = 1 then SetStopLoss( EntryPrice * StopLossPct ) ;


So in realtime without IOG it should be able to execute on the same day once the stop level is breached!???

In historical testing it would be best to choose ... No IOG. With Bar Magnifier enabled. ?????

Thanks for any further help on this.

User avatar
Henry MultiСharts
Posts: 8520
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2741 times

Re: Question on Intrabar & bar magnifier

Postby Henry MultiСharts » 12 Nov 2012

aczk wrote:So in realtime without IOG it should be able to execute on the same day once the stop level is breached!?

The code you have provided will not work this way. SetStopLoss should not be under a condition in order to be evaluated intrabar when IOG is disabled. Remove the condition and use it separately.
These users thanked the author Henry MultiСharts for the post:
aczk

aczk
Posts: 67
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Re: Question on Intrabar & bar magnifier

Postby aczk » 12 Nov 2012

Thanks

Getting rid of the condition makes the strategy buy and then sell at the same price/time it seems.

So for the backtest a condition is required for live trading not??

Thx

User avatar
Henry MultiСharts
Posts: 8520
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2741 times

Re: Question on Intrabar & bar magnifier

Postby Henry MultiСharts » 13 Nov 2012

In realtime with IOG disabled SetStopLoss will not be placed on the same bar if it is under condition.
If the trade is opened and closed with same price then most probaby the order parameters are incorrect. Please refer to the wiki article for more details on using SetStopLoss

aczk
Posts: 67
Joined: 08 Feb 2012
Has thanked: 8 times
Been thanked: 1 time

Re: Question on Intrabar & bar magnifier

Postby aczk » 25 Jan 2013

Thnaks so far.

Another question. Trading 15 min bars, my market closes at 1710 and I want to submit a market order at 1709 to close my open long position.

Code: Select all

if time > 1709 and marketposition = 1 then sell this bar at close;
[code][/code]


The above does not seem to work in backtesting with or without intrabarordergeneration and/or bar magnifier??? Is it possible to do a time exit like this within a bigger timeframe bar??

Any help appreciated. thx!

User avatar
Henry MultiСharts
Posts: 8520
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2741 times

Re: Question on Intrabar & bar magnifier

Postby Henry MultiСharts » 25 Jan 2013

Hello aczk,

This Bar on Close order is generated on the last tick of the bar. The order is sent on the open of the next bar. The code you have provided will not close the position before the session end in realtime calcualtion.

In realtime calcualtion you can use IntrabarOrderGeneration, "next bar" order command and reference computer time. For example:

Code: Select all

if datetime2eltime(computerdatetime)>= 1709 and marketposition = 1 then sell next bar at market;


The code you have provided works ok in backtesting with IOG & Bar magnifier set to Off:

Code: Select all

if time > 1709 and marketposition = 1 then sell this bar at close;


In order to get precise results in backtesting you can use IOG, Bar magnifier, "next bar" order command, reference bar closing time and enable the option "Enable access to intra-bar time for calcualtion in Intra-bar order generation mode" (Format->Strategy properties->Backtesting tab, nas been added in MC 8.5 beta 2 ). For example:

Code: Select all

if time >= 1709 and marketposition = 1 then sell next bar at market;

User avatar
TJ
Posts: 6598
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1909 times

Re: Question on Intrabar & bar magnifier

Postby TJ » 25 Jan 2013

aczk wrote:Thnaks so far.

Another question. Trading 15 min bars, my market closes at 1710 and I want to submit a market order at 1709 to close my open long position.

Code: Select all

if time > 1709 and marketposition = 1 then sell this bar at close;
[code][/code]


The above does not seem to work in backtesting with or without intrabarordergeneration and/or bar magnifier??? Is it possible to do a time exit like this within a bigger timeframe bar??

Any help appreciated. thx!


re: This Bar on Close
see post #7
viewtopic.php?f=16&t=10811


Return to “MultiCharts”