Dynamic Position

Hi in my strategy I only wanna trade on Monday to Thursday and eliminate Friday
Also would like to dynamically set position sizing i.e. Monday - Wed 10% but Thursday would be 5% of the equity.

Here is the code snippet, am i on right track or can this be done in a different way.

NoTradeDay = DayofWeek() != 5;
LongEntry = entryCondition1 AND entryCondition2 AND  NoTradeDay;
LongExit = exitCondition1;

// Dynamic Position Size
PosSiz = IIf(DayOfWeek() == 4, 5, 10);
SetPositionSize(PosSiz, spsPercentOfEquity);

Thanks

1 Like

Blockquote
// Dynamic Position Size
PosSiz = IIf(DayOfWeek() == 4 OR DayOfWeek() == 5, 10,0);
SetPositionSize(PosSiz, spsPercentOfEquity);

@subsoft - Yes your code is fine.

@Muli code is INCORRECT. If you don't want to open position you should just NOT generate signals, instead of setting position size to zero.

1 Like

Thanks for the response @Tomasz and @Muli

@Muli : I am not sure if you have checked the condition

// If the day of the week is Thursday, I would set the position size to be 5% else %10
PosSiz = IIf(DayOfWeek() == 4, 5, 10);