Pass chart's TimeFrame interval to .APX's XML Periodicity || Get Custom Interval number

Sincere Greetings to All,

Have searched this forum and the old YahooGroup to my best efforts. Tried more or less but has been unsuccessful so far on this. Almost compelled to believe its not possible but as usual the forum is the last hope. :smiley:

Objective: Pass the chart's timeframe interval to the .APX's XML Periodicity tag. So, when the .APX is called, it will always match the chart's current timeframe and accordingly perform the Analysis instead of seeking to change the Periodicity manually.

Issue: It is understandable that the XML value for Periodicity in "Backtester settings > General" is read as -4 for Yearly, -3 for Monthly....and so on. Using Interval( 0 ), I am able to figure out the number for Periodicity tag for non-custom Intervals only. For instance, when Interval( 0 ) == 25920020; Periodicity = -4; or if Interval( 0 ) == 2160001; Periodicity = -3;. Now-a-days, I am playing and analyzing backtest results in different timeframes, so, the intervals for Custom 1, Custom 2....Custom 5 keeps on changing.

Question: How to get the Custom Interval number directly instead of depending on Interval( 0 )? Had my custom TimeFrames remained constant this won't be an issue. As depicted in the image below if Custom 1 was set to 2-minute forever, then I could simply write, if interval( 0 ) == 120; Periodicity = 10; but that's not the case here.

Untitled

Is there a way to programatically know which Custom Interval is currently selected in the chart? Such that I could detect the same and assign the periodicity accordingly.

If Custom 1 is selected, then Periodicity = 10;
If Custom 2 is selected, then Periodicity = 11;
.
.
If Custom 5 is selected, then Periodicity = 14;

Also welcome any alternate solution to this.

Thanks,
Lennon

1 Like