Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am just getting into programming for multiple data sets. My question is this. When I have a rather complicated indicator to calculate with 2 data sets; Is there a way I can copy my original code (For one data set) and paste it in below, and create a command for the newly pasted code to refer to data 2 only?
I have figured out have to program with 2 data sets for simple things like a moving average, but there must be an easier way to do it for a indicator with lengthy code like this.
Any help would be greatly appreciated.
See the attached code for an example. I would like to plot the results from data sets 1 and 2 on my main price chart.
Thanks in advance for your time and have a great day,
Peak1=ClsUp[1] and ClsDwn;
Peak2=lh[1] = False and ClsDwn;
Peak3=lh[1] = False and lh;
Peak4=ClsUp[1] and lh;
Peak5=hh[1] and hh = False;
Peak6=hh and ClsUp = False;
Bttm1=ClsDwn[1] and ClsUp;
Bttm2=hl[1] = False and ClsUp;
Bttm3=hl[1] = False and hl;
Bttm4=ClsDwn[1] and hl;
Bttm5=ll[1] and ll = False;
Bttm6=ll and ClsDwn = False;
Peak=(Peak1 or Peak2 or Peak3 or Peak4 or Peak5);
Bttm=(Bttm1 or Bttm2 or Bttm3 or Bttm4 or Bttm5);
If OldRzstnce <> -1 Then
Begin
NewRzstnceBegDate = TL_GetBeginDate(NewRzstnce);
NewRzstnceBegTime = TL_GetBeginTime(NewRzstnce);
OldRzstnceBegPrice = TL_GetBeginVal(OldRzstnce);
Value4 = TL_SetExtRight(OldRzstnce, False); //Stop extending the original line to the right.
Value5 = TL_SetEnd(OldRzstnce, NewRzstnceBegDate, NewRzstnceBegTime, OldRzstnceBegPrice);
End;
End;
{-- Starts a new trendline if a new bottom signal fires ---}
If Bttm and NoPriorBttm Then
Begin
OldSupport = NewSpprt;
If Bttm6 and NoPriorBttm then
NewSpprt = tl_new(d[1], t[1], L, d, t, L)
Else
NewSpprt = tl_new(d[1], t[1], L[1], d, t, L[1]);
If OldSupport <> -1 Then
Begin
NewSpprtBegDate = TL_GetBeginDate(NewSpprt);
NewSpprtBegTime = TL_GetBeginTime(NewSpprt);
OldSprtBegPrice = TL_GetBeginVal(OldSupport);
Value9 = TL_SetExtRight(OldSupport, False);
Value10 = TL_SetEnd(OldSupport, NewSpprtBegDate, NewSpprtBegTime, OldSprtBegPrice);
End;
End;
{-- Extends the old Resistance trendline if a new peak signal fires ---}
If Peak and NoPriorPk and H <= CrrntHi[1] Then
Begin
OldRzstnceExt = NewRzstnceExt;
NewRzstnceExt = tl_new(d[1], t[1], OldRzstnceBegPrice, d, t, OldRzstnceBegPrice);
If OldRzstnceExt <> -1 Then
Begin
NewRzstnceExtBegDate = TL_GetBeginDate(NewRzstnceExt);
NewRzstnceExtBegTime = TL_GetBeginTime(NewRzstnceExt);
OldHiExtBegPrice = TL_GetBeginVal(OldRzstnceExt);
Value14 = TL_SetExtRight(OldRzstnceExt, False);
Value15 = TL_SetEnd(OldRzstnceExt, NewRzstnceExtBegDate, NewRzstnceExtBegTime, OldHiExtBegPrice);
End;
End;
{-- Extends the old support line if a new bttm signal fires ---}
If Bttm and NoPriorBttm and L >= CrrntLw[1] Then
Begin
OldExtSpprt = NewSupportExt;
NewSupportExt = tl_new(d[1], t[1], OldSprtBegPrice, d, t, OldSprtBegPrice);
one approach could be to turn your code into a function and compute the function on different data streams.
You can find examples on nexusfi.com or in the official forum:
As soon as I read your reply, I knew that was exactly the answer I needed. While I currently do not know how to make a function; after doing some research that is certainly something I can learn (And should learn if I want to be a programmer).
Thanks much for the most succinct reply I have ever gotten in a forum!!