IntrabarOrderGeneration wiki

Questions about MultiCharts and user contributed studies.
mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

IntrabarOrderGeneration wiki

Postby mefTrader » 04 Apr 2012

Is there a wiki for 'IntrabarOrderGeneration' strategy coding development/execution and debug?

I have a 1min strategy with IntrabarOrderGeneration=true and I have noticed quite a big difference between live results and back tested results

I noticed that I had not the bar magnifier set to tick data so I am trying that now.

Rather than 'guessing' this I would like to know if there is something like a 'wiki' available based on this development and testing available?

Please advise. Thanks

mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

Re: IntrabarOrderGeneration wiki

Postby mefTrader » 04 Apr 2012

When 'backtesting precision' is set to tick data I am getting the following error
Message: Not all of the required data has been obtained. Bar Magnifier mode will
be disabled.
What can I do next to be able to back test a strategy with IntrabarOrderGeneration=true with tick data precision??

mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

Re: IntrabarOrderGeneration wiki

Postby mefTrader » 04 Apr 2012

When "IntrabarOrderGeneration" is set to true are ALL calculations done on a close of a tick bar?

Example code

Code: Select all

vars: MP(0), IntraBarPersist stop_loss_long(0), IntraBarPersist stop_loss_short(0),
intrabarpersist isLong(0), intrabarpersist isShort(0);
MP=marketposition;

if (MP[0]=0) then
begin
stop_loss_long=0;
stop_loss_short=0;
isLong =0;
isShort=0;
end;

//LONG
if ((c[num_bars_long]-c[0]>=abs_volatility_long) and ((long_short=0) or (long_short=1))) then
begin
buy("Long") num_contracts contracts next bar at (c[0]+buystop) stop;
isLong=1;
//stop_loss_long= (entryprice-trail_stop_long);
end;

if (MP[0]=1 and MP[1]=0) then
begin
stop_loss_long= (entryprice-trail_stop_long);
Print(FormatDate("dd/MM/yyyy", ElDateToDateTime(Date))+","+NumToStr(time,0)+", entryprice "+NumToStr(entryprice,5)+", stop_loss_long "+NumToStr(stop_loss_long,5));
end
else if (MP[0]=1)then
begin
stop_loss_long=maxlist(stop_loss_long, close[0]-trail_stop_long);
Print(FormatDate("dd/MM/yyyy", ElDateToDateTime(Date))+","+NumToStr(time,0)+", entryprice "+NumToStr(entryprice,5)+", stop_loss_long "+NumToStr(stop_loss_long,5));
end;
Is all the logic evaluated at the close of a tick bar?
I see some other topics that "BarStatus(1)=2" is being used to check for the close of a tick bar? Do I need to do this

Please advise
Thanks

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: IntrabarOrderGeneration wiki

Postby Henry MultiСharts » 04 Apr 2012

Is there a wiki for 'IntrabarOrderGeneration' strategy coding development/execution and debug?
I have a 1min strategy with IntrabarOrderGeneration=true and I have noticed quite a big difference between live results and back tested results
I noticed that I had not the bar magnifier set to tick data so I am trying that now.
Rather than 'guessing' this I would like to know if there is something like a 'wiki' available based on this development and testing available?
Please advise. Thanks
It is expected that real-time strategy calculation and trading results (live broker account, demo broker account, playback etc...) are different from the performance results generated during backtesting.

• In real-time trading the order is filled according to market dynamics on Bid and Ask prices taking Volume into account. The order may not be filled in real-time trading because of insufficient volume at the broker. In backtesting and real-time strategy calculation the order is filled on the main data series price without taking Volume into account.

• In real-time trading, a strategy will monitor and respond to a data feed on tick-by-tick basis. However, the historical data available for backtesting will, in most cases, be in the form of bars based on a group of ticks, with only Open, High, Low, and Close prices available. While it is not possible from these four values to infer the actual price movement within each bar, the Backtesting Engine improves the backtesting accuracy by incorporating intra-bar price movement assumption logic

• Different detalization and strategy calculation methods can be selected which will produce different results.
  1. Precise Back Testing

    IOG

    Bar Magnifier
    • 1. If you are not using IOG mode for your signal then the signal is calculated on the close of the bar.

      2. In realtime with IOG enabled the script is calculated tick by tick.

      3. Without IOG on history-the script is calculated on the bar close.

      4. With IOG enabled on history-the script is calculated four times on OHLC of the bar.

      5. Bar magnifier is a separate feature for backtesting. Bar magnifier does not affect realtime calculation. Please find more information at the Bar Magnifier wiki page.
