Return to Snippet

Revision: 43816
at March 31, 2011 08:01 by ram321


Initial Code
'----------------------------
    ' xmean and slopexmean
    '----------------------------
    If i > 8 Then
        shtDB.Range("E1").Cells(i, 1).FormulaR1C1 = "=AVERAGE(R[-7]C[-4]:RC[-4])"
        shtDB.Range("E1").Cells(i, 1).Value = shtDB.Range("E1").Cells(i, 1).Value
        
        'shtDB.Range("K1").Cells(i, 1).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2"    ' slope
        'shtDB.Range("K1").Cells(i, 1).Value = shtDB.Range("K1").Cells(i, 1).Value
        
        shtDB.Range("K1").Cells(i, 1).Value = Slope( _
            shtDB.Range("E1").Cells(i - 2, 1).Value, _
            shtDB.Range("E1").Cells(i - 1, 1).Value, _
            shtDB.Range("E1").Cells(i, 1).Value)
        
        If i > 15 Then
            shtDB.Range("E1").Cells(i, 2).FormulaR1C1 = "=AVERAGE(R[-14]C[-5]:RC[-5])"
            shtDB.Range("E1").Cells(i, 2).Value = shtDB.Range("E1").Cells(i, 2).Value
            
            'shtDB.Range("K1").Cells(i, 2).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2"    ' slope
            'shtDB.Range("K1").Cells(i, 2).Value = shtDB.Range("K1").Cells(i, 2).Value
                
            shtDB.Range("K1").Cells(i, 2).Value = Slope( _
                shtDB.Range("E1").Cells(i - 2, 2).Value, _
                shtDB.Range("E1").Cells(i - 1, 2).Value, _
                shtDB.Range("E1").Cells(i, 2).Value)
            
            If i > 30 Then
                shtDB.Range("E1").Cells(i, 3).FormulaR1C1 = "=AVERAGE(R[-29]C[-6]:RC[-6])"
                shtDB.Range("E1").Cells(i, 3).Value = shtDB.Range("E1").Cells(i, 3).Value
                
                'shtDB.Range("K1").Cells(i, 3).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2"    ' slope
                'shtDB.Range("K1").Cells(i, 3).Value = shtDB.Range("K1").Cells(i, 3).Value
                
                shtDB.Range("K1").Cells(i, 3).Value = Slope( _
                    shtDB.Range("E1").Cells(i - 2, 3).Value, _
                    shtDB.Range("E1").Cells(i - 1, 3).Value, _
                    shtDB.Range("E1").Cells(i, 3).Value)
                    
                If i > 80 Then
                    shtDB.Range("E1").Cells(i, 4).FormulaR1C1 = "=AVERAGE(R[-79]C[-7]:RC[-7])"
                    shtDB.Range("E1").Cells(i, 4).Value = shtDB.Range("E1").Cells(i, 4).Value
                    
                    'shtDB.Range("K1").Cells(i, 4).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2"    ' slope
                    'shtDB.Range("K1").Cells(i, 4).Value = shtDB.Range("K1").Cells(i, 4).Value
                        
                    shtDB.Range("K1").Cells(i, 4).Value = Slope( _
                        shtDB.Range("E1").Cells(i - 2, 4).Value, _
                        shtDB.Range("E1").Cells(i - 1, 4).Value, _
                        shtDB.Range("E1").Cells(i, 4).Value)
                        
                    If i > 110 Then
                        shtDB.Range("E1").Cells(i, 5).FormulaR1C1 = "=AVERAGE(R[-109]C[-8]:RC[-8])"
                        shtDB.Range("E1").Cells(i, 5).Value = shtDB.Range("E1").Cells(i, 5).Value
                    
                        'shtDB.Range("K1").Cells(i, 5).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2"    ' slope
                        'shtDB.Range("K1").Cells(i, 5).Value = shtDB.Range("K1").Cells(i, 5).Value
                                
                        shtDB.Range("K1").Cells(i, 5).Value = Slope( _
                            shtDB.Range("E1").Cells(i - 2, 5).Value, _
                            shtDB.Range("E1").Cells(i - 1, 5).Value, _
                            shtDB.Range("E1").Cells(i, 5).Value)
                        
                        If i > 200 Then
                            shtDB.Range("E1").Cells(i, 6).FormulaR1C1 = "=AVERAGE(R[-199]C[-9]:RC[-9])"
                            shtDB.Range("E1").Cells(i, 6).Value = shtDB.Range("E1").Cells(i, 6).Value
                        
                            'shtDB.Range("K1").Cells(i, 6).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2"    ' slope
                            'shtDB.Range("K1").Cells(i, 6).Value = shtDB.Range("K1").Cells(i, 6).Value
                        
                            shtDB.Range("K1").Cells(i, 6).Value = Slope( _
                                shtDB.Range("E1").Cells(i - 2, 6).Value, _
                                shtDB.Range("E1").Cells(i - 1, 6).Value, _
                                shtDB.Range("E1").Cells(i, 6).Value)
                        End If
                    End If
                End If
            End If
        End If
    End If

Initial URL

                                

Initial Description

                                

Initial Title
automated trading - code vba 3

Initial Tags

                                

Initial Language
Visual Basic