Help requested for MESA MAMA FAMA indicator function - EasyLanguage Programming | futures io social day trading

Help requested for MESA MAMA FAMA indicator function
 Updated: October 7th, 2014 (12:11 PM) Views / Replies: 9,383 / 21 Created: December 15th, 2010 (02:48 PM) by gpw797 Attachments: 0

 Welcome to futures io.

# Help requested for MESA MAMA FAMA indicator function

Membership Permanently Revoked
Mesa, AZ

Platform: Multicharts
Favorite Futures: ES

Posts: 55 since Oct 2010

Help requested for MESA MAMA FAMA indicator function

I have been playing around with the MAMA FAMA indicator and want to try some strategy stuff but I don't have the programming skills to turn this into functions. Can somebody help with turning these into functions or point to place on the web for the functions? Code for indicators is below, thanks

Code
 {Ehlers MAMA and FAMA indicator - coded by dn //// From Cybernetic Analysis for Stocks and Futures} Inputs: Price((H+L)/2), FastLimit(.5),SlowLimit(.05); Vars: Smooth(0), Detrender(0),I1(0),Q1(0),jI(0),jQ(0),I2(0),Q2(0),Re(0), Im(0), Period(0),SmoothPeriod(0),Phase(0),DeltaPhase(0),alpha(0), MAMA(0),FAMA(0); If CurrentBar > 5 then begin Smooth = (4*Price + 3*Price[1] + 2*Price[2] + Price[3]) / 10; Detrender = (.0962*Smooth + .5769*Smooth[2] - .5769*Smooth[4] - .0962*Smooth[6])*(.075*Period[1] + .54); {Compute InPhase and Quadrature components} Q1 = (.0962*Detrender + .5769*Detrender[2] - .5769*Detrender[4] - .0962*Detrender[6])*(.075*Period[1] + .54); I1 = Detrender[3]; {Advance the phase of I1 and Q1 by 90 degrees} jI = (.0962*I1 + .5769*I1[2] - .5769*I1[4] - .0962*I1[6])*(.075*Period[1] + .54); jQ = (.0962*Q1 + .5769*Q1[2] - .5769*Q1[4] - .0962*Q1[6])*(.075*Period[1] + .54); {Phasor addition for 3-bar averaging)} I2 = I1 - jQ; Q2 = Q1 + jI; {Smooth the I and Q components before applying the discriminator} I2 = .2*I2 + .8*I2[1]; Q2 = .2*Q2 + .8*Q2[1]; {Homodyne Discriminator} Re = I2*I2[1] + Q2*Q2[1]; Im = I2*Q2[1] - Q2*I2[1]; Re = .2*Re + .8*Re[1]; Im = .2*Im + .8*Im[1]; If Im <> 0 and Re <> 0 then Period = 360/ArcTangent(Im/Re); If Period > 1.5*Period[1] then Period = 1.5*Period[1]; If Period < .67*Period[1] then Period = .67*Period[1]; If Period < 6 then Period = 6; If Period > 50 then Period = 50; Period = .2*Period + .8*Period[1]; SmoothPeriod = .33*Period + .67*SmoothPeriod[1]; If I1 <> 0 then Phase = (ArcTangent(Q1 / I1)); DeltaPhase = Phase[1] - Phase; If DeltaPhase < 1 then DeltaPhase = 1; alpha = FastLimit / DeltaPhase; If alpha < SlowLimit then alpha = SlowLimit; If alpha > FastLimit then alpha = FastLimit; MAMA = alpha*Price + (1 - alpha)*MAMA[1]; FAMA = .5*alpha*MAMA + (1 - .5*alpha)*FAMA[1]; Plot1(MAMA, "MAMA"); Plot2(FAMA, "FAMA"); End;

 December 15th, 2010, 02:48 PM #2 (permalink) Quick Summary Quick Summary Post Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

Elite Member
Atlanta, Georgia

Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB

Posts: 224 since Mar 2010

Try this:

function:

Code
 {Ehlers MAMA and FAMA indicator - coded by dn //// From Cybernetic Analysis for Stocks and Futures} Inputs: Price(NumericSeries), FastLimit(NumericSimple),SlowLimit(NumericSimple), MAMA(NumericRef), FAMA(NumericRef); Vars: Smooth(0), Detrender(0),I1(0),Q1(0),jI(0),jQ(0),I2(0),Q2(0),Re(0), Im(0), Period(0),SmoothPeriod(0),Phase(0),DeltaPhase(0),alpha(0), _MAMA(0),_FAMA(0); If CurrentBar > 5 then begin Smooth = (4*Price + 3*Price[1] + 2*Price[2] + Price[3]) / 10; Detrender = (.0962*Smooth + .5769*Smooth[2] - .5769*Smooth[4] - .0962*Smooth[6])*(.075*Period[1] + .54); {Compute InPhase and Quadrature components} Q1 = (.0962*Detrender + .5769*Detrender[2] - .5769*Detrender[4] - .0962*Detrender[6])*(.075*Period[1] + .54); I1 = Detrender[3]; {Advance the phase of I1 and Q1 by 90 degrees} jI = (.0962*I1 + .5769*I1[2] - .5769*I1[4] - .0962*I1[6])*(.075*Period[1] + .54); jQ = (.0962*Q1 + .5769*Q1[2] - .5769*Q1[4] - .0962*Q1[6])*(.075*Period[1] + .54); {Phasor addition for 3-bar averaging)} I2 = I1 - jQ; Q2 = Q1 + jI; {Smooth the I and Q components before applying the discriminator} I2 = .2*I2 + .8*I2[1]; Q2 = .2*Q2 + .8*Q2[1]; {Homodyne Discriminator} Re = I2*I2[1] + Q2*Q2[1]; Im = I2*Q2[1] - Q2*I2[1]; Re = .2*Re + .8*Re[1]; Im = .2*Im + .8*Im[1]; If Im <> 0 and Re <> 0 then Period = 360/ArcTangent(Im/Re); If Period > 1.5*Period[1] then Period = 1.5*Period[1]; If Period < .67*Period[1] then Period = .67*Period[1]; If Period < 6 then Period = 6; If Period > 50 then Period = 50; Period = .2*Period + .8*Period[1]; SmoothPeriod = .33*Period + .67*SmoothPeriod[1]; If I1 <> 0 then Phase = (ArcTangent(Q1 / I1)); DeltaPhase = Phase[1] - Phase; If DeltaPhase < 1 then DeltaPhase = 1; alpha = FastLimit / DeltaPhase; If alpha < SlowLimit then alpha = SlowLimit; If alpha > FastLimit then alpha = FastLimit; _MAMA = alpha*Price + (1 - alpha)*_MAMA[1]; _FAMA = .5*alpha*_MAMA + (1 - .5*alpha)*_FAMA[1]; MAMA= _MAMA; FAMA=_FAMA; End; MAMA_FAMA=0;
indicator:

Code
 {Ehlers MAMA and FAMA indicator - coded by dn //// From Cybernetic Analysis for Stocks and Futures} Inputs: Price((H+L)/2), FastLimit(.5),SlowLimit(.05); Vars: MAMA(0), FAMA(0); value0 = MAMA_FAMA(price, fastlimit, slowlimit, MAMA, FAMA); Plot1(MAMA, "MAMA"); Plot2(FAMA, "FAMA");
Regards,
-C

 “Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu
 The following user says Thank You to cbritton for this post:

 December 15th, 2010, 03:21 PM #4 (permalink) Membership Permanently Revoked Mesa, AZ   Trading Experience: Beginner Platform: Multicharts Favorite Futures: ES   Posts: 55 since Oct 2010 Thanks: 12 given, 16 received I got it to compile w/o the last line "MAMA_FAMA=0;" I can compile as 2 different functions and call each up separately? Or is there a way to reference each indicator within the single function? Your help is much appreciated, thanks.

Elite Member
Atlanta, Georgia

Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB

Posts: 224 since Mar 2010

gpw797
 I got it to compile w/o the last line "MAMA_FAMA=0;" I can compile as 2 different functions and call each up separately? Or is there a way to reference each indicator within the single function? Your help is much appreciated, thanks.

Really? It compiles for me without a problem. I'm using 8.8, update 6188.

Yes, you can split the function up. One to return FAMA and the other to return MAMA, but that's computationally more expensive, having to perform the same set of work twice. If that's not your concern, then go for it.

Regards,
-C

 “Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu
 The following user says Thank You to cbritton for this post:

 December 15th, 2010, 03:32 PM #6 (permalink) Membership Permanently Revoked Mesa, AZ   Trading Experience: Beginner Platform: Multicharts Favorite Futures: ES   Posts: 55 since Oct 2010 Thanks: 12 given, 16 received Opps.. I forgot to mention I am using Multicharts (sounds like you are using Tradestation by your version number). I will look at it some more tonight, thanks.

Elite Member
Atlanta, Georgia

Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB

Posts: 224 since Mar 2010

gpw797
 Opps.. I forgot to mention I am using Multicharts (sounds like you are using Tradestation by your version number). I will look at it some more tonight, thanks.

And here I was thinking that there's no difference between the two easy language platforms
Good to know there are some differences.

Regards,
-C

 “Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu

Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500

Posts: 46,976 since Jun 2009

gpw797
 I got it to compile w/o the last line "MAMA_FAMA=0;" I can compile as 2 different functions and call each up separately? Or is there a way to reference each indicator within the single function? Your help is much appreciated, thanks.

Make sure you named the function "MAMA_FAMA".

Mike

 The following user says Thank You to Big Mike for this post:

Elite Member
Atlanta, Georgia

Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB

Posts: 224 since Mar 2010

Big Mike
 Make sure you named the function "MAMA_FAMA". Mike

Yes, an important point I left out

Regards,
-C

 “Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu

Membership Permanently Revoked
Mesa, AZ

Platform: Multicharts
Favorite Futures: ES

Posts: 55 since Oct 2010

Changed name and got it to compile not excluding the last line. But not getting any signals generated from the following. What am I doing wrong? Thanks Sorry I am beginner at this stuff but trying to learn

Code
 //First attempt at MAMA FAMA Inputs: Price((H+L)/2), FastLimit(.5), SlowLimit(.05), contractsize (1); Variables: MAMA (0), FAMA (0); If FAMA > MAMA then Buy contractsize Contracts Next Bar At Market; If FAMA < MAMA then Sell short contractsize Contracts Next Bar At Market;

 futures io > Help requested for MESA MAMA FAMA indicator function

Upcoming Webinars and Events (4:30PM ET unless noted)

Apr 23

Elite only

## Benefits of Trading the Micro E-Minis w/Stage 5 & CME Group

Apr 30

 Similar Threads Thread Thread Starter Forum Replies Last Post michaelf NinjaTrader Programming 33 October 15th, 2014 05:34 PM serac NinjaTrader Programming 2 February 9th, 2011 03:54 PM ebtrader ThinkOrSwim Programming 2 December 11th, 2010 02:19 PM kenz987 Reviews of Brokers and Data Feeds 1 August 20th, 2010 02:09 PM Dragon Off-Topic 20 November 19th, 2009 09:15 PM

 Tags abc, ai, buy, code, crude, easy language, easylanguage, ehlers, el, eld, es, fractals, futures, indicator, indicators, information, limit, multicharts, neoticker, platform, programming, renko, short, signal, signals, size, split, stocks, strategy, tradestation, update