• LIMITED TIME OFFER: use coupon code PRIMEDAY (case sensitive) at checkout to save $50 off VIP membership (down to $149 / year). Valid through Tuesday 6/22. Biggest discount this year!

AggregationPeriod to provide a percentage based on moving averages

Branch

Member
VIP
Here is a link to a picture of what I am trying to build for just one product (any product) based on 1min, 5min, 15min

SAlUcWc.png


THIS CODE IS NOT WORKING

Code:
input aP = AggregationPeriod.TWO_MIN;
input length10 =10;
input length35 = 35;
input length50 = 50;
input length100 = 100;
input length200 = 200;
input over_Bought = 80;
input over_Sold = 20;
input price = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = no;
input averageType1 = AverageType.SIMPLE;
input averageType2 = AverageType.SIMPLE;
input averageType3 = AverageType.SIMPLE;
input averageType4 = AverageType.SIMPLE;
input averageType5 = AverageType.SIMPLE;
input crossingType = {default above, below};

def NetChgAvg = MovingAverage(averageType, price - price[1], length10);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length10);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def avg10 = MovingAverage(averageType1, price, length10);
def avg35 = MovingAverage(averageType2, price, length35);
def avg50 = MovingAverage(averageType3, price, length50);
def avg100 = MovingAverage(averageType4, price, length100);
def avg200 = MovingAverage(averageType5, price, length200);
#Moving average labels

AddLabel (yes,if close then "MOVING AVERAGES" else "", Color.BLUE);
AddLabel (yes, if close + aP < avg10 and close + aP <avg35 and close + aP < avg50 and close + aP <avg100 and close + aP <avg200 then "Sell 100%" + "" else "", Color.RED);

**If close is below all MA then labels for the time period should be Red with a 100% reading.

THIS IS MY CURRENT CODE THAT I USE BUT WANT TO MOVE FROM THIS TO MY REQUEST


Code:
input length10 =10;
input length35 = 35;
input length50 = 50;
input over_Bought = 80;
input over_Sold = 20;
input price = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = no;
input averageType1 = AverageType.SIMPLE;
input averageType2 = AverageType.SIMPLE;
input averageType3 = AverageType.SIMPLE;
input averageType4 = AverageType.SIMPLE;
input crossingType = {default above, below};

def NetChgAvg = MovingAverage(averageType, price - price[1], length10);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length10);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def avg10 = MovingAverage(averageType1, price, length10);
def avg35 = MovingAverage(averageType2, price, length35);
def avg50 = MovingAverage(averageType3, price, length50);

#Moving average labels

AddLabel (yes,if close then "MOVING AVERAGES" else "", Color.BLUE);
AddLabel (yes, if close < avg10 then "MA.10" + "" else "", Color.RED);
AddLabel (yes, if close > avg10 then "MA.10" + "" else "", Color.GREEN);
AddLabel (yes, if close < avg10 then "MA.21" + "" else "", Color.RED);
AddLabel (yes, if close > avg10 then "MA.21" + "" else "", Color.GREEN);
AddLabel (yes, if close < avg35 then "MA.35" + "" else "", Color.RED);
AddLabel (yes, if close > avg35 then "MA.35" + "" else "", Color.GREEN);
AddLabel (yes, if close < avg35 then "MA.50" + "" else "", Color.RED);
AddLabel (yes, if close > avg35 then "MA.50" + "" else "", Color.GREEN);
AddLabel (yes, if close < avg35 then "MA.100" + "" else "", Color.RED);
AddLabel (yes, if close > avg35 then "MA.100" + "" else "", Color.GREEN);
AddLabel (yes, if close < avg35 then "MA.200" + "" else "", Color.RED);
AddLabel (yes, if close > avg35 then "MA.200" + "" else "", Color.GREEN);
 
Last edited:

Similar threads

Top