Asianraisin
New member
I am trying to set up a thinkscript study alert for high (8x higher than average) intraday volume. I'm trying to do this on the 1 min time frame. The goal is to catch the beginning of large moves like with what happened with $DIS today or with $TWLO and $BA earlier this week. What I've done so far is created a study alert (MarketWatch > study alerts) and put the following code in:
I am trying to get alerted for volume 8x higher than average from the hours 9am cst to 2:30pm cst.(to avoid the early morning and late afternoon vol spikes). 390 representing the 390 mins in a trading day. Does this look right? I'm not sure if I'm doing this correctly. Is there any way to backtest this through OnDemand?
Thank you very much for taking time to look at my post.
Code:
def afterStart = secondsfromtime(9000)>0;
def beforeEnd = secondstilltime(1430)>0;
def conditionTrue = volume > 8*average(volume, 390);
plot alert = afterStart and beforeEnd and conditionTrue;
I am trying to get alerted for volume 8x higher than average from the hours 9am cst to 2:30pm cst.(to avoid the early morning and late afternoon vol spikes). 390 representing the 390 mins in a trading day. Does this look right? I'm not sure if I'm doing this correctly. Is there any way to backtest this through OnDemand?
Thank you very much for taking time to look at my post.
Code:
#
# Pedro Uriarte 25 Aug 2019
# /CL 2500
#
declare lower;
declare zerobase;
input lengthAvg = 50;
input volumeAlert1 = 2500;
input volumeAlert2 = 3500;
input aggregationPeriod = AggregationPeriod.MIN;
input soundType = Sound.RING;
input alertType = Alert.BAR;
Plot dinamicAlertLine = ((GetAggregationPeriod()/60000) - 1) * volumeAlert1;
plot Vol = volume;
plot VolAvg = Average(volume, lengthAvg);
Plot AlertLine1 = volumeAlert1;
Plot AlertLine2 = volumeAlert2;
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.UPTICK);
Vol.DefineColor("Down", Color.DOWNTICK);
Vol.AssignValueColor(if close > close[1] then Vol.color("Up") else if close < close[1] then Vol.color("Down") else GetColor(1));
VolAvg.SetDefaultColor(GetColor(8));
AlertLine1.SetDefaultColor(GetColor(5));
AlertLine2.SetDefaultColor(GetColor(5));
dinamicAlertLine.SetDefaultColor(GetColor(5));
# def afterStart = SecondsFromTime(0800) > 0;
# def beforeEnd = SecondsTillTime(1530) > 0;
def alertCondition = GetAggregationPeriod() == aggregationPeriod and (volume >= volumeAlert1 or (volumeAlert2!= 0 and volume >= volumeAlert2));
Alert(alertCondition, "High volume Alert", alertType, soundType);
Last edited by a moderator: