BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: Instantaneous Trendline and Sinewave Indicator
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Instantaneous Trendline and Sinewave Indicator

 Post Reply Post Reply
Author
Message / View First Unread Post
Tanaka View Drop Down
Newbie
Newbie


Joined: 08 Jul 2010
Posts: 18
Post Options Post Options   Quote Tanaka Quote  Post ReplyReply Direct Link To This Post Topic: Instantaneous Trendline and Sinewave Indicator
    Posted: 12 Jul 2011 at 10:49pm
Hi guys,

I have a great indicator that I use with another charting package (dare I say Embarrassed), which is the Hilbert Sine Wave, it's very good at finding changes in direction. I found the metastock code here http://forum.equis.com/forums/thread/28213.aspx    ...I can't code, but by the looks of it, it could be a lot of work, but well worth the time. If someone has this or could develop it for Bullcharts I would be much appreciative! Smile
Back to Top
Tanaka View Drop Down
Newbie
Newbie


Joined: 08 Jul 2010
Posts: 18
Post Options Post Options   Quote Tanaka Quote  Post ReplyReply Direct Link To This Post Posted: 15 Jul 2011 at 12:33pm
I also found this code for Tradestation, this is the sine wave which is what will give you an edge especially in choppy markets:

Typ : Indicator, Name : Sine Wave Indicator

Inputs:
Price((H+L)/2); 

Vars:
InPhase(0),
Quadrature(0),
Phase(0),
DeltaPhase(0),
count(0),
InstPeriod(0),
Period(0),
DCPhase(0),
RealPart(0),
ImagPart(0);

If CurrentBar > 5 then begin

{Compute InPhase and Quadrature components}
Value1 = Price - Price[6];
Value2 =Value1[3];
Value3 =.75*(Value1 - Value1[6]) + .25*(Value1[2] - Value1[4]);
InPhase = .33*Value2 + .67*InPhase[1];
Quadrature = .2*Value3 + .8*Quadrature[1];

{Use ArcTangent to compute the current phase}
If AbsValue(InPhase +InPhase[1]) > 0 then Phase =
ArcTangent(AbsValue((Quadrature+Quadrature[1]) / (InPhase+InPhase[1])));

{Resolve the ArcTangent ambiguity}
If InPhase < 0 and Quadrature > 0 then Phase = 180 - Phase;
If InPhase < 0 and Quadrature < 0 then Phase = 180 + Phase;
If InPhase > 0 and Quadrature < 0 then Phase = 360 - Phase;

{Compute a differential phase, resolve phase wraparound, and limit delta phase errors}
DeltaPhase = Phase[1] - Phase;
If Phase[1] < 90 and Phase > 270 then DeltaPhase = 360 + Phase[1] - Phase;
If DeltaPhase < 1 then DeltaPhase = 1;
If DeltaPhase > 60 then Deltaphase = 60;

{Sum DeltaPhases to reach 360 degrees. The sum is the instantaneous period.}
InstPeriod = 0;
Value4 = 0;
For count = 0 to 40 begin
Value4 = Value4 + DeltaPhase[count];
If Value4 > 360 and InstPeriod = 0 then begin
InstPeriod = count;
end;
end;

{Resolve Instantaneous Period errors and smooth}
If InstPeriod = 0 then InstPeriod = InstPeriod[1];
Value5 = .25*InstPeriod + .75*Value5[1];

{Compute Dominant Cycle Phase, Sine of the Phase Angle, and Leadsine}
Period = IntPortion(Value5);
RealPart = 0;
ImagPart = 0;
For count = 0 To Period - 1 begin
RealPart = RealPart + Sine(360 * count / Period) * (Price[count]);
ImagPart = ImagPart + Cosine(360 * count / Period) * (Price[count]);
end;
If AbsValue(ImagPart) > 0.001 then DCPhase = Arctangent(RealPart / ImagPart);
If AbsValue(ImagPart) <= 0.001 then DCPhase = 90 * Sign(RealPart);

DCPhase = DCPhase + 90;
If ImagPart < 0 then DCPhase = DCPhase + 180;
If DCPhase > 315 then DCPhase = DCPhase - 360;

Plot1(Sine(DCPhase), "Sine");
Plot2(Sine(DCPhase + 45), "LeadSine");

end;
    Back to Top
    cudderbean View Drop Down
    Regular
    Regular
    Avatar

    Joined: 02 Oct 2006
    Location: Thailand
    Posts: 40
    Post Options Post Options   Quote cudderbean Quote  Post ReplyReply Direct Link To This Post Posted: 02 Aug 2011 at 11:37pm
    Way beyond my capabilities, but it certainly looks very interesting.
     
    I hope someone on the forum is capable of coding this for BullCharts.
    Back to Top
    cmacdon View Drop Down
    BullCharts Guru
    BullCharts Guru


    Joined: 09 Sep 2012
    Location: Brisbane
    Posts: 236
    Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 16 Sep 2012 at 7:33am
    Tanaka
     
    This may help if no one has reqritten the above code in Bullscript.
     
    I can run most of john Ehlers indicators including the Instantaneous Trendline and Sinewave in Bullcharts as explained below.
     
    In 2008 I bought Adaptive Cycle Toolkit, a Metastock add in from the Dynamic Market Lab  (DML) which contains 72 external  DLLs and well over 150 indicators mostly based on John Ehlers Rocket Science and Cybernetics books with multiple adaptations.  The manuals give the Metastock code for indicators to reference the external DLLs provided.  The DLLS from my understanding were based on Metastock Formula Primer so it was fairly open code among Metastock users as i understand the primer was de3veloped by users.  
    I put the DLL file in the Bullcharts External DLL Folder and have set up most of the indicators in my Bullcharts so they that refererence the External DLL based on the manual instructions which are usuallly only one or 2 lines per indicator..
    BC User since June 2007
    Back to Top
    cmacdon View Drop Down
    BullCharts Guru
    BullCharts Guru


    Joined: 09 Sep 2012
    Location: Brisbane
    Posts: 236
    Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 16 Sep 2012 at 8:27am
    Just re reading the above let me clarify and be a bit more specific- I have most of the John Ehlers indicators I want working.  There are 83 in all in either my current Bullchart indicator file or my archived Bullchart indicator file.
     
    The Ehler related indicators  I have used/tested on Bullcharts include:
    Butterworth Filters,Cybernetic Hilbert Oscillator, Homodyne Cycle, Laguerre Filters, Laguerre Stochastics, Laguerre RSI, Adaptive Centre of Gravity, Adfaptive RSI, Hilbert Oscillator, Hilbert Trandform, Optimum Predictor, Sinewae(cybernetics), Stochastic Fisher, Stochastic Hotelling and about 6 other stochastic variations.
     
    Some of the codes for the above were also provided in Metastock format in various Ehlers articles in Technical Analysis of Stocks and Commodities (Tasc) over the last decade.
     
    There are many other non-Ehlers indicators that are on the two packages contained in the Toolkit that I ignore or have not tried to get running on Bullcharts as they or equivalent indicators are on Bullcharts.  Also I recall there were two ot three indicators referencing external Dlls I tried to get working on Bullcharts but they did not work for some reason when referenced by Bullscript. 
     
     
    BC User since June 2007
    Back to Top
     Post Reply Post Reply

    Forum Jump Forum Permissions View Drop Down

    Bulletin Board Software by Web Wiz Forums® version 9.69
    Copyright ©2001-2010 Web Wiz