Conditioning Code to Sequence with Time

Hi,

I am trying to condition the below code based on the dates in each block of code beginning with "if dates are...." In practice I will have many more symbols in each block and many more date sequences. What would be the best way to code this time condition?

Thanks,

Mike

////TimeFrameSet( inMonthly ); // switch to 5 minute frame

SetOption( "DisableRuinStop", True );
//SetOption("HoldMinBars",1);
SetOption("MaxOpenPositions", 3000);
SetOption("AllowPositionShrinking", 1);

BuyPrice=SellPrice=C;

n = Name();
wgt=0;
adjfactor=100;

if dates are greater than 20210205 AND less than or equal to 20210403 then use this code....
if(n=="A")  SetPositionSize(0.000892859323887574*adjfactor,spsPercentofEquity);  if(n=="A") wgt=-0.000892859323887574;
if(n=="AAL")  SetPositionSize(0.000297619774629191*adjfactor,spsPercentofEquity);  if(n=="AAL") wgt=-0.000297619774629191;
if(n=="AAP")  SetPositionSize(0.000892859323887574*adjfactor,spsPercentofEquity);  if(n=="AAP") wgt=-0.000892859323887574;
if(n=="AAPL")  SetPositionSize(0.000297619774629191*adjfactor,spsPercentofEquity);  if(n=="AAPL") wgt=-0.000297619774629191;

if dates are greater than 20210403 AND less or equal to 20210810 then use this code....
if(n=="A")  SetPositionSize(0.000892859323887574*adjfactor,spsPercentofEquity);  if(n=="A") wgt=0.000892859323887574;
if(n=="AAL")  SetPositionSize(0.000297619774629191*adjfactor,spsPercentofEquity);  if(n=="AAL") wgt=0.000297619774629191;
if(n=="AAP")  SetPositionSize(0.000892859323887574*adjfactor,spsPercentofEquity);  if(n=="AAP") wgt=-0.000892859323887574;
if(n=="AAPL")  SetPositionSize(0.000297619774629191*adjfactor,spsPercentofEquity);  if(n=="AAPL") wgt=0.000297619774629191;

//....
//....

Buy= wgt>0;
Short= wgt<0;
    
isEndOfMonth = TimeFrameExpand(1, inMonthly, expandPoint);
Sell = isEndOfMonth;
Cover =isEndofMonth;

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