Re: Fun with ThinkScript January 06, 2016 10:09AM |
Registered: 9 years ago Posts: 78 |
Re: Fun with ThinkScript January 06, 2016 04:36PM |
Registered: 8 years ago Posts: 9 |
Re: Fun with ThinkScript January 06, 2016 07:11PM |
Registered: 8 years ago Posts: 26 |
Quote
tanman
# long and short signal formula def OBV = TotalSum(Sign(close - close[1]) *volume); def OBVUP = OBV > OBV[1]; def OBVDN = OBV < OBV[1];
Re: Fun with ThinkScript January 07, 2016 12:40PM |
Registered: 10 years ago Posts: 143 |
Re: Fun with ThinkScript January 07, 2016 12:47PM |
Registered: 10 years ago Posts: 143 |
Re: Fun with ThinkScript January 07, 2016 01:35PM |
Registered: 10 years ago Posts: 143 |
Re: Fun with ThinkScript January 07, 2016 04:53PM |
Registered: 9 years ago Posts: 14 |
# Short_123_Reversal # Inputs input price = close; input length = 9; input length2 = 20; input maType = {default Weighted, Exponential, Simple, Wilders, Hull}; # Input Moving Average types def ma = ExpAverage(price, length); def ma2 = ExpAverage(price, length2); # Set crossthreshold according to aggregationPeriod def thrUp = if getAggregationPeriod() == AggregationPeriod.WEEK then 0.005 else if getAggregationPeriod() == AggregationPeriod.DAY then 0.0025 else if getAggregationPeriod() == AggregationPeriod.HOUR then 0.0015 else 0.00125; def thrDn = if getAggregationPeriod() == AggregationPeriod.WEEK then 0.005 else if getAggregationPeriod() == AggregationPeriod.DAY then 0.0025 else if getAggregationPeriod() == AggregationPeriod.HOUR then 0.0015 else 0.00125; # Price CrossOver def up = close > ((1 + thrUp) * ma) and close[1] <= ((1 + thrUp) * ma[1]); rec barUp = if up then barNumber() else if isNaN(barUp[1]) then barNumber() else barUp[1]; # Price CrossUnder def down = close < ((1 - thrDn) * ma2) and close[1] >= ((1 - thrDn) * ma2[1]); rec barDown = if down then barNumber() else if isNaN(barDown[1]) then barNumber() else barDown[1]; #cross def condition1 = open > ma; def condition2 = close < ma2; def condition3 = condition1 and condition2; ##### Plotting Peaks and Valleys input magnitude = 3; # define and plot the most recent peak def peak = high >= Highest(high[1], magnitude) and high >= Highest(high[-magnitude], magnitude); def peakvalue = if BarNumber() < magnitude then Double.NaN else if peak then high else peakvalue[1]; plot peakline = peakvalue; peakline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); peakline.SetDefaultColor(Color.GREEN); # extend the current peak line to the right edge of the chart def countp = if IsNaN(peak) and !IsNaN(peak[1]) then 1 else countp[1] + 1; plot peakext = if IsNaN(peak) then GetValue(peakline, countp) else Double.NaN; peakext.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); peakext.SetDefaultColor(Color.GREEN); # continue the previous peak as a dashed line def oldpeak = if BarNumber() < magnitude then Double.NaN else if peak then peakvalue[1] else oldpeak[1]; plot oldpeakline = oldpeak; oldpeakline.SetPaintingStrategy(PaintingStrategy.DASHES); oldpeakline.SetDefaultColor(Color.GREEN); def condition4 = (peak < peak[1]) and (condition3 is true); # Sell Signal plot sell = if condition4 and (if isNaN(barDown[1]) then 1 else if barDown[1] <= barUp then 1 else 0) then 1 else 0; sell.setDefaultColor(color.BLUE); sell.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); #Trigger alerts alert(sell, "Price CrossUnder", Alert.Bar, Sound.Ring);
Re: Fun with ThinkScript January 07, 2016 05:44PM |
Registered: 10 years ago Posts: 21 |
Re: Fun with ThinkScript January 07, 2016 05:48PM |
Registered: 8 years ago Posts: 161 |
Re: Fun with ThinkScript January 08, 2016 02:22PM |
Registered: 10 years ago Posts: 143 |
Re: Fun with ThinkScript January 13, 2016 12:01PM |
Registered: 8 years ago Posts: 6 |
Re: Fun with ThinkScript January 13, 2016 12:47PM |
Registered: 8 years ago Posts: 6 |
Re: Fun with ThinkScript January 13, 2016 04:47PM |
Registered: 8 years ago Posts: 161 |
mdaprasad, the way you wrote the code you'll get a signal for as long as the condition is True, i.e., continuous triangles. If you only want a signal when the condition first happens, then you want "crosses above" , not the ">" as you wrote it. Maybe I misunderstand but what I think is you want a signal for when the sma first curves upward, right? And you want the exact price for when that happens. You also want to know if the signal may come and go during the current bar; the answer is Yes. You've specified to display triangle at current Close when condition is True, and whatever the price is on the current bar is for the moment the Close. So the first time you see the triangle, that's the "exact price" when the condition is first True. But if you can't watch, you may want to set up an Alert, which would record when it was first True. I added two lines (in Blue) to help me see what was going on. Hope this helps.Quote
mdaprasad
> I am trying to get exact price when the condition
> is meet...
>... What above code snippet plots is a triangle at the
> close of current bar when buySignal condition is
> meet isn't it?...
> What I am trying to get is exact price when that
> condition is meet not close or open or hlc3 etc.
>... I am aware that price might get repainted several
> times before bar is closed but that's what I want
> to find out...
def sma = average(close,5); def buySignal = sma[0] crosses above sma [1]; plot mysma = sma; plot BUY = if buySignal then close else double.nan; BUY.setDefaultColor(color.CYAN); BUY.setLineWeight(5); BUY.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
Re: Fun with ThinkScript January 13, 2016 05:13PM |
Registered: 8 years ago Posts: 6 |
Re: Fun with ThinkScript January 13, 2016 08:16PM |
Registered: 8 years ago Posts: 161 |
Re: Fun with ThinkScript January 13, 2016 11:35PM |
Registered: 8 years ago Posts: 6 |
Re: Fun with ThinkScript January 14, 2016 12:29AM |
Registered: 8 years ago Posts: 161 |
Re: Fun with ThinkScript January 14, 2016 10:10AM |
Registered: 10 years ago Posts: 464 |
Re: Fun with ThinkScript January 14, 2016 10:28AM |
Registered: 8 years ago Posts: 6 |
Re: Fun with ThinkScript January 14, 2016 12:38PM |
Registered: 8 years ago Posts: 161 |
Re: Fun with ThinkScript January 14, 2016 04:43PM |
Registered: 8 years ago Posts: 6 |
Re: Fun with ThinkScript January 14, 2016 05:19PM |
Registered: 8 years ago Posts: 161 |
No, I meant get original price data someplace and put in a spreadsheet and create your algo in the spreadsheet then you could collect the data you want. But actually I came back here just now to give you something that "may" help with bubbles. I was looking for something else when I ran across it: http://investorshub.advfn.com/boards/read_msg.aspx?message_id=81374423 .Quote
mdaprasad
> Spreadsheet? You mean we can transfer alerts data
> to spread sheet? I am not aware of this
> functionality..
Re: Fun with ThinkScript January 14, 2016 09:54PM |
Registered: 10 years ago Posts: 464 |
Re: Fun with ThinkScript January 15, 2016 01:15PM |
Registered: 8 years ago Posts: 161 |
help with a script.... January 19, 2016 08:22AM |
Registered: 8 years ago Posts: 25 |
Re: Fun with ThinkScript January 19, 2016 01:32PM |
Registered: 10 years ago Posts: 143 |
Re: Fun with ThinkScript January 19, 2016 07:14PM |
Registered: 8 years ago Posts: 25 |
Re: Fun with ThinkScript January 20, 2016 05:45PM |
Registered: 10 years ago Posts: 143 |
Re: Fun with ThinkScript January 20, 2016 07:00PM |
Registered: 8 years ago Posts: 25 |
Programming Indicators Request January 20, 2016 05:34PM |
Registered: 8 years ago Posts: 4 |