Something like the following...
Ruby:
def agg = AggregationPeriod.MONTH;
def price = close(period = agg);
plot trend = if price > price[6] + (price[6] * 1.5) then 1 else Double.NaN;
Here's my contribution, didn't know that
@rad14733 already posted after I started. I had created it as a scan for the monthly timeframe -
Ruby:
plot scan = close >= (2.5 * low[6]);
I noticed an odd thing when first coding this. I had originally coded the multiplier as 1.5, but when testing the results, it was showing signals at 50% and greater,
not 150% and greater! After a good bit of testing, I multiplied it by 2.5, and it finally starting showing at 150% gain. Then I realized . . .
10 * 1.5 = 15 or a
50% increase
over the original amount, but a 150% increase above 0
10 * 2.5 = 25 or a
150% increase
over the original amount
My initial math calculation to get "150% above the 6-month low" was wrong, as I need to treat the low price as "0". Multiplying by 1.5 gets 150%
above 0, not the 6-month low. Unless my mind is completely befuddled. I'd appreciate someone (
@rad14733,
@mashume,
@SleepyZ,
@XeoNoX) to check if my math conclusion is correct.
Here's the code I used on the chart to check percentage values -
Ruby:
def l = low(period = aggregationperiod.MONTH)[6];
plot c = if close >= (2.5 * l) then l else double.nan;
c.setpaintingstrategy(paintingstrategy.line);
c.setdefaultcolor(color.red);
Note: I did my measuring of percentages using the line drawing tool. Wondering if the tool is somehow inaccurate.
Edit: posted wrong test code, changed it for the code in question.