Issues: In between trades | All trades are not considering

Hi Community!


I'm encountering an issue with my trading strategy where I'm receiving a Long Trade Signal even when a Short trade is already in progress, and vice versa.

The primary challenge is ensuring that the strategy generates the appropriate signals based on the existing trade status. I'm seeking assistance in refining the logic to prevent conflicting signals and enhance the overall performance of the strategy.

newday = Day() != Ref(Day(),-1);

Buy =  ( (Ref(BC, -1) AND HaClose > ValueWhen(BC, HaOpen) ) OR ( B1 ) ) AND TradesOpenTime ;
Buy = Ref(Buy,-1) ;

iSell = TradesCloseTime ;

Buy = ExRem(Buy, iSell);
isell = ExRem(iSell, Buy);

BuyPrice = Valuewhen(Buy, Open);

BuyStop = BuyPrice - stops;
BuyTarget = BuyPrice + target;

Sell = isell OR Cross(H, BuyTarget) OR ValueWhen(C, H >= BuyTarget) OR Cross(Buystop, L) OR ValueWhen(C, L <= BuyStop) ;

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

SellPrice = ValueWhen( Sell, IIf( Cross( H, BuyTarget ) OR ValueWhen( C, H >= BuyTarget ), BuyTarget, IIf( Cross(Buystop, L) OR ValueWhen( C, L <= BuyStop), Buystop,Open ) ) ) ;

Short = ( (Ref( SC, -1 ) AND HaClose < ValueWhen( SC, HaOpen ) ) OR ( S1 ) ) AND TradesOpenTime ;
Short = Ref(Short,-1);

iCover = TradesCloseTime ; 

Short = ExRem(Short, iCover);
iCover = ExRem(iCover, Short);

ShortPrice = Valuewhen(Short, Open);

ShortStop = ShortPrice + stops;
ShortTarget = ShortPrice - target;

cover = icover OR Cross(H, Shortstop) OR ValueWhen(C, H >= ShortStop) OR Cross(ShortTarget, L) OR ValueWhen(C, L <= ShortTarget);

Short = ExRem(Short, Cover);
Cover = ExRem(Cover, Short);

CoverPrice = ValueWhen( Cover, IIf( Cross( ShortTarget, L ) OR ValueWhen( C, L <= ShortTarget ), ShortTarget, IIf( Cross( H, Shortstop ) OR ValueWhen( C, H >= ShortStop),Shortstop ,Open ) ) );

Buy = Buy AND Sum(Buy OR Short , BarsSince(newday) + 1 ) <= LimitTrades AND BarsSince(Short) > BarsSince(Cover) ; 
Short = Short AND Sum(Short OR Buy , BarsSince(newday) + 1) <= LimitTrades AND BarsSince(Buy) > BarsSince(Sell) ; 

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

Short = ExRem(Short, Cover);
Cover = ExRem(Cover, Short); 

I'm facing a second issue with my strategy. Despite observing multiple instances where Long and Short conditions are met within a day, my strategy seems to consider only two trades per day—specifically, one Long and one Short.

This occurs even when I include or exclude the Trade Limit code.

While I've plotted all bars where the conditions are met, the strategy is only taking into account a total of two trades daily, restricting it to one Long and one Short, and not allowing for variations such as multiple Longs or multiple Shorts on the same day.

I'm seeking assistance in understanding and resolving this limitation.

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