Exclude new signals from pairs of tickers

I have two pairs of tickers, XYZ1 and XYZ2, and ZYZ1 and ZYX2. I would like the system NOT to take a new long position in some cross pairs; specifically, no new long position in ZYX1 when there is an open long in XYZ1, and vice versa, and NOT a new long position in ZYX2 when there is an open position in YXZ2, and vice versa. I tried this with flip(buy, sell) for each symbol as follows:

if ( Name () == "XYZ1" ) { 

//system code

intradeXYZ1=flip(buy, sell);

buy=iif(intradeZXY1,0,1);

}

if ( Name () == "XYZ2" ) { 

//system code

intradeXYZ2=flip(buy, sell);

buy=iif(intradeZXY2,0,1);

}


if ( Name () == "ZYX1" ) { 

//system code

intradeZYX1=flip(buy, sell);

buy=iif(intradeXYZ1,0,1);

}

if ( Name () == "ZYX2" ) { 

//system code

intradeXYZ2=flip(buy, sell);

buy=iif(intradeXYZ1,0,1);

}

I get the impression this is spaghetti code I wrote, and it does not work, by the way. Any suggestions? Thanks.

You haven't provided working code, nor have you fully described your system, so it's pretty hard to suggest a reasonable solution. Personally, I typically use a CBT when I need logic that determines whether or not to ignore a trade signal. However, depending on your system, you might be able to use something as simple as PositionScore to solve your problem.

Thanks. CBT is the proper solution. I have to read more.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.