NexusFi: Find Your Edge


Home Menu

 





Another EL Learning Exercise


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #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?
After $87M Settles NO: Irans Nuclear Redline Sets Up the …
Prediction Markets & Event Contracts
US Prop Firms Race Inside the CFTC Perimeter -- Tradeify …
Funded Trading Evaluation Firms
Kalshi Sets $4.13B All-Time Weekly Record as Polymarket …
Prediction Markets & Event Contracts
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
CME Group CEO Calls CFTC-Approved Crypto Perps Dangerous …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks




Last Updated on April 10, 2016


© 2026 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 - Downloads - Top
no new posts