Pad & Align Checker

Hi,

With the following Pad & Align Checker when running it just on the Explorer the Error Function activates but after some signals are shown in the Results list. Is it possible to have it so no signals are shown if the Error Function is activated (Pad & Align not checked)?

if (Status("action") == actionBacktest OR Status("action") == actionExplore) 
{ 
	if (Status("stocknum") == 0) 
		StaticVarSet("barCountZero", BarCount); 
	else  
		if (StrToUpper(Name()) != "~~~EQUITY") 
		{ 
			barCountZero = StaticVarGet("barCountZero"); 
			if (BarCount != barCountZero) 
				Error("Make sure Pad & Align is checked in Backtester Settings dialog. Set symbol to $XAO"); 
		} 
} 
	
buySignal = C > 1; // testing

Filter = buySignal;

Thank-you.

@Tomasz, is it possible to not have any results show when the Error Function executes?

Instead of using Error, just set Filter to zero (Filter = 0); then you will have no results and no error.

Thanks @Tomasz,

But then how would you know if Pad & Align has been checked or not? I want the error message to be displayed, just don't want any results displayed if Pad & Align is not checked.

Just assign 0 to FIlter variable as I wrote:

if (BarCount != barCountZero)
{
  Filter = 0; // display no results
  Error("Make sure Pad & Align is checked in Backtester Settings dialog. Set symbol to $XAO"); 
}
1 Like

In some instances, I want to be able to check that the Pad and Align is off so I hacked the code as follows. It works, but if anyone knows a neater or proper way to do it, please share:

if (Status("action") == actionBacktest)
{
	if (Status("stocknum") == 0)
		StaticVarSet("barCountZero", BarCount);
	else 
		if (StrToUpper(Name()) != "~~~EQUITY")
		{
			barCountZero = StaticVarGet("barCountZero");
			if (BarCount != barCountZero)
				//Error("Make sure Pad & Align is checked in Backtester Settings. Set symbol to All Ordinaries ticker (eg .AORD)");//comment out to check pad and align is off
				ThreadSleep( 1 );//comment out to check pad and align is on
				else//comment out to check pad and align is on
				Error("Make sure Pad & Align is turned off in Backtester Settings.");//comment out to check pad and align is on
		}
}

In version 6.33 (upcoming) you would just write GetOption("PadAndAlignToReference");

1 Like