Internet Name
Member
"ShowOnlyLastPeriod" Functionality
This is a basic template of the structure that works for me:
Structure 1:
This will return true for the current period and every period afterwards. It will return false for any period before the current period.
If you wanted to do a code where you want to show only the prior periods as true, it would be adjusted to the following:
If you wanted to return the code as true only on the current period, and false on every period before or after the specified period, it would look like this:
Structure 2:
This code allows you to tell the software where you want the "current period" to be. So if you wanted just the current day to return true, it would look like the code above. if you wanted something to show only on the prior day, the begin num and end num would be 1.
This is a basic template of the structure that works for me:
Structure 1:
Code:
Input ShowOnlyLastPeriod = yes;
Def NextDayClose = Close(Period=AggregationPeriod.Day)[-1];
Plot line;
Line = if ShowOnlyLastPeriod and !IsNaN(NextDayClose)
Then 0
Else 1;
AddVerticalLine(line ==1);
This will return true for the current period and every period afterwards. It will return false for any period before the current period.
If you wanted to do a code where you want to show only the prior periods as true, it would be adjusted to the following:
Code:
Input ShowOnlyPriorPeriod = yes;
Def NextDayClose = Close(Period=AggregationPeriod.Day)[-1];
Plot line;
Line = if ShowOnlyPriorPeriod and IsNaN(NextDayClose)
Then 0
Else 1;
AddVerticalLine(line ==1);
If you wanted to return the code as true only on the current period, and false on every period before or after the specified period, it would look like this:
Structure 2:
Code:
input ShowOnlyLastPeriod = yes;
input BeginNumOfPeriodsBack = 0;
input EndNumOfPeriodsBack = 0;
def BeginningPeriod = Close(period =aggregationPeriod.Day)[-BeginNumOfPeriodsBack-1];
def EndingPeriod = Close(period = aggregationPeriod.Day)[-EndNumOfPeriodsBack];
plot line;
Line = if ShowOnlyLastPeriod and !IsNaN(EndingPeriod) and IsNaN(BeginningPeriod)
then 1
else 0;
AddVerticalLine(line ==1);
This code allows you to tell the software where you want the "current period" to be. So if you wanted just the current day to return true, it would look like the code above. if you wanted something to show only on the prior day, the begin num and end num would be 1.