Normal Il USA
Posts: 1 since Jul 2016
Thanks Given: 0
Thanks Received: 0
|
I am attempting to write my first script and need some help. A simple indicator to follow trend changes.
I want to adjust the timeframe independent of the chart, but can't seem to figure out how to add the time period to my plot. Any help would be appreciated.
declare lower;
input TimeFrame1 = {default "5 min", "10 min", "15 min", "20 min"};
def Aggregation1;
def range = (hl2[5] + hl2[4] + hl2[3] + hl2[2] + hl2[1] + hl2) / 6;
def uptrend = (if close > range then 1 else 0);
def downtrend = if close <= range then 1 else 0;
switch (TimeFrame1) {
case "5 min":
Aggregation1 = AggregationPeriod.FIVE_MIN;
case "10 min":
Aggregation1 = AggregationPeriod.TEN_MIN;
case "15 min":
Aggregation1 = AggregationPeriod.FIFTEEN_MIN;
case "20 min":
Aggregation1 = AggregationPeriod.TWENTY_MIN;
}
def timeFrame = GetAggregationPeriod();
def testTimeFrames = if timeFrame < Aggregation1 then yes else no;
AddLabel(yes, if testTimeFrames then "Time Frames Are Correct" else "Time Frames Are Wrong", if testTimeFrames then Color.GREEN else Color.RED);
plot Trend1 = if uptrend then 1 else Double.NaN;
plot Trend2 = if downTrend then 1 else Double.NaN;
Trend1.SetDefaultColor(Color.GREEN);
Trend2.SetDefaultColor(Color.RED);
|