strategy stuck in calculating mode. Using 2 sets of data

Questions about MultiCharts and user contributed studies.
MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

strategy stuck in calculating mode. Using 2 sets of data

Postby MeiHua » 29 Nov 2012

I am developing a trading strategy. I am using data2 for calculation and data1 for execution. However I have had problems, that are two fold. 1) The strategy doesn't execute on the data1 set if it doesn't have 200 or more periods ( i am using a 200 period MA on data2). 2) It now is suck calculating.... and never changes. help?

Code: Select all

Input:
//Price Channel
LookBack ( 7 ),
//SMA Bias Filter
MAlength ( 200 );

Variables:
Int MP( 0 ), // *** add this variable
// Price Channel
HighBar ( 0 ), LowBar ( 0 ),
// System Variables
LongBias (false),
//SMA bias filter
SMAvalue ( 0, Data2 ), // *** alias to 2nd data streams
//Trend Strength Index
TSIvalue ( 0 ),
// Adaptive Profit Target/ Entry
ProfitTarget ( 0, Data2 ) , EnterLongPrice ( 0, Data2 ) ; // *** alias to 2nd data streams


// *** Add this assignment of market position to MP
MP = MarketPosition ;

{Simple Moving Average Calculations}
SMAvalue = Average(Close data2, MALength ) of data2;

{Set Trend Bias Logic}

If Close data2 > SMAValue then
LongBias = True
else
Longbias = False;

{Trend Strength Index}
TSIvalue = TrendStrengthIndex(10) of data2;

// Adaptive Entry

IF TSIvalue[1] > TSIvalue[0] then
EnterLongPrice = Lowest(Low data2, LookBack)[1] of Data2
else
EnterLongPrice = Lowest(Close data2, LookBack)[1] of Data2 ;


{Order Logic and Entry}
If LongBias = true then
Buy (" 77 LE" ) next bar at(EnterLongPrice - 1 point) limit ;

{Trade Exit}

// Adaptive Exit

IF TSIvalue < 1.65 then
ProfitTarget = Highest(High data2, Lookback)[1] of Data2
else
ProfitTarget = Highest(Close data2, LookBack)[1] of Data2 ;

IF MP = 1 then
Sell (" 77 LX") next bar at ProfitTarget Limit;

Print("LongBias: ", LongBias, "TSI: ", TSIvalue );
http://my.jetscreenshot.com/12147/20121129-0ztb-52kb

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

Re: strategy stuck in calculating mode. Using 2 sets of data

Postby Henry MultiСharts » 29 Nov 2012

Hello MeiHua,

Please check the max bars back value in Format->Strategy properties->Properties tab.
The value should be set to suit your study calculation. If you are using MA 200 then it should be set to 200.
On your chart for both data series you should have more bars than it is set in max bars back field (>200) to have strategy calculation results.

MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

Re: strategy stuck in calculating mode. Using 2 sets of data

Postby MeiHua » 29 Nov 2012

I have it set to 200, however the 1st data set can NOT have 200 bars in it. Due to futures roll over. I need the calculations to be done on the 2nd data set and executed on the 1st data set which will in inherently have less than 200 bars of data. Is this possible?

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

Re: strategy stuck in calculating mode. Using 2 sets of data

Postby Henry MultiСharts » 30 Nov 2012

When a study is referencing additional dataseries the highest max bars back value used by the study is applied to all dataseries. You need to have more than 200 bars on your data1 in order to have the strategy calculated. You can create a custom futures to have continuous data on the chart.

MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

Re: strategy stuck in calculating mode. Using 2 sets of data

Postby MeiHua » 30 Nov 2012

Yes I have a custom futures contract, However if i use custom futures in data1, then it will never execute a real trade using the current contract. How can I get it to execute on YMZ12 but use the custom YM contract for calculation, I think i am in a catch 22.

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

Re: strategy stuck in calculating mode. Using 2 sets of data

Postby Henry MultiСharts » 30 Nov 2012

You need to map your custom futures to the current contract you need to trade using Symbol Mapping.


Return to “MultiCharts”