TTM Scalper? Aka, 3 Higher Lows/Highs
Posted: Fri Jul 27, 2007 10:44 pm
I've been unable to come up with a .eld that replicates this. I've searched this forum high and low and haven't seen anything quite like it. I understand its a fairly simple concept, but the indicator i found on traderslabratory.com is kind of screwy. Its been awhile since my C++ class, so I don't really know how to modify the code accordingly.
On the other thread, someone posted up saying that the code was incorrect and posted the correct logic (not in easy language). Can anyone convert them into an indicator or shoot me in the right direction if this is already part of the motherlode packages somewhere?
The Code from the other TL thread:
And the logic someone said was really how it needed to be coded (metastock code):
Thanks again for your help here! Its easy enough to do this manually, but a paintbar would simplify my life immensely!
On the other thread, someone posted up saying that the code was incorrect and posted the correct logic (not in easy language). Can anyone convert them into an indicator or shoot me in the right direction if this is already part of the motherlode packages somewhere?
The Code from the other TL thread:
Code: Select all
inputs: BarWidth(3); variables: UpTrend(false), LowPainted(false), HighPainted(false), ExtremeBar(0), TriggerBarLow(0), ExtremeBarHigh(0), TriggerBarHigh(0), ExtremeBarLow(0), counter(-1); // Compare the 9-period MA to the previous bar's value as the basis for determining // if we are in an uptrend or a downtrend at this moment. // // We will NOT check for the presence of a trend if we are // "waiting for a confirmation of a trigger (i.e. Extreme Bar <> 0)" ?? //Downtrend -- Look to paint a low bar if (AverageFC(Close[3],9) < AverageFC(Close[4],9) and ExtremeBar=0) or ((AverageFC(Close[3],9) = AverageFC(Close[4],9) and ExtremeBar=0) and (UpTrend=False)) then begin UpTrend=False; HighPainted=false; if low[3] > low then LowPainted=false; end; //Uptrend -- Look to paint a high bar if AverageFC(Close[3],9) > AverageFC(Close[4],9) and ExtremeBar=0 or ((AverageFC(Close[3],9) = AverageFC(Close[4],9) and ExtremeBar=0) and (UpTrend=True)) then begin UpTrend=True; LowPainted=false; if high[3] < high then HighPainted=false; end; //Check for triggers and paint the extreme bar on confirmation //Uptrend if UpTrend = True and HighPainted=false then begin if high[2] < high[3] and ExtremeBar=0 then begin ExtremeBar = 3; ExtremeBarHigh = high[3]; TriggerBarLow = low[2]; end; if high[1] > ExtremeBarHigh then begin ExtremeBar = 0; ExtremeBarHigh = 0; TriggerBarLow = 0; counter=-1; end; if ExtremeBar <> 0 then counter=counter+1; // Paint an "Extreme Bar" if it exists based on the two if blocks above // OR if the earlier close was above the 8-EMA and the later close was // below the 8-EMA) if (close[1] < TriggerBarLow and ExtremeBar <> 0) // or ((Close[3] > XAverage(Close[3],8)) and (Close[1] < XAverage(Close[1],8))) then begin ExtremeBar = ExtremeBar + counter; PlotPaintBar[ExtremeBar](High[ExtremeBar],Low[ExtremeBar],"ScalperSig",white); SetPlotWidth[ExtremeBar](1,BarWidth); SetPlotColor[ExtremeBar](1,white); alert("Scalper Sell Detected!"); HighPainted = true; counter=-1; ExtremeBar=0; end; end; //Downtrend if UpTrend = False and LowPainted=false then begin if low[2] > low[3] and ExtremeBar=0 then begin ExtremeBar = 3; ExtremeBarLow = low[3]; TriggerBarHigh = high[2]; if ExtremeBarLow > low[4] then ExtremeBar = 4; end; if low[1] < ExtremeBarLow then begin ExtremeBar = 0; ExtremeBarLow = 0; TriggerBarHigh = 0; counter=-1; end; if ExtremeBar <> 0 then counter=counter+1; if close[1] > TriggerBarHigh and ExtremeBar <> 0 then begin ExtremeBar = ExtremeBar + counter; PlotPaintBar[ExtremeBar](Low[ExtremeBar],High[ExtremeBar],"ScalperSig",white); SetPlotWidth[ExtremeBar](1,BarWidth); SetPlotColor[ExtremeBar](1,white); alert("Scalper Buy Detected!"); LowPainted = true; counter=-1; ExtremeBar=0; end; end;
And the logic someone said was really how it needed to be coded (metastock code):
Code: Select all
I am new to easy language but have coded this in metastock below is the code.
The code for higher closes in the highlights Tab
BC:=C>Ref(C,-1) AND Ref(C,-1)>Ref(C,-2);
SC:=C<Ref(C,-1) AND Ref(C,-1)<Ref(C,-2);
X:=If(BC=1,1,If(SC=1,0,PREV));
Cross(X,0.5);
Here is the one for the lower closes:
BC:=C>Ref(C,-1) AND Ref(C,-1)>Ref(C,-2);
SC:=C<Ref(C,-1) AND Ref(C,-1)<Ref(C,-2);
X:=If(BC=1,1,If(SC=1,0,PREV));
Cross(0.5,X);
Thanks again for your help here! Its easy enough to do this manually, but a paintbar would simplify my life immensely!