How to loop through OHLC DataSeries in Optimization?
Author: emskiphoto
Creation Date: 5/19/2017 8:32 PM
profile picture

emskiphoto

#1
In the line of code from the script below I would like to be able to substitute the term "Low" with a StrategyParameter that would enable analysis of either the O, H, L, or C of a price series in the optimization process. In other words, I wish to leverage the automated optimization process to evaluate the effectiveness of the strategy on all four of the OHLC time series for a given ticker symbol.

CODE:
Please log in to see this code.


I imagine this requires 'enumerating' the different time series and then defining Strategy Parameters as shown below. This is beyond my coding abilities - please help.

Open = 1
High = 2
Low = 3
Close = 4

CODE:
Please log in to see this code.


// for example if slider5=2, then the CrossUnder series would use the bar "High" price of the data series.


WHOLE SCRIPT (FYI):

CODE:
Please log in to see this code.
profile picture

Eugene

#2
Hi Matt,

There's always more than one way to skin a cat but the natural choice here is to use the switch keyword like shown below. Hope this is intuitive enough:

CODE:
Please log in to see this code.
profile picture

emskiphoto

#3
Excellent! Thanks Eugene