• There are differences in real-time data and historical data that affect the strategy calculation results. You should understand how chart bars are built. A single tick difference between real-time and historical backfilled data can generate completely different looking charts. This in turn would impact the calculations of your strategy.

• The difference in strategy calculation is especially seen on certain chart types (e.g. Point and Figure) than others due to their inherent nature in bar formation. Please refer to this page for more details.
This is why you may see orders not fill in real-time strategy calculation or real-time strategy trading compared to your backtesting results.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: IntrabarOrderGeneration wiki

Postby Henry MultiСharts » 04 Apr 2012

When 'backtesting precision' is set to tick data I am getting the following error
Message: Not all of the required data has been obtained. Bar Magnifier mode will
be disabled.
What can I do next to be able to back test a strategy with IntrabarOrderGeneration=true with tick data precision??
The error message means that bar magnifier is not able to obtain the detailed data from your database or data feed. If your data feed does not provide the requested amount of detailed data-you need to import it to your local database. You can check the amount of provided historical data by all of the supported data feeds at this page.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: IntrabarOrderGeneration wiki

Postby Henry MultiСharts » 04 Apr 2012

When "IntrabarOrderGeneration" is set to true are ALL calculations done on a close of a tick bar?

Example code

Code: Select all

vars: MP(0), IntraBarPersist stop_loss_long(0), IntraBarPersist stop_loss_short(0),
intrabarpersist isLong(0), intrabarpersist isShort(0);
MP=marketposition;

if (MP[0]=0) then
begin
stop_loss_long=0;
stop_loss_short=0;
isLong =0;
isShort=0;
end;

//LONG
if ((c[num_bars_long]-c[0]>=abs_volatility_long) and ((long_short=0) or (long_short=1))) then
begin
buy("Long") num_contracts contracts next bar at (c[0]+buystop) stop;
isLong=1;
//stop_loss_long= (entryprice-trail_stop_long);
end;

if (MP[0]=1 and MP[1]=0) then
begin
stop_loss_long= (entryprice-trail_stop_long);
Print(FormatDate("dd/MM/yyyy", ElDateToDateTime(Date))+","+NumToStr(time,0)+", entryprice "+NumToStr(entryprice,5)+", stop_loss_long "+NumToStr(stop_loss_long,5));
end
else if (MP[0]=1)then
begin
stop_loss_long=maxlist(stop_loss_long, close[0]-trail_stop_long);
Print(FormatDate("dd/MM/yyyy", ElDateToDateTime(Date))+","+NumToStr(time,0)+", entryprice "+NumToStr(entryprice,5)+", stop_loss_long "+NumToStr(stop_loss_long,5));
end;
Is all the logic evaluated at the close of a tick bar?
I see some other topics that "BarStatus(1)=2" is being used to check for the close of a tick bar? Do I need to do this

Please advise
Thanks
When you enable Intrabar Order Generation it enables tick-by-tick (in realtime) calculation for the entire script unless you have restriction conditions like Barstatus=2.

Code: Select all

If Barstatus=2 then ....
will calculate the piece of code under this condition only on the closing tick of the bar.

mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

Re: IntrabarOrderGeneration wiki

Postby mefTrader » 04 Apr 2012

Henry thanks for the info - one further question

what's your defintion of a "closing tick bar"?

Morgan

mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

Re: IntrabarOrderGeneration wiki

Postby mefTrader » 04 Apr 2012

Just to understand Henry

If I have '[IntrabarOrderGeneration = true]' on a 1min chart and then do the following check

Code: Select all


if (C>0) then
begin
.... do something#1
end;

if (BarStatus(1)=2) then
begin
....do something #2
end;
#1 - does something at the close of every tick or on every tick

#2 - does something at the closing tick of a 1min bar?


Am I understanding this correctly?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: IntrabarOrderGeneration wiki

Postby Henry MultiСharts » 05 Apr 2012

Just to understand Henry

If I have '[IntrabarOrderGeneration = true]' on a 1min chart and then do the following check

Code: Select all


if (C>0) then
begin
.... do something#1
end;

if (BarStatus(1)=2) then
begin
....do something #2
end;
#1 - does something at the close of every tick or on every tick

#2 - does something at the closing tick of a 1min bar?


Am I understanding this correctly?
1. A tick is a minimum price movement of a trading instrument. It has only one price i.e. tick by tick = on the close of every tick.
2. That is correct.


Return to “MultiCharts”