NexusFi: Find Your Edge


Home Menu

 





Another EL Learning Exercise


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,495 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

Another EL Learning Exercise

  #1 (permalink)
TrendFirst
Calgary AB Canada
 
Posts: 8 since Jan 2016
Thanks Given: 2
Thanks Received: 0

I'm continuing down the path of learning EL, starting by exploring some of the indicators included with MultiCharts. When I saw one labeled "Elder Triple Screen", I thought "Well this might be an easier one for me to understand, since I have Elder's original book". So I started reviewing it.

While I'm thankful that MC included indicator code with the software package, I have to say that their Elder Triple Screen is, well, not really a triple screen. The original triple screen worked on three time frames, hence the name. The MC Triple Screen works on one time frame. It does use two screens, the slope of an EMA line and the slope of the MACD Histogram, to paint bars.

I'm not an expert on the history of EL by any means, but it seems to be coded with an older version of EL. I also found their variable-naming convention confusing. Here is my code, using different nomenclature that makes more sense to me.

 
Code
{ ------------------------------------------------------------------------------------------
 
 A bit of practice here, along with "correcting" one of the existing MC indicators,
 which they called Elder Triple Screen.  It's not - it's not even close to the
 original ETS.  So I'm renaming it and re-coding it, using nomenclature that makes
 more sense to me.  MC used variable names that didn't seem logical to me.
 
 I'm calling this the MACD_EMA Double Screen.  One time frame, two screens. Next step
 will be doing a proper Elder Triple Screen that actually uses three time frames.
 
 How this works:
 If MACD Histogram slope is up and EMA slope is up, bars are painted green.
 If MACD Histogram slope is down and EMA slope is down, bars are painted red.
 If the slopes point in opposite directions, bars are painted yellow.
 
 ------------------------------------------------------------------------------------------- }
 
 Inputs:
 	UpColor   (Green),      // Paintbar colors used
 	DownColor (Red),
 	FlatColor (Yellow),
 	FastEMAPeriod (12),     // Fast period used to calculate MACD
 	SlowEMAPeriod (26),     // Slow period used to calculate MACD
 	SignalPeriod   (9),     // EMA period used for calculating the Signal Line
 	EMAPeriod     (26),     // Exponential moving average period for calculating EMA slope
 	MACDPrice     (Close);  // Closing price is used in the calculations
 	
 Variables:
 	MACDLine      (0),      // MACD line, also known as fast line, usually solid color
 	SignalLine    (0),      // Signal line, also known as slow line, usually dashed line
 	Histogram     (0),      // Histogram bars, which are MACDLine - SignalLine
 	EMALine       (0),      // Exponential Moving Average
 	PlotColor     (0);
 
 	
 EMALine    = Xaverage (Close, EMAPeriod);
 MACDLine   = (MACD (MACDPrice, FastEMAPeriod, SlowEMAPeriod));
 SignalLine = Xaverage (MACDLine, SignalPeriod);
 Histogram  = MACDLine - SignalLine;
 
 
 If (( EMALine > EMALine[1]) and (Histogram > Histogram[1])) then begin
 	PlotColor    = UpColor;
 end
 
 Else If (( EMALine < EMALine[1]) and (Histogram < Histogram[1])) then begin
 	PlotColor    =  DownColor;
 end
 
 Else If (((EMALine <= EMALine[1]) and (Histogram >= Histogram[1]))
	or (EMALine >= EMALine[1]) and Histogram <= Histogram[1]) then begin
	PlotColor    = FlatColor;
 end;
 
 PlotPaintBar (High, Low, Open, Close, "MACD_EMA Double Screen", PlotColor);


And here is the old code for comparison:

 
Code
{ 27499 }

{Title:  Alexander Elder Triple Screen: Initial Screen for Trading Prospects

Description:

1.  Paint the bar green when the EMA and the MACD histogram each turn up.       Possible long setup.
2.  Paint the bar red when the EMA and the MACD histogram each turn down.      Possible short setup.
3.  Paint the bar yellow when the EMA and the MACD go in different directions.  No trade setup.

}

{Declarations}
      
   Inputs:
   
      LongColor(Green),         {Paintbar color for possible long}
      ShortColor(Red),         {Paintbar color for possible short}
      NoActionColor(Yellow),      {Paintbar color for noaction}
         
      MACDPrice(Close),         {MACD Price value used in calculation}
      MACDExpMALength(9),      {MACD Smoothing Exponential Moving Average Length}
      MACDFastLength(12),      {MACD Fast length value used in calculation}
      MACDSlowLength(26),      {MACD Slow length value used in calculation}

      MALength(26);         {Moving average length}


   Variables:
      
      AlertMessage(""),         {Content of Alert Message}
      PlotColor(0),         {Color to be plotted}
      PlotMessage(""),         {Message to be plotted}

      MACDDiff(0),         {MACD Difference used to plot MACD histogram}
      MAValue(0),         {Current moving average value}
      MACDAvg(0),
      MACDValue(0),         {Current MACD value}
      OldMACDDiff(0),         {Prior MACD Diff Value to which current will be compared}
      OldMACDValue(0),         {Prior MACD value to which current will be compared}

      OldMAValue(0);         {Prior Moving average value to which current will be compared}


{Procedure}
      
      OldMAValue=MAValue;      {Capture old moving average value before calculating new}
      MAValue=Xaverage(Close,MALength);

      OldMACDDiff=MACDDiff;      {Capture old MACD Diff value before calculating new}
      OldMACDValue=MACDValue;      {Capture old MACD value before calculating new}
      MACDValue=MACD(MACDPrice, MACDFastLength,MACDSlowLength);
      MACDAvg=Xaverage(MACD(MACDPrice, MACDFastLength,MACDSlowLength),MACDExpMALength);
      MACDDiff=(MACDValue-MACDAvg);   {MACDDiff is the diffe between MACD  and MACD Exp Value}


      If ((MAValue > OldMAValue) and (MACDDiff > OldMACDDiff)) then
         begin
            PlotColor=LongColor ;
            AlertMessage="Long";
         end

      Else
      If ((MAValue < OldMAValue) and (MACDDiff < OldMACDDiff)) then
         begin
            PlotColor=ShortColor ;
            AlertMessage="Short";
         end

      Else
If ((MAValue <= OldMAValue) and (MACDDiff >= OldMACDDiff)) or ((MAValue >= OldMAValue) and (MACDDiff <= OldMACDDiff)) then
         begin
            PlotColor=NoActionColor;
            AlertMessage="NoAction";
         end;


      PlotPaintBar(High,Low,Open,Close, "Elder Screen", PlotColor) ;
      Alert( AlertMessage ) ;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Futures True Range Report
The Elite Circle
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Build trailing stop for micro index(s)
Psychology and Money Management
Are there any eval firms that allow you to sink to your …
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
GFIs1 1 DAX trade per day journal
22 thanks
NexusFi site changelog and issues/problem reporting
22 thanks
The Program
20 thanks




Last Updated on April 10, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts