Problem with maxbarback with different data resolution  [SOLVED]

Questions about MultiCharts and user contributed studies.
henrywl
Posts: 26
Joined: 28 Jun 2012
Has thanked: 2 times
Been thanked: 1 time

Problem with maxbarback with different data resolution

Postby henrywl » 25 Sep 2012

For example, Data1 with 1 minute resolution and let say indiciator MACD(5, 34, 5) and Data2 with 5 miniute resolution with indicator MACD(5, 34, 5). When I set the MaxBarBack Reference to 6 or something like that, then the autotrade entry will depend on the Data2's 5min resolution signal, however, the autotrade won't start until like over 100 bar of 1 minute bars in which is really what I don't want. As after 35 bars of 1 min bar, the 5min MACD would start plotting the graph base on the calculation, then how come we can't start using the 5 min MACD plotting as an entry for the autotrade and would instead wait until over 100 bars of 1 min bar to get the strategy started.

Am I missing something over the setting. Thanks

User avatar
Henry MultiСharts
Posts: 8397
Joined: 25 Aug 2011
Has thanked: 1201 times
Been thanked: 2686 times

Re: Problem with maxbarback with different data resolution

Postby Henry MultiСharts » 25 Sep 2012

Hello Henrywl,

Please attach screenshots demonstrating this behavior and explain in details what the problem is exactly. How are indicator and strategy calculations connected in your case ?
If you are using a custom strategy code-please attach it to your post as well as the workspace you are using.

henrywl
Posts: 26
Joined: 28 Jun 2012
Has thanked: 2 times
Been thanked: 1 time

Re: Problem with maxbarback with different data resolution

Postby henrywl » 26 Sep 2012

The autotrade execution just won't start.

var0 = MACD( Close of Data2, FastLength, SlowLength ) Data2;
var1 = XAverage( var0, MACDLength ) Data2;
var2 = var0 - var1 ;
condition3 = var2 > 0;
if condition3 then
begin
if marketposition_checked(0) <> 1 then
Buy ( "LE(1)" ) Next bar AT Market;
end
else
begin
if marketposition_checked(0) <> -1 then
Sell Short ( "SE(1)" ) Next bar At Market;
end;

As I suppose the code should start execution as long as the MACD for the 5 min chart start collecting data, however, it doesn't even I keep on change the max reference bar back
Attachments
Capture_1452.jpg
strategy property
Capture_1452.jpg (42.01 KiB) Viewed 216 times
Capture_1451.jpg
workspace
Capture_1451.jpg (191.58 KiB) Viewed 207 times
Capture_1450.jpg
error message
Capture_1450.jpg (74.66 KiB) Viewed 210 times

henrywl
Posts: 26
Joined: 28 Jun 2012
Has thanked: 2 times
Been thanked: 1 time

Problem with BarBack Reference

Postby henrywl » 26 Sep 2012

Problem as attached error message!!

Data1 with 1 minute resolution and indiciator MACD(5, 34, 5) and Data2 with 5 miniute resolution with indicator MACD(5, 34, 5). When I set the MaxBarBack Reference to 6 or something like that, then the strategy entry will depend on the Data2's 5min resolution signal, however, the autotrade won't start until like over 100 bar of 1 minute bars in which is really what I intended. As after 35 bars of 1 min bar, the 5min MACD (Data2 5min) would start plotting the graph base on the calculation, then how come we can't start using the 5 min MACD plotting as an entry for the autotrade and would instead wait until over 100 bars of 1 min bar to get the strategy started.

The autotrade execution just won't start.

Code: Select all

var0 = MACD( Close of Data2, FastLength, SlowLength ) Data2;
var1 = XAverage( var0, MACDLength ) Data2;   
var2 = var0 - var1 ;
condition3 = var2 > 0;
if condition3 then
   begin
      if marketposition_checked(0) <> 1 then
         Buy ( "LE(1)" ) Next bar AT Market;
   end
else
   begin
      if marketposition_checked(0) <> -1 then
         Sell Short ( "SE(1)" ) Next bar At Market;
   end;


As I suppose the code should start execution as long as the MACD for the 5 min chart start collecting data, however, it doesn't and even I keep on change the max reference bar back
Attachments
Capture_1457.jpg
Another error message
Capture_1457.jpg (8.8 KiB) Viewed 209 times
Capture_1451.jpg
WorkSpace
Capture_1451.jpg (191.58 KiB) Viewed 197 times
Capture_1450.jpg
error message
Capture_1450.jpg (74.66 KiB) Viewed 200 times

User avatar
TJ
Posts: 6523
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: Problem with BarBack Reference

Postby TJ » 26 Sep 2012

henrywl wrote:Problem as attached error message!!

Data1 with 1 minute resolution and indiciator MACD(5, 34, 5) and Data2 with 5 miniute resolution with indicator MACD(5, 34, 5). When I set the MaxBarBack Reference to 6 or something like that, then the strategy entry will depend on the Data2's 5min resolution signal, however, the autotrade won't start until like over 100 bar of 1 minute bars in which is really what I intended. As after 35 bars of 1 min bar, the 5min MACD (Data2 5min) would start plotting the graph base on the calculation, then how come we can't start using the 5 min MACD plotting as an entry for the autotrade and would instead wait until over 100 bars of 1 min bar to get the strategy started.

