| strategynode 5 posts
 msg #121432
 - Ignore strategynode
 modified
 | 9/4/2014 2:04:18 AM 
 Hi,
 I am trying to figure out how to scan based on a study or indicator which thinkorswim has. Its called the TTM_Scalper_alert, the problem is that when I try to look for its source code it says not available not sure why ( I am new to this)
 
 I also found another indicator which seems to give me the same results as the above mentioned study but the code for this one is available:
 
 input signalOffsetFactor = 0.20;
 def signalOffset = AvgTrueRange(high, close, low, 9) * signalOffsetFactor;
 plot Data = hlc3;
 def triggerSell = if(if(close[-1] < high, 1, 0) and (hlc3[-2] < close[-1] or hlc3[-3] < close[-1]), 1, 0);
 def triggerBuy = if(if(close[-1] > low, 1, 0) and (hlc3[-2] > close[-1] or hlc3[-3] > close[-1]), 1, 0);
 rec buySellSwitch = if(triggerSell, 1, if(triggerBuy, 0, buySellSwitch[1]));
 def thirdBarClosed = if(IsNaN(hlc3[-3]), 0, 1);
 plot SBS = if(triggerSell and thirdBarClosed and !buySellSwitch[1], high + signaloffset, if(triggerBuy and thirdBarClosed and buySellSwitch[1], low - signaloffset, double.nan));
 SBS.SetStyle(curve.FIRM);
 SBS.SetPaintingStrategy(paintingStrategy.LINE_VS_POINTS);
 SBS.SetLineWeight(2);
 # SBS.SetDefaultColor(color.white);
 
 SBS.AssignValueColor(if triggerSell then
 if thirdbarclosed then
 #UpPos
 CreateColor(255, 0, 0) else
 #UpNeg
 CreateColor(255, 0, 0)
 else if Triggerbuy then
 #DnPos
 CreateColor(0, 255, 0) else
 #DnNeg
 CreateColor(0, 255, 0));
 
 I want to create two version for this filter 1) short biased and 2) long biased
 
 1) It looks like the relevant code for the short biased (from what I can gather is)
 
 def triggerSell = if(if(close[-1] < high, 1, 0) and (hlc3[-2] < close[-1] or hlc3[-3] < close[-1]), 1, 0);
 
 2) For long Biased
 
 def triggerBuy = if(if(close[-1] > low, 1, 0) and (hlc3[-2] > close[-1] or hlc3[-3] > close[-1]), 1, 0);
 
 Hope I can have somebody help me with this:
 
 Thanks.
 
 PS these are some of the explanations you may need to understand the code
 
 hlc3  = https://tlc.thinkorswim.com/center/charting/thinkscript/reference/Functions/Fundamentals/hlc3.html
 
 
 |