trendline automatic indicator

Questions about MultiCharts and user contributed studies.
dlahyani
Posts: 24
Joined: 06 Feb 2007

trendline automatic indicator

Postby dlahyani » 27 Jul 2009

how could I make the trendline automatic indicator to plot thicker lines?

User avatar
TJ
Posts: 6572
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1901 times

Postby TJ » 27 Jul 2009

go to Format> Study,

change TrendLine.width to any size you like.


Code: Select all

inputs:
   SwHiStrength( 4 ),
   SwLoStrength( 4 ),
   BarsPast( 10 ),
   History( "Yes" ),
   DnTLColor( Red ),
   UpTLColor( Cyan ),
   AlertType( "IntraBar" ),
   TrendLine.width(1) ; {<-- added this line}

variables:
   var0( -1 ),
   var1( 0 ),
   var2( false ),
   var3( DnTLColor ),

   var4( -1 ),
   var5( 0 ),
   var6( false ),
   var7( UpTLColor ),

   var8( 0 ),
   var9( 0 ),
   var10( false ),
   var11( UpperStr( AlertType ) ) ;

arrays:
   arr0[10]( 0 ),
   arr1[10]( 0 ),
   arr2[10]( -1000000 ),
   arr3[10]( 0 ),
   arr4[10]( 0 ),
   arr5[10]( 1000000 ) ;

if CurrentBar = 1 then
   var10 = UpperStr( History ) = "YES" or UpperStr( History ) = "Y" ;
                                                          

var9 = CurrentBar;

condition1 = SwingHighBar( 1, High, SwHiStrength, SwHiStrength + 1 ) = SwHiStrength ;
if condition1 then
                             
   begin

                      
   for Value1 = 9 downto 0
      begin
      arr0[ Value1 + 1 ] = arr0[Value1] ;
      arr1[ Value1 + 1 ] = arr1[Value1] ;
      arr2[ Value1 + 1 ] = arr2[Value1] ;
      end ;

                                                              
   arr0[0] = Date[SwHiStrength] ;
   arr1[0] = Time[SwHiStrength] ;
   arr2[0] = High[SwHiStrength] ;

                                                                              
   for Value2 = 1 to 10
      begin
      if arr2[Value2] > arr2[0] then
         begin
         var8 = Value2 ;
         Value2 = 11 ;                                                         
                                            
         end ;
      end ;

   if Value2 = 12 then                                               
      begin
      if var0 >= 0 then                                 
         begin
         condition1 = var10 and var2 = false ;
         if condition1 then
                                                                         
                                         
            begin
            TL_SetEnd( var0, Date, Time, TL_GetValue( var0, Date, Time ) ) ;
            TL_SetExtRight( var0, false ) ;
            end
         else if var10 = false then
                                                           
            TL_Delete( var0 ) ;
         end ;
                                                                               
      var0 = TL_New( arr0[var8], arr1[var8], arr2[var8],
       arr0[0], arr1[0], arr2[0] ) ;
       tl_setsize(var0, TrendLine.width); {<-- added this line}
      if var2 = true then
         var2 = false ;
      var1 = var9 - SwHiStrength ;
      TL_SetExtLeft( var0, false ) ;
      TL_SetExtRight( var0, true ) ;
      if var3 <> 99 then
         TL_SetColor( var0, var3 ) ;
      if var11 = "ONCLOSE" then
         TL_SetAlert( var0, 2 )
      else if var11 = "INTRABAR" then
         TL_SetAlert( var0, 1 )
      else
         TL_SetAlert( var0, 0 ) ;
      end ;
   end ;

