#### RedToGreen

##### Member

The following code is part of a script I'm working on with MACD

I could...

def Long = Macdfastgreen1

or

def Long = MacdFastGreen1 and MacdSlowup1A

to sum up what I'm trying to figure out, if possible, if you can go into the study settings and apply all the signals I want for a certain aggperiod without going into the actual code and changing things there?

hope that makes sense

Thank you

Code:

```
input Time1 = {"5 min", "10 min", "15 min", "Hour", "4 Hour", "Daily", default "Weekly", "Monthly"};
input Time2 = {"5 min", "10 min", "15 min", "Hour", "4 Hour", "Daily", default "Weekly", "Monthly"};
input Time3 ={"5 min", "10 min", "15 min", "Hour", "4 Hour", "Daily", default "Weekly", "Monthly"};
#============TIME=========================
def Agg1;
switch (Time1) {
case "5 min":
Agg1 = AggregationPeriod.FIVE_MIN;
case "10 Min":
Agg1 = AggregationPeriod.TEN_MIN;
case "15 min":
Agg1 = AggregationPeriod.FIFTEEN_MIN;
case "Hour":
Agg1 = AggregationPeriod.HOUR;
case "4 Hour":
Agg1 = AggregationPeriod.FOUR_HOURS;
case "Daily":
Agg1 = AggregationPeriod.DAY;
case "Weekly":
Agg1 = AggregationPeriod.WEEK;
case "Monthly":
Agg1 = AggregationPeriod.MONTH;
}
def Agg2;
switch (Time2) {
case "5 min":
Agg2 = AggregationPeriod.FIVE_MIN;
case "10 Min":
Agg2 = AggregationPeriod.TEN_MIN;
case "15 min":
Agg2 = AggregationPeriod.FIFTEEN_MIN;
case "Hour":
Agg2 = AggregationPeriod.HOUR;
case "4 Hour":
Agg2 = AggregationPeriod.FOUR_HOURS;
case "Daily":
Agg2 = AggregationPeriod.DAY;
case "Weekly":
Agg2 = AggregationPeriod.WEEK;
case "Monthly":
Agg2 = AggregationPeriod.MONTH;
}
input fastLengthMACD = 8;
input slowLengthMACD = 21;
input MACDLength = 5;
input averageTypeMACD = AverageType.WEIGHTED;
input showBreakoutSignals = no;
def FastMacD1 = MovingAverage(averageTypeMACD, close(PERIOD = Agg1), fastLengthMACD) - MovingAverage(averageTypeMACD, close(period = Agg1), slowLengthMACD);
def FastMacD2 = MovingAverage(averageTypeMACD, close(PERIOD = Agg2), fastLengthMACD) - MovingAverage(averageTypeMACD, close(period = Agg2), slowLengthMACD);
def FastMacD3 = MovingAverage(averageTypeMACD, close(PERIOD = Agg3), fastLengthMACD) - MovingAverage(averageTypeMACD, close(period = Agg3), slowLengthMACD);
def SlowMacd1 = MovingAverage(averageTypeMACD, FastMacD1, MACDLength);
def SlowMacd2 = MovingAverage(averageTypeMACD, FastMacD2, MACDLength);
def SlowMacd3 = MovingAverage(averageTypeMACD, FastMacD3, MACDLength);
#def Diff = FastMacD1 - SlowMacd1;
def MacDSlowGreen1 = SlowMacd1 > SlowMacd1[1];
def MacDSlowGreen2 = SlowMacd2 > SlowMacd2[1];
def MacDSlowGreen3 = SlowMacd3 > SlowMacd3[1];
def MacDSlowRed1 = SlowMacd1 < SlowMacd1[1];
def MacDSlowRed2 = SlowMacd2 < SlowMacd2[1];
def MacDSlowRed3 = SlowMacd3 < SlowMacd3[1];
#def MacdFastup1A = FastMacD1[1] > FastMacD1[2];
#def MacdFastup2A = FastMacD2[1] > FastMacD2[2];
#def MacdFastup3A = FastMacD3[1] > FastMacD3[2];
#def MacdFastdn1A = FastMacD1[1] < FastMacD1[2];
#def MacdFastdn2A = FastMacD2[1] < FastMacD2[2];
#def MacdFastdn3A = FastMacD3[1] < FastMacD3[2];
```