TNTrader5159
Active member
Hello Trader/Coders!
Is it advisable to use multiple studies to create a study set for monitoring many time-frames simultaneously? Only one input needs to be changed in the code in order to do so, but copying the entire code block into the same study for the various inputs would necessitate the creation of new variable names and make a tedious mess of things. So which way is more efficient for monitoring and resource management?
<p>
In the below example of code, only the <ratio1> input would be changed with many different values to be reckoned. Is it better to copy/paste the code below this for every increment and alter the variable names accordingly, or should I use multiple studies with only the <ratio1> value changed to leave the variable names unchanged in each one?
Is it advisable to use multiple studies to create a study set for monitoring many time-frames simultaneously? Only one input needs to be changed in the code in order to do so, but copying the entire code block into the same study for the various inputs would necessitate the creation of new variable names and make a tedious mess of things. So which way is more efficient for monitoring and resource management?
<p>
In the below example of code, only the <ratio1> input would be changed with many different values to be reckoned. Is it better to copy/paste the code below this for every increment and alter the variable names accordingly, or should I use multiple studies with only the <ratio1> value changed to leave the variable names unchanged in each one?
Code:
def nonum = Double.NaN;
def bn = BarNumber();
# User options
input showengbub = yes;
input showenglines = yes;
# Engulfing bars
input ratio1 = 3;
# Multiplying factor
input minratio = Double.Pi;
# Engulfed bars
def ratio2 = minratio * ratio1;
# Bars since high/low of tail
def tailbarsago = ratio1 - 1;
# Maximum number of bars to look back for engulfed range
def lookback = 144 * ratio1;
# Count the number of bars engulfed in bearish pattern
def engbarsbear = fold countbear = ratio1 to lookback * ratio1 with bear while high[tailbarsago] > GetValue(high, countbear) and low[tailbarsago] > low[ratio1] and low < GetValue(low, countbear) do bear + 1;
# Verify at least <ratio2> bars engulfed
def engbarsminbear = if engbarsbear >= ratio2 then engbarsbear else 0;
# Count the number of bars engulfed in a bullish pattern
def engbarsbull = fold countbull = ratio1 to lookback * ratio1 with bull while low[tailbarsago] < GetValue(low, countbull) and high[tailbarsago] < high[tailbarsago + 1] and high > GetValue(high, countbull) do bull + 1;
# Verify at least <ratio2> bars engulfed
def engbarsminbull = if engbarsbull >= ratio2 then engbarsbull else 0;
# Display qualified numbers of engulfed bars in red or green bubble
addchartbubble(engbarsminbear, high * 1.00025, engbarsminbear / ratio1, color.light_red, yes);
addchartbubble(engbarsminbull, low * 0.99925, engbarsminbull / ratio1, color.light_green, no);