CODING help requested for multiple data symbol indicator

Questions about MultiCharts and user contributed studies.
johnson scott
Posts: 7
Joined: 19 Nov 2007

CODING help requested for multiple data symbol indicator

Postby johnson scott » 19 Dec 2007

Hi,
I am hoping someone with more EL experience can tell me what I'm doing wrong in this indicator. I can do a bit of EL coding, but have been baffled by coding indicators that call multiple data streams for their calculation.

I included my code below. In this case, I am trying to write a Paint Bar indicator that will paint a bullish color when:

1. MACD is above its Trigger for data1
2. MACD Hist is above an 8 period trigger for data1
3. MACD is above its trigger for data2
4. MACD Hist is above an 8 period trigger for data2

and a bearish color when opposite.

In other words, a paint bar that gets confirmation from a higher timeframe, and has coding that calls for higher timeframe data to be used to paint lower timeframe bars.

I applied this to a chart with 1 minute YM on data1 and 3 minute YM on data2, with the indicator itself applied to data1. Thus, I'm expecting the indicator to use the 1 minute data unless the code specifally asks for the 3 minute data (data2). If I plot the code below, it paints something else entirely. When I plot the MACD's and Hist's from both timeframes on the chart, The paint does not match any of the four. What am I doing wrong here? I hope there is some EL programmer out there who can set me straight. If you look at the code, you'll note I didn't finish the plot statements. I only plotted the first condition since I was troubleshooting. I'll write the rest of the conditions once I find out where I am going wrong with my EL coding.

Thanks for the help.
Scott



Inputs:
FastLen1(12),
SlowLen1(26),
MACDLen1(9),
TriggerLen1(8),
FastLen2(12),
SlowLen2(26),
MACDLen2(9),
TriggerLen2(8);

Variables:
MyMACD1(0),
Diff1(0),
Trigger1(0),
DiffTrig1(0),
MyMACD2(0),
Diff2(0),
Trigger2(0),
DiffTrig2(0);


MyMACD1 = AverageFC(close, FastLen1) - AverageFC(close, SlowLen1);
Trigger1 = AverageFC(MyMACD1, MACDLen1);
Diff1 = MyMACD1 - Trigger1;
DiffTrig1 = AverageFC(Diff1, TriggerLen1);


MyMACD2 = AverageFC(close data2, FastLen2) - AverageFC(close data2, SlowLen2);
Trigger2 = AverageFC(MyMACD2, MACDLen2);
Diff2 = MyMACD2 - Trigger2;
DiffTrig2 = AverageFC(Diff2, TriggerLen2);


Condition1 = Diff2 >= DiffTrig2;

if condition1 then
plotpb(h,l, "DT2 Up");

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Postby TJ » 19 Dec 2007

you can compile another copy of this indicator with the following plots to see how your indicator trigger is doing:

plot1(Diff1, "diff1");
plot2(DiffTrig1, "difftrig1");

plot3(Diff2, "diff2");
plot4(DiffTrig2, "difftrig2");


Return to “MultiCharts”