Hello guys
Could you please help me clarify why the following code produce different number of trades (depending on PositionSize).
The thing is I don't see the following error if the positionsize is the problem:
Notice 802: Trade size limit of 10% of entry bar volume has been hit N times. Check your Settings 'Portfolio' tab, position sizing
Thank you in advance!
SetOption("MaxOpenPositions", 100);
SetOption("AllowSameBarExit", False);
SetTradeDelays(1,1,1,1);
// Set the risk per share and position risk as before
RiskPerShare = 2 * ATR(20);
PositionRisk = 0.1;
// Calculate the position size for long and short trades separately
PctSizeLong = PositionRisk * BuyPrice / RiskPerShare;
PctSizeShort = PositionRisk * ShortPrice / RiskPerShare;
// Set different position sizes for long and short trades using conditional statements
// If it's a long trade, use PctSizeLong; otherwise, use PctSizeShort
BuyPrice = Open;
SellPrice = Open;
ShortPrice = Open;
CoverPrice = Open;
value_optimize = Optimize("std_refDays", 360, 5, 365, 10);
priceReturn = abs(C - Ref(C, -1));
hisSTD = abs(ln(StDev(priceReturn,365,True))); //standard deviation for the past 365 days
std = ln(StDev(priceReturn,value_optimize,True));
Buy = C >= HHV(C, 10) AND std <= 1.01*hisSTD and C >= MA(C,200);
Sell = C <= LLV(C, 10);
Short = C <= LLV(C,10) AND std >= 1.02*hisSTD;
Cover = C >= HHV(C, 5);
//Here if we test wuth dufferebt PositionSizes we produce different number of trades
//SetPositionSize( IIf(Buy, PctSizeLong, IIf(Short, PctSizeShort, 0)), spsPercentOfEquity );
//SetPositionSize(1, spsPercentOfEquity );