how to code a trendline from a moving average?

Questions about MultiCharts and user contributed studies.
User avatar
scarecrow
Posts: 50
Joined: 12 Apr 2012
Has thanked: 14 times
Been thanked: 3 times

how to code a trendline from a moving average?

Postby scarecrow » 30 Jul 2012

fairly straight forward but giving me trouble please bear with me, still learning.
how would you code a trend line or tl_new statement to draw a line from a moving average crossing?? then maybe end on subsequent prices of moving averages, or high pivot or current high...
basically i'm having trouble capturing a MA cross for a trend line statement
here is a snippet of code that i've learned for pivots... how would i modify it for MA trend lines??

Code: Select all

condition1 = Pivot(L,25,leftstrength,rightstrength,1,-1,oPivotPrice1,oPivotBar1) <>-1;
{confirms most recent bottom pivot}
condition2 = Pivot(L,25,leftstrength,rightstrength,2,-1,oPivotPrice2,oPivotBar2) <>-1;
{confirms next most recent bottom pivot}
TL_new(D[oPivotBar2], T[oPivotBar2], L[oPivotBar2],
      D[oPivotBar1], T[oPivotBar1], L[oPivotBar1]);

User avatar
Henry MultiСharts
Posts: 8503
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2731 times

Re: how to code a trendline from a moving average?

Postby Henry MultiСharts » 30 Jul 2012

Hello Scarecrow,

Here is a suggestion from our coder:

Code: Select all

SMA1 = Average(close,1);
SMA2 = Average(close,2);

if SMA1 >= SMA2 and SMA1[1] < SMA2 then begin
   PointIntersectDate = Date;
   PointIntersectTime = time;
end;

TL_new(PointIntersectDate ,PointIntersectTime ,High, PointIntersectDate , PointIntersectTime , Low);

Plot1(SMA1,"SMA1 ");   
Plot2(SMA2,"SMA2 ");   
These users thanked the author Henry MultiСharts for the post:
JoshM

User avatar
scarecrow
Posts: 50
Joined: 12 Apr 2012
Has thanked: 14 times
Been thanked: 3 times

Re: how to code a trendline from a moving average?

Postby scarecrow » 30 Jul 2012

awesome thanks, I'll play around with it for awhile.


Return to “MultiCharts”