condition1 = SwingLowBar( 1, Low, SwLoStrength, SwLoStrength + 1 ) = SwLoStrength ;
if condition1 then                               
   begin                      
   for Value1 = 9 downto 0
      begin
      arr3[Value1+1] = arr3[Value1] ;
      arr4[Value1+1] = arr4[Value1] ;
      arr5[Value1+1] = arr5[Value1] ;
      end ;

                                                              
   arr3[0] = Date[SwLoStrength] ;
   arr4[0] = Time[SwLoStrength] ;
   arr5[0] = Low[SwLoStrength] ;

                                                                              
   for Value2 = 1 to 10
      begin
      if arr5[Value2] < arr5[0] then
         begin
         var8 = Value2 ;
         Value2 = 11 ;                                                         
                                            
         end ;
      end ;

   if Value2 = 12 then                                               
      begin
      if var4 >= 0 then                               
         begin
         condition1 = var10 and var6 = false ;
         if condition1 then                                          
            begin
            TL_SetEnd( var4, Date, Time, TL_GetValue( var4, Date, Time ) ) ;
            TL_SetExtRight( var4, false ) ;
            end
         else if var10 = false then
                                                           
            TL_Delete( var4 ) ;
         end ;
                                                                               
      var4 = TL_New( arr3[var8], arr4[var8], arr5[var8],
       arr3[0], arr4[0], arr5[0] ) ;
       tl_setsize(var4, TrendLine.width); {<-- added this line}
      if var6 = true then
         var6 = false ;
      var5 = var9 - SwLoStrength ;
      TL_SetExtLeft( var4, false ) ;
      TL_SetExtRight( var4, true ) ;
      if var7 <> 99 then
         TL_SetColor( var4, var7 ) ;
      if var11 = "ONCLOSE" then
         TL_SetAlert( var4, 2 )
      else if var11 = "INTRABAR" then
         TL_SetAlert( var4, 1 )
      else
         TL_SetAlert( var4, 0 ) ;
      end ;
   end ;

                                                                                   
                                                                                     
                 
condition1 = var0 >= 0
   and var2 = false
   and var9 > var1 + SwHiStrength + BarsPast
   and ( Close > TL_GetValue( var0, Date, Time ) )[BarsPast];

if condition1
then
   begin
   TL_SetEnd( var0, Date, Time, TL_GetValue( var0, Date, Time ) ) ;
   TL_SetExtRight( var0, false ) ;
   var2 = true ;
   end ;

condition1 = var4 >= 0
   and var6 = false
   and var9 > var5 + SwLoStrength + BarsPast
   and ( Close < TL_GetValue( var4, Date, Time ) )[BarsPast];

if condition1
then
   begin
   TL_SetEnd( var4, Date, Time, TL_GetValue( var4, Date, Time ) ) ;
   TL_SetExtRight( var4, false ) ;
   var6 = true ;
   end ;
Last edited by TJ on 27 Jul 2009, edited 1 time in total.

dlahyani
Posts: 24
Joined: 06 Feb 2007

TL automatic

Postby dlahyani » 27 Jul 2009

thanks TJ, that was fast.

Daniel

User avatar
TJ
Posts: 6572
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1901 times

Re: TL automatic

Postby TJ » 27 Jul 2009

thanks TJ, that was fast.
Daniel



that was easy too.

MultiCharts is an enabler.
It lets the trader "see" what he needs to see.

I hope you get the time and patience to study the code...
it is not difficult; you too can make modifications like this.



p.s. I have added annotation to the code.

dlahyani
Posts: 24
Joined: 06 Feb 2007

code

Postby dlahyani » 27 Jul 2009

TJ,

somehow I can't find the patience to study the code, it happen before that when I needed something I'd hire a programmer to do it for me. recently I spent some money to code an indicator that plot divergence between 2 symbols. it would take me years to master codding when a programmer can do it in a few hrs codding. before MC I used esignal and they had this programming wizard, this was helpful for simple things but I hated the charting software. that's why I moved to MC. I use it since beta of ver 1.

thanks again, Daniel

User avatar
TJ
Posts: 6572
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1901 times

Postby TJ » 27 Jul 2009

I hope you found the divg indicator useful.

Tresor posted a MACD divg code in the user forum.
Last edited by TJ on 27 Jul 2009, edited 1 time in total.

dlahyani
Posts: 24
Joined: 06 Feb 2007

Postby dlahyani » 27 Jul 2009

the code I have is for price to price divergence not price/indicator. that means 2 symbols in the same chart window. see chart attached.

D
Attachments
15min.png
15min.png (36.05 KiB) Viewed 246 times


Return to “MultiCharts”