I have used the custom contract. Back adjusted for the YM, which i am trying to trade for this. This is fine. also when i just use 1 data stream it trades fine. The only problem is shifting from 1 data stream to 2 data streams in order to actually execute on the current front month contract. I just dont understand why it isn't doing that. All my variables are valid and it trades fine on a single data stream custom contract. I have used print to debug as well as indicator. I have tried shifting the calculations to data2 then just leave the buy/sell statements. I use a custom contract and have it plot and execute on back test on that single stream.
here is a more complicated code that also has the same problem. I posted the most simple system that contains the problem assuming it could be fixed easily and i could transfer that info into more of my systems that require it.
Code: Select all
Input:
//Price Channel
LookBack ( 7 ),
//SMA Bias Filter
MAlength ( 200 );
Variables:
// Price Channel
HighBar ( 0 ), LowBar ( 0 ),
// System Variables
LongBias (false),
//SMA bias filter
SMAvalue ( 0 ),
//Trend Strength Index
TSIvalue ( 0 ),
// Adaptive Profit Target/ Entry
ProfitTarget ( 0 ) , EnterLongPrice ( 0 );
{Simple Moving Average Calculations}
SMAvalue = Average(Close data2, MALength );
{Set Trend Bias Logic}
If Close data2 > SMAValue then
LongBias = True
else
Longbias = False;
{Trend Strength Index}
TSIvalue = TrendStrengthIndex(10) data2;
// Adaptive Entry
IF TSIvalue[1] > TSIvalue[0] then
EnterLongPrice = Lowest(Low data2, LookBack)[1]
else
EnterLongPrice = Lowest(Close data2, LookBack)[1];
{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]
else
ProfitTarget = Highest(Close data2, LookBack)[1];
IF MP = 1 then
Sell (" 77 LX") next bar at ProfitTarget Limit;
http://my.jetscreenshot.com/12147/20120930-9bt3-171kb
screenshot of plots on single datastream as you can see its all valid.