The autotrade execution just won't start.

var0 = MACD( Close of Data2, FastLength, SlowLength ) Data2;
var1 = XAverage( var0, MACDLength ) Data2;
var2 = var0 - var1 ;
condition3 = var2 > 0;
if condition3 then
begin
if marketposition_checked(0) <> 1 then
Buy ( "LE(1)" ) Next bar AT Market;
end
else
begin
if marketposition_checked(0) <> -1 then
Sell Short ( "SE(1)" ) Next bar At Market;
end;

As I suppose the code should start execution as long as the MACD for the 5 min chart start collecting data, however, it doesn't and even I keep on change the max reference bar back


see section on MaxBarsBack
https://www.multicharts.com/trading-soft ... ripts_Work



ps. Please use code tag when posting codes. It makes reading easier.
Highlight the codes you are about to post, then click on the [Code] button located at the top of the message window.

I have tagged your code for you in your post.

henrywl
Posts: 26
Joined: 28 Jun 2012
Has thanked: 2 times
Been thanked: 1 time

Re: Problem with BarBack Reference

Postby henrywl » 26 Sep 2012

Hello Tj,

I have read the MaxBarBack already.. but still doesn't help, I still don't know what's going on with the error message I attached. In the Code, I use MACD only.

However, without 2 data series and apply with MACD the maxbarback I can be use is 1.

Thanks.

User avatar
TJ
Posts: 6523
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: Problem with BarBack Reference

Postby TJ » 26 Sep 2012

henrywl wrote:Hello Tj,

I have read the MaxBarBack already.. but still doesn't help, I still don't know what's going on with the error message I attached. In the Code, I use MACD only.

However, without 2 data series and apply with MACD the maxbarback I can be use is 1.

Thanks.


Why do you want to set the maxbarsback to 6?


The number of bars required for 5 min MACD(5, 34, 5) on a 1 min chart:

34 + 5 = 39

39 times 5 (for the 1 min chart) = 195.

henrywl
Posts: 26
Joined: 28 Jun 2012
Has thanked: 2 times
Been thanked: 1 time

Re: Problem with BarBack Reference

Postby henrywl » 27 Sep 2012

TJ wrote:
henrywl wrote:Hello Tj,

I have read the MaxBarBack already.. but still doesn't help, I still don't know what's going on with the error message I attached. In the Code, I use MACD only.

However, without 2 data series and apply with MACD the maxbarback I can be use is 1.

Thanks.


Why do you want to set the maxbarsback to 6?


The number of bars required for 5 min MACD(5, 34, 5) on a 1 min chart:

34 + 5 = 39

39 times 5 (for the 1 min chart) = 195.


Thx, I am kind of seeing the problem now, but I have one more question is that, at the same time, I am applying RSI(9) for the 1 min chart together with MACD(5, 34, 5) with the 5 min chart. By executing such strategy, I have to set the max bar back to 9 for the RSI, however, since RSI(9) for Data1(1 min) and MACD(5) for Data2(5 min) in the same signal, I intend to use MaxBarBack with 5 instead of 9, because the strategy won't start executed until after the 9th bar of the 5 min MACD chart, I would like to use the 5min MACD signal right after the 5th bar of the 5 min chart.

RSI(9) of Data1 = start after 9 minute
MACD(5, 34, 5) of Data2 = 9x5 minute start after 45 minute instead of 5x5 minute

Seems the code couldn't distinguish between the different data resolution with the max bar back option.. since by default I assume the max bar back should use Data1's resolution as a default calculation.

Is there any otherway, I can work around it. Thank you.

User avatar
TJ
Posts: 6523
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: Problem with BarBack Reference  [SOLVED]

Postby TJ » 27 Sep 2012

henrywl wrote:Thx, I am kind of seeing the problem now, but I have one more question is that, at the same time, I am applying RSI(9) for the 1 min chart together with MACD(5, 34, 5) with the 5 min chart. By executing such strategy, I have to set the max bar back to 9 for the RSI, however, since RSI(9) for Data1(1 min) and MACD(5) for Data2(5 min) in the same signal, I intend to use MaxBarBack with 5 instead of 9, because the strategy won't start executed until after the 9th bar of the 5 min MACD chart, I would like to use the 5min MACD signal right after the 5th bar of the 5 min chart.

RSI(9) of Data1 = start after 9 minute
MACD(5, 34, 5) of Data2 = 9x5 minute start after 45 minute instead of 5x5 minute

Seems the code couldn't distinguish between the different data resolution with the max bar back option.. since by default I assume the max bar back should use Data1's resolution as a default calculation.

Is there any otherway, I can work around it. Thank you.

Maxbarsback applies to the indicator as a whole.
The minimum maxbarsback is the largest value of all the calculations of all the dataseries in that indicator.
These users thanked the author TJ for the post (total 2):
henrywlHenry MultiСharts


Return to “MultiCharts”