SUB btnOnClick(SENDER AS QBUTTON)

    DIM i AS INTEGER  'Loop counters...
    DIM j AS INTEGER
    DIM k AS SINGLE  'A Scratch Variable
    DIM ii AS INTEGER
    STATIC ClickedBar AS INTEGER  'Keep track of button clicks
    STATIC ClickedXY AS INTEGER
    STATIC ClickedBox AS INTEGER
    STATIC ClickedLine AS INTEGER

    SELECT CASE Sender.Caption

        CASE "Import CSV"
            Form2.Visible = 1
            form2.WindowState = 0
            SetFocus(Form2.Handle)

        CASE "Export CSV"
            exportfile()
            'Form2.visible=1
            'form2.WindowState=0
            'SetFocus(Form2.Handle)

        CASE "Histogram"
            ClickedBar = ClickedBar + 1  'Adding new series to existing chart
            IF ClickedBar > 3 THEN ClickedBar = 1  'one by one
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctBar  'Bar Chart
                .ChartStyle = csHisto  'Histogram
                .MainTitle.Text = "Histogram Example"  'Change desired options
                .SubTitle.Text = "No Axis Border, Add series with each click"
                .XTitle.Text = "Class Limits"
                .YTitle.Text = "Number"
                .AxisBorder = FALSE
                .XAxis.Grid = FALSE
                k = 10
                .DATA.ColCount = ClickedBar  'Set .Data dimensions based on ClickedBar
                .DATA.RowCount = 12
                RANDOMIZE  'Load the data
                .DATA.Cell(0 , 0) = "3"  'Col 0, Row 0 = data minimum
                FOR i = 1 TO .DATA.ColCount
                    .DATA.Cell(i , 0) = "Series " + STR$(i)
                    FOR j = i TO .DATA.RowCount - (i - 1)
                        .DATA.Cell(0 , j) = STR$(j * 3 + 3)
                        .DATA.Cell(i , j) = STR$(RND * k)
                    NEXT j
                NEXT i
                .DrawChart(FALSE) 'Draw it!
            END WITH

        CASE "Bar Graph"
            ClickedBar = ClickedBar + 1  'Adding new series to existing chart
            IF ClickedBar > 4 THEN ClickedBar = 1  'one by one
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctBar  'Bar Chart
                .ChartStyle = csBar  'Grouped Bars
                .MainTitle.Text = "Bar Graph Example 1"  'change desired options
                .SubTitle.Text = "Standard Bar Graph"
                .XTitle.Text = "X Axis"
                .YTitle.Text = "Y Axis"
                IF ClickedBar = 2 THEN .YAxis.LogScale = TRUE
                .DATA.ColCount = 6  'Set .Data Grid dimensions
                .DATA.RowCount = 3
                k = 75  'Load the data
                RANDOMIZE
                FOR i = 1 TO .DATA.ColCount
                    .DATA.Cell(i , 0) = "Grp " + STR$(i) 'Legend in Row 0 of each Col
                    FOR j = 1 TO .DATA.RowCount
                        SELECT CASE ClickedBar
                            CASE 1 , 2
                                .DATA.Cell(i , j) = STR$(RND * k)
                            CASE 3
                                .DATA.Cell(i , j) = STR$(RND * - k)
                            CASE 4
                                .DATA.Cell(i , j) = STR$((RND - RND) * k)
                        END SELECT
                    NEXT j
                NEXT i
                FOR j = 1 TO .DATA.RowCount
                    .DATA.Cell(0 , j) = "Treatment " + STR$(j) 'X Labels in Col 0 of each Row
                NEXT j
                .DrawChart(FALSE) 'Draw it!
            END WITH

        CASE "Stacked Bar"
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctBar  'Bar Chart
                .ChartStyle = csStacked  'Grouped Bars
                .MainTitle.Text = "Bar Graph Example 2"  'change desired options
                .SubTitle.Text = "Stacked Bar Graph"
                .XTitle.Text = "X Axis"
                .YTitle.Text = "Y Axis"
                .DATA.ColCount = 6  'Set .Data Grid dimensions
                .DATA.RowCount = 3
                k = 100  'Load the data
                RANDOMIZE
                FOR i = 1 TO .DATA.ColCount
                    .DATA.Cell(i , 0) = "Treatment " + STR$(i) 'Legend in Row 0 of each Col
                    FOR j = 1 TO .DATA.RowCount
                        .DATA.Cell(i , j) = STR$(RND * k + 1)
                    NEXT j
                NEXT i
                FOR j = 1 TO .DATA.RowCount
                    .DATA.Cell(0 , j) = "Group " + STR$(j) 'X Labels in Col 0 of each Row
                NEXT j
                .DrawChart(FALSE) 'Draw it!
            END WITH

        CASE "%Stacked Bar"
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctBar  'Bar Chart
                .ChartStyle = csPctStacked  'Grouped Bars
                .MainTitle.Text = "Bar Graph Example 3"  'change desired options
                .SubTitle.Text = "Percent Stacked Bar Graph"
                .XTitle.Text = "X Axis"
                .YTitle.Text = "Y Axis"
                .DATA.ColCount = 6  'Set .Data Grid dimensions
                .DATA.RowCount = 2
                k = 25  'Load the data
                RANDOMIZE
                FOR i = 1 TO .DATA.ColCount
                    .DATA.Cell(i , 0) = "Long Legend Title " + STR$(i) 'Legend in Row 0 of each Col
                    FOR j = 1 TO .DATA.RowCount
                        .DATA.Cell(i , j) = STR$(RND * k)
                    NEXT j
                NEXT i
                FOR j = 1 TO .DATA.RowCount
                    .DATA.Cell(0 , j) = "Level " + STR$(j) 'X Labels in Col 0 of each Row
                NEXT j
                .DrawChart(FALSE) 'Draw it!
            END WITH

        CASE "Pie Chart"
            WITH Graph  'The minimum (2) required calls
                .Initialize  'Always call this first
                .ChartType = ctPie
                .ChartStyle = csPiePct  'Show % at wedges (csPieVal shows Values)
                .AxisFont.Size = 12
                .LegendFont.Size = 12
                .MainTitle.Text = "Pie Chart"
                .SubTitle.Text = "Click Again For New Data"
                .DATA.ColCount = 6  'Set .Data Grid dimensions
                .DATA.RowCount = 1
                k = 10000  'Load the data
                RANDOMIZE
                FOR i = 1 TO .DATA.ColCount
                    .DATA.Cell(i , 0) = "Group " + STR$(i) 'Labels in Row 0 of Each Col
                    .DATA.Cell(i , 1) = STR$(RND * k * i) 'Data in Row 1 of Each Col
                NEXT
                .DrawChart(FALSE) 'Always call this last
            END WITH

        CASE "XY Points"
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctXY  'XY Scatter Chart
                .ChartStyle = csPoints  'Just the Points
                .MainTitle.Text = "Scatter Plot Example"  'change desired options
                .SubTitle.Text = "Data in All Four Quadrants"
                .XTitle.Text = "X Axis"
                .YTitle.Text = "Y Axis"
                .DATA.ColCount = 16  'Set .Data Grid dimensions
                .DATA.RowCount = 5
                k = 75  '<-- change k for large and small values
                RANDOMIZE  'Load the data
                FOR i = 2 TO .DATA.ColCount STEP 2  'for each col pair
                    .DATA.Cell(i , 0) = "Group " + STR$(i \ 2) 'Legend in 2nd Col (Y) of Pair, Row 0
                    FOR j = 1 TO .DATA.RowCount  'add data to each row
                        .DATA.Cell(i - 1 , j) = STR$(k * (RND - RND)) 'X Values in Col 1
                        .DATA.Cell(i , j) = STR$(k * (RND - RND)) 'Y Values in Col 2
                    NEXT j
                NEXT i
                .DrawChart(FALSE) 'Draw it!
            END WITH

        CASE "XY Lines"
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctXY  'XY Scatter Chart
                .ChartStyle = csLines  'Just the Lines
                .MainTitle.Text = "Two Sine Curves"  'change desired options
                .SubTitle.Text = "Out of Phase"
                .XTitle.Text = "Radians"
                .YTitle.Text = "Sine of X"
                .YAxis.Div = 6
                .XAxis.AutoScale = FALSE  'Manually Scale
                .XAxis.Max = 2  'Set Max Manually
                .XAxis.Min = 0  'Set Min Manually
                .YAxis.AutoScale = FALSE  'Manually Scale
                .YAxis.Max = 1.5  'Set Max Manually
                .YAxis.Min = - 1.5  'Set Min Manually
                .DATA.ColCount = 4  'Set .Data Grid dimensions
                .DATA.RowCount = 21  'Load the data
                FOR i = 2 TO .DATA.ColCount STEP 2  'for each col pair
                    .DATA.Cell(i , 0) = "Group " + STR$(i \ 2) 'Legend in 2nd Col of Pair, Row 0
                    .Series(i \ 2).LineStyle = (i \ 2 - 1) MOD 5  'Cycle line styles
                    FOR j = 1 TO .DATA.RowCount  'add data to each row
                        .DATA.Cell(i - 1 , j) = STR$((j - 1) / 10) 'X Values in 1st Col of Pair
                        k = ((j - 1) / 10 + [(i - 2) * 4.75]) * 3.141592
                        .DATA.Cell(i , j) = STR$(SIN(k)) 'Y Values in 2nd Col of Pair
                    NEXT j
                NEXT i
                .DrawChart(FALSE) 'Draw it!
            END WITH

        CASE "XY Both"
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctXY  'XY Scatter Chart
                .ChartStyle = csBoth  'Lines and Points
                .MarkerSize = 0
                .Series(1).LineWidth = 1
                .DATA.RowCount = 11
                .DATA.ColCount = 10  'Set .Data dimensions based on ClickedXY
                FOR j = 1 TO .DATA.RowCount  'add data to each row
                    .DATA.Cell(1 , j) = STR$(j) 'X Values in 1st Col of Pair
                    .DATA.Cell(2 , j) = STR$(j) 'Y Values in 2nd Col of Pair
                NEXT j
                FOR j = 1 TO .DATA.RowCount  'add data to each row
                    .DATA.Cell(3 , j) = STR$(j) 'X Values in 1st Col of Pair
                    .DATA.Cell(4 , j) = STR$(2 * j) 'Y Values in 2nd Col of Pair
                NEXT j
                FOR j = 1 TO .DATA.RowCount  'add data to each row
                    .DATA.Cell(5 , j) = STR$(j) 'X Values in 1st Col of Pair
                    .DATA.Cell(6 , j) = STR$(3 * j) 'Y Values in 2nd Col of Pair
                NEXT j
                FOR j = 1 TO .DATA.RowCount  'add data to each row
                    .DATA.Cell(7 , j) = STR$(j) 'X Values in 1st Col of Pair
                    .DATA.Cell(8 , j) = STR$(4 * j) 'Y Values in 2nd Col of Pair
                NEXT j
                FOR j = 1 TO .DATA.RowCount  'add data to each row
                    .DATA.Cell(9 , j) = STR$(j) 'X Values in 1st Col of Pair
                    .DATA.Cell(10 , j) = STR$(5 * j) 'Y Values in 2nd Col of Pair
                NEXT j

                .DrawChart(FALSE) 'Draw it!

            END WITH

        CASE "XY Logs"
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctXY  'XY Scatter Chart
                .ChartStyle = csBoth  'Points and Lines
                .MainTitle.Text = "Log - Log Scaling"  'change desired options
                .SubTitle.Text = "Grid with no Tics"
                .XTitle.Text = "X Axis"
                .YTitle.Text = "Y Axis"
                .YAxis.Tics = FALSE
                .YAxis.LogScale = TRUE
                .XAxis.Tics = FALSE
                .XAxis.LogScale = TRUE
                .DoLegend = FALSE
                .DATA.ColCount = 2  'Set .Data Grid dimensions
                .DATA.RowCount = 10
                RANDOMIZE  'Load the data
                FOR i = 2 TO .DATA.ColCount STEP 2  'for each col pair
                    .DATA.Cell(i , 0) = "Group " + STR$(i \ 2) 'Legend in 2nd Col of Pair, Row 0
                    FOR j = 1 TO .DATA.RowCount  'add data to each row
                        .DATA.Cell(i - 1 , j) = STR$(j) 'X Values in 1st Col of Pair
                        .DATA.Cell(i , j) = STR$(RND * 10^(j / 5)) 'Y Values in 2nd Col of Pair
                    NEXT j
                NEXT i
                .DrawChart(TRUE) 'Draw it!
            END WITH

        CASE "Line Graph"
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctLine  'Line Chart
                .ChartStyle = csLines  'Lines only
                .MainTitle.Text = "Simple Line Graph"  'change desired options
                .SubTitle.Text = "Five Available Line Styles"
                .XTitle.Text = "X Axis"
                .YTitle.Text = "Y Axis"
                .DATA.ColCount = 5  'Set .Data Grid dimensions
                .DATA.RowCount = 12
                k = 100  'Load the data
                RANDOMIZE
                FOR i = 1 TO .DATA.ColCount  'for each col
                    .Series(i).LineStyle = (i - 1) MOD 5  'Cycle line styles
                    .DATA.Cell(i , 0) = "Group " + STR$(i) 'Legend in Row 0 of Each Col
                    FOR j = 1 TO .DATA.RowCount  'add data to each row
                        .DATA.Cell(0 , j) = "Label " + STR$(j) 'X Labels
                        .DATA.Cell(i , j) = STR$(RND * k) 'Y Values
                    NEXT j
                NEXT i
                .DrawChart(FALSE) 'Draw it!
            END WITH

        CASE "Line w/Points"
            ClickedLine = ClickedLine + 1  'Change options on existing chart
            IF ClickedLine > 3 THEN ClickedLine = 1  'one by one
            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctLine  'Line Chart
                .ChartStyle = csBoth  'Points and Lines
                .MainTitle.Text = "Line Graph With Points"  'change desired options
                .SubTitle.Text = "Tics Only, Data Plotted in B&W, Custom Color Scheme"
                .XTitle.Text = "X Axis"
                .YTitle.Text = "Y Axis"
                IF ClickedLine = 2 THEN .YAxis.LogScale = TRUE
                IF ClickedLine = 3 THEN .ChartStyle = csPoints
                .BW = TRUE  'Data drawn in B&W
                .XAxis.Grid = FALSE  'Tics only
                .YAxis.Grid = FALSE
                .bgColor = .Colors(15) 'different colors
                .PlotAreaColor = .Colors(16)
                .MainFont.Color = .Colors(3)
                .SubFont.Color = .Colors(3)
                .AxisFont.Color = .Colors(7)
                .LegendFont.Color = .Colors(7)
                .Xaxis.Color = .Colors(7)
                .YAxis.Color = .Colors(7)
                .DATA.ColCount = 4  'Set .Data Grid dimensions
                .DATA.RowCount = 6
                k = 12  'Load the data
                RANDOMIZE
                FOR i = 1 TO .DATA.ColCount  'for each col
                    .DATA.Cell(i , 0) = "Group " + STR$(i) 'Legend in Row 0 of Each Col
                    FOR j = 1 TO .DATA.RowCount  'add data to each row
                        .DATA.Cell(0 , j) = "Lbl " + STR$(j) 'X Labels
                        .DATA.Cell(i , j) = STR$(RND * k) 'Y Values
                    NEXT j
                NEXT i
                .DrawChart(FALSE) 'Draw it!
            END WITH

            '-=============================== Case CandleSticks ==============================================-

        CASE "Candlesticks"                    

            frmmain.Caption = "QChartist - Please wait while loading chart..."
            Graph.Visible = 1
            split.Visible = 1
            splith.Visible = 1
            closedispchart.Visible = 1
            Scrollchart.Visible = 1
            pricescaleplusbtn.visible=1
            pricescaleminusbtn.visible=1
            addbarsbtn.visible=1
            shiftchartbtn.visible=1
            zoominchartbtn.visible=1
            zoomoutchartbtn.visible=1
            tfm1btn.visible=1
            tfm5btn.visible=1
            tfm15btn.visible=1
            tfm30btn.visible=1
            tfh1btn.visible=1
            tfh4btn.visible=1
            tfd1btn.visible=1
            tfw1btn.visible=1
            tfmnbtn.visible=1
            chartgridbtn.visible=1
            chartvolumesbtn.visible=1
            datawindowbtn.visible=1
            livebtn.visible=1
            refreshbtn.visible=1
            templateCoolBtn.visible=1
            arrowsbtn2.visible=1

            IF showcanvas = 1 THEN
                'visible switch from 0 to 1 is necessary because of a "bug"
                canvas.Visible = 0
                canvas.Visible = 1
                closedispcanvas.Visible = 1
            END IF

            WITH Graph
                .Initialize  'Set defaults
                .ChartType = ctBox  'Box and Whisker Plot
                .ChartStyle = csWhisker
                .MainFont.Name = "Arial"
                .MainFont.Size = 10
                .MainTitle.Text = "File: " + importedfile(displayedfile) 'change desired options
                .XTitle.Text = "Time"
                .YTitle.Text = "Price"

                SELECT CASE axistypecomboitemindex
                    CASE 0 :
                        .YAxis.LogScale = FALSE
                        .XAxis.LogScale = FALSE
                        .YAxis.FixedScale = FALSE                       

                    CASE 1 :
                        .YAxis.LogScale = TRUE
                        .XAxis.LogScale = FALSE
                        .YAxis.FixedScale = FALSE
                        
                    CASE 2 :
                        .YAxis.LogScale = FALSE
                        .XAxis.LogScale = FALSE
                        .YAxis.FixedScale = TRUE


                END SELECT

                .YAxis.AutoScale = FALSE
                .XAxis.Grid = drawxaxisgridcheckbox.checked
                .YAxis.Grid = drawyaxisgridcheckbox.checked
                .XAxis.AutoScale = FALSE
                .plotareacolor = plotareacolor


                .DoLegend = FALSE
                .DATA.ColCount = numbars
                .DATA.RowCount = 50

                .MarkerSize = 0
                .Series(1).LineWidth = 1

                IF scrollmode = 0 THEN
                    .Data_Indi.RowCount = numbars
                    .Data_Indi.ColCount = 2000
                    canvas.separateindicator1.RowCount = 100
                    canvas.separateindicator1.ColCount = numbars
                ELSE
                    .Data_Indi.RowCount = 1
                    .Data_Indi.ColCount = 1
                    canvas.separateindicator1.RowCount = 1
                    canvas.separateindicator1.ColCount = 1
                END IF

                DIM l AS INTEGER
                l = - 1

                IF chartstart > chartbars(displayedfile) - numbars THEN
                    chartstart = chartbars(displayedfile) - numbars
                END IF


                IF useindi.Checked = 1 THEN
                    IF scrollmode = 0 THEN
' ---------------------- Bugs ---------------------------
                        'REDIM Open(0 TO 0) AS DOUBLE
                        'REDIM high(0 TO 0) AS DOUBLE
                        'REDIM low(0 TO 0) AS DOUBLE
                        'REDIM Close(0 TO 0) AS DOUBLE
                        'REDIM volume(0 TO 0) AS DOUBLE
' --------------------------------------------------------
			'defdbl Open(0 TO 1000)
			'defdbl high(0 TO 1000)
			'defdbl low(0 TO 1000)
			'defdbl close(0 TO 1000)
			'defint volume(0 TO 1000)

                        'REDIM date(0 TO 0) AS STRING
                        'REDIM time(0 TO 0) AS STRING
                        'REDIM datetimeserial(0 TO 0) AS double
' ---------------------- Bugs ---------------------------
                        'REDIM Open(1 TO 1000) AS DOUBLE
                        'REDIM high(1 TO 1000) AS DOUBLE
                        'REDIM low(1 TO 1000) AS DOUBLE
                        'REDIM Close(1 TO 1000) AS DOUBLE
                        'REDIM volume(1 TO 1000) AS DOUBLE
' ----------------------------------------------------------                     
			'REDIM date(1 TO 1000) AS STRING
                        'REDIM time(1 TO 1000) AS STRING
                        'REDIM datetimeserial(1 TO 1000) AS double

                        DIM o AS INTEGER
                        o = 0
                        
                        dim year as integer,month as integer,day as integer, hour as integer,minute as integer,second as integer

                        defint ii2=chartbars(displayedfile) - VAL(cntbarsedit.Text)
                        if ii2<1 then ii2=1

                        cntbarseditstr=cntbarsedit.Text:cpptmpfuncreturn=varptr$(useindifunc(varptr(cntbarseditstr)))

                        FOR i = chartbars(displayedfile) TO ii2 STEP - 1
                            date(o) = Grid.Cell(rowgridoffset + 1 , i)
                            date2(o) = Grid.Cell(rowgridoffset + 1 , i)                                                       
                            time(o) = Grid.Cell(rowgridoffset + 2 , i)
                            Open(o) = VAL(Grid.Cell(rowgridoffset + 3 , i))
                            high(o) = VAL(Grid.Cell(rowgridoffset + 4 , i))
                            low(o) = VAL(Grid.Cell(rowgridoffset + 5 , i))
                            Close(o) = VAL(Grid.Cell(rowgridoffset + 6 , i))
                            volume(o) = VAL(Grid.Cell(rowgridoffset + 7 , i))
                            year = VAL(MID$(date(o) , 0 , 4))
                            month = VAL(MID$(date(o) , 6 , 2))
                            day = VAL(MID$(date(o) , 9 , 2))
                            hour = VAL(MID$(time(o) , 0 , 2))
                            minute = VAL(MID$(time(o) , 4 , 2))
                            second=0
                            parameters=str$(year)+";"+str$(month)+";"+str$(day)+";"+str$(hour)+";"+str$(minute)+";"+str$(second)
'showmessage "1"
                            datetimeserial(o)=val(varptr$(calculate_seconds_since_1_1_1970_cpp(varptr(parameters)))) 'DateSerial (year, month, day)
'showmessage "2"
                            'datetimeserial(o)=datetimeserial(o)*24*60*60
                            'datetimeserial(o)=datetimeserial(o)+(hour*60*60)
                            'datetimeserial(o)=datetimeserial(o)+(minute*60) 
                            o ++   
                            doevents                                                                                                                                         
                        NEXT i

                    END IF
                END IF    
         
                date(0) = Grid.Cell(rowgridoffset + 1 , chartbars(displayedfile)) ' Added this because of a bug
                date2(0) = Grid.Cell(rowgridoffset + 1 , chartbars(displayedfile)) ' Added this because of a bug                                                       
                time(0) = Grid.Cell(rowgridoffset + 2 , chartbars(displayedfile)) ' Added this because of a bug
                Open(0) = VAL(Grid.Cell(rowgridoffset + 3 , chartbars(displayedfile))) ' Added this because of a bug
                high(0) = VAL(Grid.Cell(rowgridoffset + 4 , chartbars(displayedfile))) ' Added this because of a bug
                low(0) = VAL(Grid.Cell(rowgridoffset + 5 , chartbars(displayedfile))) ' Added this because of a bug
                Close(0) = VAL(Grid.Cell(rowgridoffset + 6 , chartbars(displayedfile))) ' Added this because of a bug
                volume(0) = VAL(Grid.Cell(rowgridoffset + 7 , chartbars(displayedfile))) ' Added this because of a bug  
                year = VAL(MID$(date(0) , 0 , 4)) ' Added this because of a bug
                month = VAL(MID$(date(0) , 6 , 2)) ' Added this because of a bug
                day = VAL(MID$(date(0) , 9 , 2)) ' Added this because of a bug
                hour = VAL(MID$(time(0) , 0 , 2)) ' Added this because of a bug
                minute = VAL(MID$(time(0) , 4 , 2)) ' Added this because of a bug
                second=0 ' Added this because of a bug
                parameters=str$(year)+";"+str$(month)+";"+str$(day)+";"+str$(hour)+";"+str$(minute)+";"+str$(second) ' Added this because of a bug
                datetimeserial(0)=val(varptr$(calculate_seconds_since_1_1_1970_cpp(varptr(parameters)))) 'DateSerial (year, month, day) ' Added this because of a bug                                                                

                bars = chartbars(displayedfile)
                barsstr=str$(bars):cpptmpfuncreturn=varptr$(setbars(varptr(barsstr)))
                numbars_first=chartbars(displayedfile)-scrollchart.position+numbars-1
                numbars_last=chartbars(displayedfile)-scrollchart.position
                defstr numbars_firststr=str$(numbars_first):cpptmpfuncreturn=varptr$(setnumbars_first(varptr(numbars_firststr)))
                defstr numbars_laststr=str$(numbars_last):cpptmpfuncreturn=varptr$(setnumbars_last(varptr(numbars_laststr)))   
                
                maxvolume=0     
               
                FOR i = chartstart TO chartstart + .DATA.ColCount + val(generalsettingsfuturebarsedit.text)  'for each col
                    l ++

                    .Series(l).AutoColor = FALSE

                    IF Grid.Cell(rowgridoffset + 6 , i) > Grid.Cell(rowgridoffset + 3 , i) THEN
                        .Series(l).Color = bullcandlecolor '.Colors(1)
                    END IF
                    IF Grid.Cell(rowgridoffset + 6 , i) < Grid.Cell(rowgridoffset + 3 , i) THEN
                        .Series(l).Color = bearcandlecolor '.Colors(2)
                    END IF
                    IF Grid.Cell(rowgridoffset + 6 , i) = Grid.Cell(rowgridoffset + 3 , i) THEN
                        .Series(l).Color = black '.Colors(0)
                    END IF

                    .DATA.Cell(l , 0) = Grid.Cell(rowgridoffset + 1 , i) + " " + Grid.Cell(rowgridoffset + 2 , i) 'Legend in Row 0 of Each Col
                    .DATA.Cell(l , 1) = Grid.Cell(rowgridoffset + 4 , i)
                    .DATA.Cell(l , 2) = Grid.Cell(rowgridoffset + 6 , i)
                    .DATA.Cell(l , 3) = STR$(0)
                    .DATA.Cell(l , 4) = Grid.Cell(rowgridoffset + 3 , i)
                    .DATA.Cell(l , 5) = Grid.Cell(rowgridoffset + 5 , i)
                    
                    ' Calculates max volume if Volumes are activated
                    if chartvolumes=1 then
                            if val(Grid.Cell(rowgridoffset + 7 , i)) > maxvolume then maxvolume=val(Grid.Cell(rowgridoffset + 7 , i))
                    END IF
                    ' ----------------------------------------------                    

                    IF scrollmode = 0 THEN
                        '-================================= Indicators area ========================================-

                        DIM indicol AS INTEGER
                        indicol = 0
                        DIM barindex AS INTEGER
                        DIM barsback AS INTEGER
                        DIM period AS INTEGER
                        DIM ibar AS INTEGER
                        ibar = i
                        DIM lastbar AS INTEGER
                        lastbar = chartstart + .DATA.ColCount
                        DIM openx AS INTEGER
                        DIM highx AS INTEGER
                        DIM lowx AS INTEGER
                        DIM closex AS INTEGER
                        openx = rowgridoffset + 3
                        highx = rowgridoffset + 4
                        lowx = rowgridoffset + 5
                        closex = rowgridoffset + 6
                        DIM lbar AS INTEGER
                        lbar = ibar - chartstart
                        DIM offset AS INTEGER
                        dim bufnamestr as string
                        dim offsetstr as string
                        offset = chartbars(displayedfile) - ibar
                        offsetstr=str$(offset)
                        dim periodstr as string
			dim sourcestr as string
			dim methodstr as string
			dim shiftstr as string
            dim numbarsstr as string
                        dim barsbackstr as string
                        dim curtfstr as string
			dim tfbasestr as string
			dim atrmultstr as string
                        'IF useindi.Checked = 1 THEN
                            DIM lo AS INTEGER
                            'FOR lo = 1 TO .Data_Indi.RowCount STEP 2
                            '    .Data_Indi.Cell(lo , l) = STR$(l) 'Legend in Row 0 of Each Col
                            'NEXT lo
                            'FOR lo = 2 TO .Data_Indi.RowCount STEP 2
                            '    .Data_Indi.Cell(lo , l) = STR$(0)
                            'NEXT lo
                        'END IF

                        DIM drawid AS INTEGER
                        drawid = 2
                        DIM indiid AS INTEGER
                        indiid = - 1
                        DIM canvasid AS INTEGER

                        canvasid = 0

                          
'------------------------- ADR112 cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=ADR112cppperiodedit.text
tfbasestr=str$(ADR112cpptfbasecombo.itemindex)
cpptmpfuncreturn=varptr$(ADR112cpp(varptr(periodstr),varptr(tfbasestr)))
end if

barsback=700 '<--- can also be something like VAL(ADR112cppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="ADR112cppbuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="ADR112cppbuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=yellow '<--- replace with your color
    bufnamestr="ADR112cppbuffer3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=pink '<--- replace with your color
    bufnamestr="ADR112cppbuffer4"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="ADR112cppbuffer5"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End ADR112 cpp -------------------------------------------------
'------------------------- Anchored_VWAP -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
'periodstr=Anchored_VWAPperiodedit.text
'cpptmpfuncreturn=varptr$(Anchored_VWAP(varptr(periodstr)))

defstr vwapstartfromstr=Anchored_VWAPstartfromedit.text

defstr year2,month2,day2,hour2,minute2,second2
    year2=mid$(vwapstartfromstr,0,4)
    month2=mid$(vwapstartfromstr,6,2)
    day2=mid$(vwapstartfromstr,9,2)
    hour2=mid$(vwapstartfromstr,12,2)
    minute2=mid$(vwapstartfromstr,15,2)
    'second=mid$(cpptmpfuncreturn,18,2)
    second2="00"

    defstr parameters=year2+";"+month2+";"+day2+";"+hour2+";"+minute2+";"+second2
    defdbl inseconds=val(varptr$(calculate_seconds_since_1_1_1970_cpp(varptr(parameters))))
    defstr insecondsstr=str$(inseconds)

defstr vwapdevbandstr=Anchored_VWAPdeviationbandedit.text
if Anchored_VWAPautotf.checked=0 then curtfstr=Anchored_VWAPcurtfedit.text
if Anchored_VWAPautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Anchored_VWAP(varptr(insecondsstr),varptr(vwapdevbandstr),varptr(curtfstr)))
end if

barsback=bars '<--- can also be something like VAL(Anchored_VWAPbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=green '<--- replace with your color
    bufnamestr="Anchored_VWAPCustom"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="Anchored_VWAPUpperDev1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="Anchored_VWAPLowerDev1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Anchored_VWAP -------------------------------------------------
'--------ATR Channels-------------------------------------------------------------
indiid++
        
                    if indicatorslistsel.item(indiid)="x" then 

                        if lbar=1 then     
                            atrchannels
                        end if

                         barsback=200 
                    

                        if ibar>=lastbar-barsback then
            
                            indicolor(drawid)=olive
				.Data_Indi.Cell(drawid,lbar)= STR$(ch3up_buffer5(offset))
				drawid=drawid+2
                            indicolor(drawid)=olive
				.Data_Indi.Cell(drawid,lbar)= STR$(ch3dn_buffer6(offset))
				drawid=drawid+2
                                                                                
                        end if                      
                                             
                    end if
        
        '--------End ATR Channels----------------------------------------------------------        		
'------------------------- balance_point_fibo -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if balance_point_fiboautotf.checked=0 then curtfstr=balance_point_fibocurtfedit.text
if balance_point_fiboautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(balance_point_fibo(varptr(curtfstr)))
end if

barsback=200 '<--- can also be something like VAL(balance_point_fibobarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="dbp"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=red '<--- replace with your color
    bufnamestr="dbph"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=red '<--- replace with your color
    bufnamestr="dbpl"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End balance_point_fibo -------------------------------------------------
'--------Bollinger Bands-------------------------------------------------------------
indiid++
        
                    if indicatorslistsel.item(indiid)="x" then 

                        if lbar=1 then     
                            bands
                        end if

                         barsback=val(bandsbarsbackedit.text)
                    

                        if ibar>=lastbar-barsback then
            
                            indicolor(drawid)=mediumseagreen
				.Data_Indi.Cell(drawid,lbar)= STR$(bandsmovingbuffer(offset))
				drawid=drawid+2
                            indicolor(drawid)=mediumseagreen
				.Data_Indi.Cell(drawid,lbar)= STR$(bandsupperbuffer(offset))
				drawid=drawid+2
                            indicolor(drawid)=mediumseagreen                                                                    
                            .Data_Indi.Cell(drawid,lbar)= STR$(bandslowerbuffer(offset))          
				drawid=drawid+2
                        end if                      
                                             
                    end if
        
        '--------End Bollinger Bands----------------------------------------------------------                    
'------------------------- bandscpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=bandsbarsbackedit.text
defstr bandsperiodstr=bandscppperiodedit.text
defstr bandscppshiftstr=bandscppshiftedit.text
defstr bandscppdeviationsstr=bandscppdeviationsedit.text
if bandscppautotf.checked=0 then curtfstr=bandscppcurtfedit.text
if bandscppautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
parameters=barsbackstr+";"+bandsperiodstr+";"+bandscppshiftstr+";"+bandscppdeviationsstr+";"+curtfstr
cpptmpfuncreturn=varptr$(bandscpp(varptr(parameters)))
end if

barsback=VAL(bandscppbarsbackedit.text) '<--- can also be something like VAL(bandscppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=mediumseagreen '<--- replace with your color
    bufnamestr="bandsmovingbuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=mediumseagreen '<--- replace with your color
    bufnamestr="bandsupperbuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=mediumseagreen '<--- replace with your color
    bufnamestr="bandslowerbuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End bandscpp -------------------------------------------------
'--------BB - HL-------------------------------------------------------------
indiid++
        
                    if indicatorslistsel.item(indiid)="x" then 
            
                        if lbar=1 then     
                            bbhl                        
                        end if

                         barsback=VAL(bbhlbarsbackedit.text)                            

                        if ibar>=lastbar-barsback then
                            indicolor(drawid)=purple
                            .Data_Indi.Cell(drawid,lbar)= STR$(upperbandbuffer(offset))
				drawid=drawid+2
                            indicolor(drawid)=purple
                            .Data_Indi.Cell(drawid,lbar)= STR$(lowerbandbuffer(offset))
				drawid=drawid+2
            
                        end if                      
                     
                    end if			
        
        '--------End BB - HL----------------------------------------------------------       
'------------------------- BB - HL cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=bbhlcppperiodedit.text
barsbackstr=bbhlcppbarsbackedit.text
defstr ndevstr=bbhlcppndevedit.text
cpptmpfuncreturn=varptr$(bbhlcpp(varptr(periodstr),varptr(barsbackstr),varptr(ndevstr)))
end if

barsback=chartbars(displayedfile) '<--- can also be something like VAL(bbhlcppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=purple '<--- replace with your color
    bufnamestr="upperbandbuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=purple '<--- replace with your color
    bufnamestr="lowerbandbuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=purple '<--- replace with your color
    bufnamestr="mabuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End BB - HL cpp -------------------------------------------------
'------------------------- bowels -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=bowelsperiodedit.text
tfbasestr=str$(bowelstfbasecombo.itemindex)
cpptmpfuncreturn=varptr$(bowels(varptr(periodstr),varptr(tfbasestr)))
end if

barsback=200 '<--- can also be something like VAL(bowelsbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=purple '<--- replace with your color
    bufnamestr="pivot"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=red '<--- replace with your color
    bufnamestr="r1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=red '<--- replace with your color
    bufnamestr="r2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=red '<--- replace with your color
    bufnamestr="r3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=green '<--- replace with your color
    bufnamestr="s1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=green '<--- replace with your color
    bufnamestr="s2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=green '<--- replace with your color
    bufnamestr="s3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End bowels -------------------------------------------------
'--------Center Of Gravity-------------------------------------------------------------
indiid++
        
                    if indicatorslistsel.item(indiid)="x" then 

                        if lbar=1 then     
                            cog
                        end if

                         barsback=300 
                    
                        if ibar>=lastbar-barsback then
                            indicolor(drawid)=lightblue
				.Data_Indi.Cell(drawid,lbar)= STR$(fx(offset))
				drawid=drawid+2
                            indicolor(drawid)=red
				.Data_Indi.Cell(drawid,lbar)= STR$(sqh(offset))
				drawid=drawid+2
                            indicolor(drawid)=red
				.Data_Indi.Cell(drawid,lbar)= STR$(sql(offset))
				drawid=drawid+2
                            indicolor(drawid)=crimson
				.Data_Indi.Cell(drawid,lbar)= STR$(stdh(offset))
				drawid=drawid+2
                            indicolor(drawid)=crimson
				.Data_Indi.Cell(drawid,lbar)= STR$(stdl(offset))
				drawid=drawid+2
                                                                                                                                                                    
                        end if                                                          
         
                    end if
        
        '--------End Center Of Gravity----------------------------------------------------------   
'------------------------- COG of RSTL -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=rstlcogcppbarsbackedit.text
defstr kstdstr=kstdedit.text
cpptmpfuncreturn=varptr$(rstlcogcpp(varptr(barsbackstr),varptr(kstdstr)))
end if

barsback=300 '<--- can also be something like VAL(RSTLCOGbarsbackedit.text)

if ibar>=lastbar-barsback then
indicolor(drawid)=lightblue
    bufnamestr="fx2"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
                            indicolor(drawid)=yellow
                            bufnamestr="sqh2"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
                            indicolor(drawid)=yellow
                            bufnamestr="sql2"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
                            indicolor(drawid)=yellow
                            bufnamestr="stdh2"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
                            indicolor(drawid)=yellow
                            bufnamestr="stdl2"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
end if

end if
'------------------------- End COG of RSTL -------------------------------------------------
'------------------------- Center Of Gravity cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=cogcppbarsbackedit.text
cpptmpfuncreturn=varptr$(cogcpp(varptr(barsbackstr)))
end if

barsback=300 '<--- can also be something like VAL(cogcppbarsbackedit.text)

if ibar>=lastbar-barsback then    
    indicolor(drawid)=lightblue
    bufnamestr="fx"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
                            indicolor(drawid)=red
                            bufnamestr="sqh"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
                            indicolor(drawid)=red
                            bufnamestr="sql"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
                            indicolor(drawid)=crimson
                            bufnamestr="stdh"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
                            indicolor(drawid)=crimson
                            bufnamestr="stdl"
                .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
                drawid=drawid+2
end if

end if
'------------------------- End Center Of Gravity cpp -------------------------------------------------
'------------------------- Din fibo high cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=Din_fibo_highperiodedit.text
if Din_fibo_highautotf.checked=0 then curtfstr=Din_fibo_highcurtfedit.text
if Din_fibo_highautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(dinfibohighcpp(varptr(curtfstr)))
end if

barsback=200 '<--- can also be something like VAL(Din_fibo_highbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="dinfibohighbuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=yellow '<--- replace with your color
    bufnamestr="dinfibohighbuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Din fibo high cpp -------------------------------------------------
'------------------------- Elliot_Wave_3_Level_ZZ_Semafor -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if Elliot_Wave_3_Level_ZZ_Semaforautotf.checked=0 then curtfstr=Elliot_Wave_3_Level_ZZ_Semaforcurtfedit.text
if Elliot_Wave_3_Level_ZZ_Semaforautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Elliot_Wave_3_Level_ZZ_Semafor(varptr(curtfstr)))
defint delalli,delallj
	FOR delallj=1 to 10
	    FOR delalli = 1 TO 1000 - 1
                    if textlabelsdb.Cell(5 , delalli) = "elliot wave" then			
			textlabelsdb.deleterow(delalli)
			textlabelsoffset--
			if textlabelsoffset<0 then textlabelsoffset=0
		    end if
            NEXT delalli
	textlabelsdb.RowCount = 100
	next delallj
defstr year0,month0,day0,hours0,minutes0,$mydate0
end if

barsback=numbars '<--- can also be something like VAL(Elliot_Wave_3_Level_ZZ_Semaforbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=chocolate '<--- replace with your color
    bufnamestr="FP_BuferUp"
    '.Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
if val(varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr))))>0 then
year0=mid$(date(offset),1,4)
month0=mid$(date(offset),6,2)
day0=mid$(date(offset),9,2)
hours0=mid$(time(offset),1,2)
minutes0=mid$(time(offset),4,2) 
$mydate0=year0+";"+month0+";"+day0+";"+hours0+";"+minutes0+";"+"00"
cpptmpfuncreturn=varptr$(date_to_unix_time(varptr($mydate0)))
textlabelsoffset++
textlabelsdb.Cell(1 , textlabelsoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
textlabelsdb.Cell(2 , textlabelsoffset) = cpptmpfuncreturn
textlabelsdb.Cell(3 , textlabelsoffset) = "1"
textlabelsdb.Cell(4 , textlabelsoffset) = str$(white)
textlabelsdb.Cell(5 , textlabelsoffset) = "elliot wave"
textlabelsdb.Cell(6 , textlabelsoffset) = str$(chocolate)
end if
    drawid=drawid+2
    
indicolor(drawid)=chocolate '<--- replace with your color
    bufnamestr="FP_BuferDn"
    '.Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
if val(varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr))))>0 then
year0=mid$(date(offset),1,4)
month0=mid$(date(offset),6,2)
day0=mid$(date(offset),9,2)
hours0=mid$(time(offset),1,2)
minutes0=mid$(time(offset),4,2) 
$mydate0=year0+";"+month0+";"+day0+";"+hours0+";"+minutes0+";"+"00"
cpptmpfuncreturn=varptr$(date_to_unix_time(varptr($mydate0)))
textlabelsoffset++
textlabelsdb.Cell(1 , textlabelsoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
textlabelsdb.Cell(2 , textlabelsoffset) = cpptmpfuncreturn
textlabelsdb.Cell(3 , textlabelsoffset) = "1"
textlabelsdb.Cell(4 , textlabelsoffset) = str$(white)
textlabelsdb.Cell(5 , textlabelsoffset) = "elliot wave"
textlabelsdb.Cell(6 , textlabelsoffset) = str$(chocolate)
end if
    drawid=drawid+2

indicolor(drawid)=mediumvioletred '<--- replace with your color
    bufnamestr="NP_BuferUp"
    '.Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
if val(varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr))))>0 then
year0=mid$(date(offset),1,4)
month0=mid$(date(offset),6,2)
day0=mid$(date(offset),9,2)
hours0=mid$(time(offset),1,2)
minutes0=mid$(time(offset),4,2) 
$mydate0=year0+";"+month0+";"+day0+";"+hours0+";"+minutes0+";"+"00"
cpptmpfuncreturn=varptr$(date_to_unix_time(varptr($mydate0)))
textlabelsoffset++
textlabelsdb.Cell(1 , textlabelsoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
textlabelsdb.Cell(2 , textlabelsoffset) = cpptmpfuncreturn
textlabelsdb.Cell(3 , textlabelsoffset) = "2"
textlabelsdb.Cell(4 , textlabelsoffset) = str$(white)
textlabelsdb.Cell(5 , textlabelsoffset) = "elliot wave"
textlabelsdb.Cell(6 , textlabelsoffset) = str$(mediumvioletred)
if val(textlabelsdb.Cell(1 , textlabelsoffset-1))=val(textlabelsdb.Cell(1 , textlabelsoffset)) and _
val(textlabelsdb.Cell(2 , textlabelsoffset-1))=val(textlabelsdb.Cell(2 , textlabelsoffset)) and _
textlabelsdb.Cell(5 , textlabelsoffset-1)=textlabelsdb.Cell(5 , textlabelsoffset) then
textlabelsdb.deleterow(textlabelsoffset-1)
textlabelsoffset--
end if
end if
    drawid=drawid+2

indicolor(drawid)=mediumvioletred '<--- replace with your color
    bufnamestr="NP_BuferDn"
    '.Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
if val(varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr))))>0 then
year0=mid$(date(offset),1,4)
month0=mid$(date(offset),6,2)
day0=mid$(date(offset),9,2)
hours0=mid$(time(offset),1,2)
minutes0=mid$(time(offset),4,2) 
$mydate0=year0+";"+month0+";"+day0+";"+hours0+";"+minutes0+";"+"00"
cpptmpfuncreturn=varptr$(date_to_unix_time(varptr($mydate0)))
textlabelsoffset++
textlabelsdb.Cell(1 , textlabelsoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
textlabelsdb.Cell(2 , textlabelsoffset) = cpptmpfuncreturn
textlabelsdb.Cell(3 , textlabelsoffset) = "2"
textlabelsdb.Cell(4 , textlabelsoffset) = str$(white)
textlabelsdb.Cell(5 , textlabelsoffset) = "elliot wave"
textlabelsdb.Cell(6 , textlabelsoffset) = str$(mediumvioletred)
if val(textlabelsdb.Cell(1 , textlabelsoffset-1))=val(textlabelsdb.Cell(1 , textlabelsoffset)) and _
val(textlabelsdb.Cell(2 , textlabelsoffset-1))=val(textlabelsdb.Cell(2 , textlabelsoffset)) and _
textlabelsdb.Cell(5 , textlabelsoffset-1)=textlabelsdb.Cell(5 , textlabelsoffset) then
textlabelsdb.deleterow(textlabelsoffset-1)
textlabelsoffset--
end if
end if
    drawid=drawid+2

indicolor(drawid)=yellow '<--- replace with your color
    bufnamestr="HP_BuferUp"
    '.Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
if val(varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr))))>0 then
year0=mid$(date(offset),1,4)
month0=mid$(date(offset),6,2)
day0=mid$(date(offset),9,2)
hours0=mid$(time(offset),1,2)
minutes0=mid$(time(offset),4,2) 
$mydate0=year0+";"+month0+";"+day0+";"+hours0+";"+minutes0+";"+"00"
cpptmpfuncreturn=varptr$(date_to_unix_time(varptr($mydate0)))
textlabelsoffset++
textlabelsdb.Cell(1 , textlabelsoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
textlabelsdb.Cell(2 , textlabelsoffset) = cpptmpfuncreturn
textlabelsdb.Cell(3 , textlabelsoffset) = "3"
textlabelsdb.Cell(4 , textlabelsoffset) = str$(black)
textlabelsdb.Cell(5 , textlabelsoffset) = "elliot wave"
textlabelsdb.Cell(6 , textlabelsoffset) = str$(yellow)
if val(textlabelsdb.Cell(1 , textlabelsoffset-1))=val(textlabelsdb.Cell(1 , textlabelsoffset)) and _
val(textlabelsdb.Cell(2 , textlabelsoffset-1))=val(textlabelsdb.Cell(2 , textlabelsoffset)) and _
textlabelsdb.Cell(5 , textlabelsoffset-1)=textlabelsdb.Cell(5 , textlabelsoffset) then
textlabelsdb.deleterow(textlabelsoffset-1)
textlabelsoffset--
end if
end if
    drawid=drawid+2

indicolor(drawid)=yellow '<--- replace with your color
    bufnamestr="HP_BuferDn"
    '.Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
if val(varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr))))>0 then
year0=mid$(date(offset),1,4)
month0=mid$(date(offset),6,2)
day0=mid$(date(offset),9,2)
hours0=mid$(time(offset),1,2)
minutes0=mid$(time(offset),4,2) 
$mydate0=year0+";"+month0+";"+day0+";"+hours0+";"+minutes0+";"+"00"
cpptmpfuncreturn=varptr$(date_to_unix_time(varptr($mydate0)))
textlabelsoffset++
textlabelsdb.Cell(1 , textlabelsoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
textlabelsdb.Cell(2 , textlabelsoffset) = cpptmpfuncreturn
textlabelsdb.Cell(3 , textlabelsoffset) = "3"
textlabelsdb.Cell(4 , textlabelsoffset) = str$(black)
textlabelsdb.Cell(5 , textlabelsoffset) = "elliot wave"
textlabelsdb.Cell(6 , textlabelsoffset) = str$(yellow)
if val(textlabelsdb.Cell(1 , textlabelsoffset-1))=val(textlabelsdb.Cell(1 , textlabelsoffset)) and _
val(textlabelsdb.Cell(2 , textlabelsoffset-1))=val(textlabelsdb.Cell(2 , textlabelsoffset)) and _
textlabelsdb.Cell(5 , textlabelsoffset-1)=textlabelsdb.Cell(5 , textlabelsoffset) then
textlabelsdb.deleterow(textlabelsoffset-1)
textlabelsoffset--
end if
end if
    drawid=drawid+2

end if

end if
'------------------------- End Elliot_Wave_3_Level_ZZ_Semafor -------------------------------------------------
'------------------------- Enveloppes -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
envelop
end if

barsback=200 '<--- can also be something like VAL(envelopbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=green '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(ci(offset))
    drawid=drawid+2
	indicolor(drawid)=red '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(UperBuffer (offset))
    drawid=drawid+2
	indicolor(drawid)=red '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(DownBuffer (offset))
    drawid=drawid+2
end if

end if
'------------------------- End Enveloppes -------------------------------------------------
'------------------------- Envelopes_cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=Envelopes_cppbarsbackedit.text
periodstr=Envelopes_cppmaperiodedit.text
sourcestr=Envelopes_cppappliedpriceedit.text
methodstr=Envelopes_cppmamethodedit.text
shiftstr=Envelopes_cppmashiftedit.text
defstr deviationstr=Envelopes_cppdeviationedit.text
'cpptmpfuncreturn=varptr$(Moving_Average(varptr(periodstr)))
if Envelopes_cppautotf.checked=0 then curtfstr=Envelopes_cppcurtfedit.text
if Envelopes_cppautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
parameters=barsbackstr+";"+periodstr+";"+sourcestr+";"+methodstr+";"+shiftstr+";"+curtfstr+";"+deviationstr
cpptmpfuncreturn=varptr$(Envelopes_cpp(varptr(parameters)))
end if

barsback=VAL(Envelopes_cppbarsbackedit.text) '<--- can also be something like VAL(Envelopes_cppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Envelopes_cppbuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="Envelopes_cppbuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Envelopes_cpp -------------------------------------------------
'------------------------- Hurst_FLD -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=Hurst_FLDbarsbackedit.text
periodstr=Hurst_FLDperiodedit.text
sourcestr=str$(Hurst_FLDsourcecombo.itemindex)
'cpptmpfuncreturn=varptr$(Hurst_FLD(varptr(periodstr)))
if Hurst_FLDautotf.checked=0 then curtfstr=Hurst_FLDcurtfedit.text
if Hurst_FLDautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Hurst_FLD(varptr(barsbackstr),varptr(periodstr),varptr(sourcestr),varptr(curtfstr)))
end if

barsback=VAL(Hurst_FLDbarsbackedit.text) '<--- can also be something like VAL(Hurst_FLDbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Hurst_FLDbuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Hurst_FLD -------------------------------------------------
'------------------------- Ichimoku -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
defstr tenkanstr=Ichimokutenkanedit.text
defstr kijunstr=Ichimokukijunedit.text
defstr senkoustr=Ichimokusenkouedit.text
cpptmpfuncreturn=varptr$(Ichimoku(varptr(tenkanstr),varptr(kijunstr),varptr(senkoustr)))
end if

barsback=numbars '<--- can also be something like VAL(Ichimokubarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="Tenkan_Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Kijun_Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="SpanA_Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=gray '<--- replace with your color
    bufnamestr="SpanB_Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=green '<--- replace with your color
    bufnamestr="Chinkou_Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="SpanA2_Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=gray '<--- replace with your color
    bufnamestr="SpanB2_Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

'defstr myyear0,mymonth0,myday0,myhours0,myminutes0,$mymydate0
'myyear0=mid$(date(offset),1,4)
'mymonth0=mid$(date(offset),6,2)
'myday0=mid$(date(offset),9,2)
'myhours0=mid$(time(offset),1,2)
'myminutes0=mid$(time(offset),4,2) 
'$mymydate0=myyear0+";"+mymonth0+";"+myday0+";"+myhours0+";"+myminutes0+";"+"00"

'cpptmpfuncreturn=varptr$(date_to_unix_time(varptr($mymydate0)))
'fillregionoffset++
'bufnamestr="SpanA_Buffer"
'fillregiondb.Cell(1 , fillregionoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
'bufnamestr="SpanB_Buffer"
'fillregiondb.Cell(2 , fillregionoffset) = cpptmpfuncreturn
'fillregiondb.Cell(3 , fillregionoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
'fillregiondb.Cell(4 , fillregionoffset) = cpptmpfuncreturn
'fillregiondb.Cell(5 , fillregionoffset) = str$(chocolate)
'fillregiondb.Cell(6 , fillregionoffset) = "0"

end if

end if
'------------------------- End Ichimoku -------------------------------------------------
'------------------------- Jupiter - Saturn cycle -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
jupiter_saturn_cycle
end if

barsback=numbars '<--- can also be something like VAL(jupiter_saturn_cyclebarsbackedit.text)

if ibar>=lastbar-barsback then
defint incrj
for incrj=0 to 12
    indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(jupiter_saturn_cyclebuffer(incrj,offset))
    drawid=drawid+2
next incrj
end if

end if
'------------------------- End Jupiter - Saturn cycle -------------------------------------------------
'------------------------- Levels -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=Levelsperiodedit.text
cpptmpfuncreturn=varptr$(Levels(varptr(periodstr)))
end if

barsback=200 '<--- can also be something like VAL(Levelsbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="sopr1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="sopr2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="sopr3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="sopr4"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="sopr5"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="pod1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="pod2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="pod3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="pod4"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="pod5"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Levels -------------------------------------------------
'------------------------- Logarithmic Regression -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=Logarithmic_Regressionperiodedit.text
'cpptmpfuncreturn=varptr$(Logarithmic_Regression(varptr(periodstr)))
if Logarithmic_Regressionautotf.checked=0 then curtfstr=Logarithmic_Regressioncurtfedit.text
if Logarithmic_Regressionautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Logarithmic_Regression(varptr(periodstr),varptr(curtfstr)))

end if

barsback=bars '<--- can also be something like VAL(Logarithmic_Regressionbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="Middle"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    
        indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Upper"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    
        indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Lower"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Upper2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    
        indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Lower2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Upper3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    
        indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Lower3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Logarithmic Regression -------------------------------------------------

                   '--------Moving Average-------------------------------------------------------------
indiid++
        
                    if indicatorslistsel.item(indiid)="x" then 
            
                        if lbar=1 then     
      
                            sma(0)                        
                        end if

                        barsback=VAL(mabarsbackedit.text)                        

                        if ibar>=lastbar-barsback then
                           indicolor(drawid)=blue
                           .Data_Indi.Cell(drawid,lbar)= STR$(extmapbuffer(offset))
            			drawid=drawid+2
                       end if                      
                     
                    end if			
        
        '--------End Moving Average----------------------------------------------------------     
'------------------------- MA_Chanels_cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=MA_Chanels_cppperiodedit.text
if MA_Chanels_cppautotf.checked=0 then curtfstr=MA_Chanels_cppcurtfedit.text
if MA_Chanels_cppautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(MA_Chanels_cpp(varptr(periodstr),varptr(curtfstr)))
end if

barsback=bars '<--- can also be something like VAL(MA_Chanels_cppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=Red '<--- replace with your color
    bufnamestr="MA_Chanels_cppbuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=Orange '<--- replace with your color
    bufnamestr="MA_Chanels_cppbuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=Yellow '<--- replace with your color
    bufnamestr="MA_Chanels_cppbuffer3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=White '<--- replace with your color
    bufnamestr="MA_Chanels_cppbuffer4"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=White '<--- replace with your color
    bufnamestr="MA_Chanels_cppbuffer5"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=Yellow '<--- replace with your color
    bufnamestr="MA_Chanels_cppbuffer6"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=Orange '<--- replace with your color
    bufnamestr="MA_Chanels_cppbuffer7"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=Red '<--- replace with your color
    bufnamestr="MA_Chanels_cppbuffer8"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End MA_Chanels_cpp -------------------------------------------------
'------------------------- MA Chanels FiboEnv Mid -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=MA_Chanels_FiboEnv_Midperiodedit.text
if MA_Chanels_FiboEnv_Midautotf.checked=0 then curtfstr=MA_Chanels_FiboEnv_Midcurtfedit.text
if MA_Chanels_FiboEnv_Midautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(MA_Chanels_FiboEnv_Mid(varptr(periodstr),varptr(curtfstr)))
end if

barsback=bars '<--- can also be something like VAL(MA_Chanels_FiboEnv_Midbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=mediumorchid '<--- replace with your color
    bufnamestr="MA_Chanels_FiboEnv_Midbuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=violet '<--- replace with your color
    bufnamestr="MA_Chanels_FiboEnv_Midbuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=mediumorchid '<--- replace with your color
    bufnamestr="MA_Chanels_FiboEnv_Midbuffer3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=violet '<--- replace with your color
    bufnamestr="MA_Chanels_FiboEnv_Midbuffer4"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=mediumorchid '<--- replace with your color
    bufnamestr="MA_Chanels_FiboEnv_Midbuffer5"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=violet '<--- replace with your color
    bufnamestr="MA_Chanels_FiboEnv_Midbuffer6"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=mediumorchid '<--- replace with your color
    bufnamestr="MA_Chanels_FiboEnv_Midbuffer7"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End MA Chanels FiboEnv Mid -------------------------------------------------
'------------------------- MonthlyPivot2 -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=MonthlyPivot2barsbackedit.text
if MonthlyPivot2autotf.checked=0 then curtfstr=MonthlyPivot2curtfedit.text
if MonthlyPivot2autotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(MonthlyPivot2(varptr(barsbackstr),varptr(curtfstr)))
end if

barsback=bars '<--- can also be something like VAL(MonthlyPivot2barsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=Orange '<--- replace with your color
    bufnamestr="MPBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=DarkBlue '<--- replace with your color
    bufnamestr="MS1Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=Maroon '<--- replace with your color
    bufnamestr="MR1Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=DarkBlue '<--- replace with your color
    bufnamestr="MS2Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=Maroon '<--- replace with your color
    bufnamestr="MR2Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=Green '<--- replace with your color
    bufnamestr="MS3Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=Green '<--- replace with your color
    bufnamestr="MR3Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End MonthlyPivot2 -------------------------------------------------
'------------------------- monthlypivotcpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=monthlypivotcppbarsbackedit.text
if monthlypivotcppautotf.checked=0 then curtfstr=monthlypivotcppcurtfedit.text
if monthlypivotcppautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(monthlypivotcpp(varptr(barsbackstr),varptr(curtfstr)))
end if

barsback=bars '<--- can also be something like VAL(monthlypivotcppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=magenta '<--- replace with your color
    bufnamestr="PmBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=royalblue '<--- replace with your color
    bufnamestr="S1mBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=crimson '<--- replace with your color
    bufnamestr="R1mBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=royalblue '<--- replace with your color
    bufnamestr="S2mBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=crimson '<--- replace with your color
    bufnamestr="R2mBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=seagreen '<--- replace with your color
    bufnamestr="S3mBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=seagreen '<--- replace with your color
    bufnamestr="R3mBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End monthlypivotcpp -------------------------------------------------
'------------------------- Moving Average -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=Moving_Averagebarsbackedit.text
periodstr=Moving_Averageperiodedit.text
sourcestr=str$(Moving_Averageapplytocombo.itemindex)
methodstr=str$(Moving_Averagemethodcombo.itemindex)
shiftstr=Moving_Averageshiftedit.text
'cpptmpfuncreturn=varptr$(Moving_Average(varptr(periodstr)))
if Moving_Averageautotf.checked=0 then curtfstr=Moving_Averagecurtfedit.text
if Moving_Averageautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
parameters=barsbackstr+";"+periodstr+";"+sourcestr+";"+methodstr+";"+shiftstr+";"+curtfstr
cpptmpfuncreturn=varptr$(Moving_Average(varptr(parameters)))
end if

barsback=VAL(Moving_Averagebarsbackedit.text) '<--- can also be something like VAL(Moving_Averagebarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="Moving_Averagebuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Moving Average -------------------------------------------------
'------------------------- Moon_Phases_on_chart -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
MP_on_chart
end if

barsback=numbars '<--- can also be something like VAL(MP_on_chartbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(MP_on_chartbuffer(offset))
    drawid=drawid+2
end if

end if
'------------------------- End Moon_Phases_on_chart -------------------------------------------------
'------------------------- Murrey_Math -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=Murrey_Mathbarsbackedit.text
defstr Pstr=Murrey_MathPedit.text
cpptmpfuncreturn=varptr$(Murrey_Math(varptr(barsbackstr),varptr(Pstr)))
end if

barsback=val(barsbackstr) '<--- can also be something like VAL(Murrey_Mathbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=yellow '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer4"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=pink '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer5"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=green '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer6"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer7"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=green '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer8"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=pink '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer9"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=yellow '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer10"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer11"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer12"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

indicolor(drawid)=red '<--- replace with your color
    bufnamestr="Murrey_Mathbuffer13"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Murrey_Math -------------------------------------------------
'------------------------- Overlay_Chart -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
Overlay_Chart
end if

barsback=bars '<--- can also be something like VAL(Overlay_Chartbarsbackedit.text)

if ibar>=lastbar-barsback then 
	
	defint incrov
    
    if overlaychartslist.itemcount>0 then

	if charttf(displayedfile)<=240 then
	indicolor(drawid)=blue '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(0)/7+1)		
	if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(0) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") and Grid.Cell(Overlay_Chartbuffer(0) + 2 , incrov)=Grid.Cell(rowgridoffset + 2 , ibar) then    	
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(0) + 6 , incrov))*val(overlaychartsratiolist.item(0)))
	exit for
	'else
	'.Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if
	
	if charttf(displayedfile)=1440 then
	indicolor(drawid)=blue '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(0)/7+1)	
	if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(0) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then    	
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(0) + 6 , incrov))*val(overlaychartsratiolist.item(0)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if

	if charttf(displayedfile)=10080 then
	indicolor(drawid)=blue '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(0)/7+1)

defstr yearov=mid$(Grid.Cell(Overlay_Chartbuffer(0) + 1 , incrov),1,4)
defstr monthov=mid$(Grid.Cell(Overlay_Chartbuffer(0) + 1 , incrov),6,2)
defstr dayov=mid$(Grid.Cell(Overlay_Chartbuffer(0) + 1 , incrov),9,2)
defstr dateov=yearov+";"+monthov+";"+dayov+";"+"00"+";"+"00"+";"+"00"
defstr unixtimeov=varptr$(date_to_unix_time(varptr(dateov)))

defstr year00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),1,4)
defstr month00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),6,2)
defstr day00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),9,2)
defstr date00=year00+";"+month00+";"+day00+";"+"00"+";"+"00"+";"+"00"
defstr unixtime00=varptr$(date_to_unix_time(varptr(date00)))

	'if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(0) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then    	
if val(unixtimeov)>=val(unixtime00)-(1440*60*3) and val(unixtimeov)<val(unixtime00)+(1440*60*3) then
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(0) + 6 , incrov))*val(overlaychartsratiolist.item(0)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if

	if charttf(displayedfile)=43200 then
	indicolor(drawid)=blue '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(0)/7+1)	
	if MID$(replacesubstr$(Grid.Cell(Overlay_Chartbuffer(0) + 1 , incrov),"-",".") , 1 , 7)=MID$(replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") , 1 , 7) then    	
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(0) + 6 , incrov))*val(overlaychartsratiolist.item(0)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if

    drawid=drawid+2
    
    end if
    
    if overlaychartslist.itemcount>1 then
    
    if charttf(displayedfile)<=240 then
    indicolor(drawid)=green '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(1)/7+1)       
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(1) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") and Grid.Cell(Overlay_Chartbuffer(1) + 2 , incrov)=Grid.Cell(rowgridoffset + 2 , ibar) then       
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(1) + 6 , incrov))*val(overlaychartsratiolist.item(1)))
    exit for
    'else
    '.Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if
    
    if charttf(displayedfile)=1440 then
    indicolor(drawid)=green '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(1)/7+1)   
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(1) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(1) + 6 , incrov))*val(overlaychartsratiolist.item(1)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

if charttf(displayedfile)=10080 then
	indicolor(drawid)=green '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(1)/7+1)

 yearov=mid$(Grid.Cell(Overlay_Chartbuffer(1) + 1 , incrov),1,4)
 monthov=mid$(Grid.Cell(Overlay_Chartbuffer(1) + 1 , incrov),6,2)
 dayov=mid$(Grid.Cell(Overlay_Chartbuffer(1) + 1 , incrov),9,2)
 dateov=yearov+";"+monthov+";"+dayov+";"+"00"+";"+"00"+";"+"00"
 unixtimeov=varptr$(date_to_unix_time(varptr(dateov)))

 year00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),1,4)
 month00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),6,2)
 day00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),9,2)
 date00=year00+";"+month00+";"+day00+";"+"00"+";"+"00"+";"+"00"
 unixtime00=varptr$(date_to_unix_time(varptr(date00)))

	'if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(1) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then    	
if val(unixtimeov)>=val(unixtime00)-(1440*60*3) and val(unixtimeov)<val(unixtime00)+(1440*60*3) then
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(1) + 6 , incrov))*val(overlaychartsratiolist.item(1)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if

    if charttf(displayedfile)=43200 then
	indicolor(drawid)=green '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(1)/7+1)	
	if MID$(replacesubstr$(Grid.Cell(Overlay_Chartbuffer(1) + 1 , incrov),"-",".") , 1 , 7)=MID$(replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") , 1 , 7) then    	
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(1) + 6 , incrov))*val(overlaychartsratiolist.item(1)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if

    drawid=drawid+2
    
    end if
    
    if overlaychartslist.itemcount>2 then
    
    if charttf(displayedfile)<=240 then
    indicolor(drawid)=red '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(2)/7+1)       
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(2) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") and Grid.Cell(Overlay_Chartbuffer(2) + 2 , incrov)=Grid.Cell(rowgridoffset + 2 , ibar) then       
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(2) + 6 , incrov))*val(overlaychartsratiolist.item(2)))
    exit for
    'else
    '.Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if
    
    if charttf(displayedfile)=1440 then
    indicolor(drawid)=red '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(2)/7+1)   
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(2) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(2) + 6 , incrov))*val(overlaychartsratiolist.item(2)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

    if charttf(displayedfile)=10080 then
	indicolor(drawid)=red '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(2)/7+1)

 yearov=mid$(Grid.Cell(Overlay_Chartbuffer(2) + 1 , incrov),1,4)
 monthov=mid$(Grid.Cell(Overlay_Chartbuffer(2) + 1 , incrov),6,2)
 dayov=mid$(Grid.Cell(Overlay_Chartbuffer(2) + 1 , incrov),9,2)
 dateov=yearov+";"+monthov+";"+dayov+";"+"00"+";"+"00"+";"+"00"
 unixtimeov=varptr$(date_to_unix_time(varptr(dateov)))

 year00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),1,4)
 month00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),6,2)
 day00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),9,2)
 date00=year00+";"+month00+";"+day00+";"+"00"+";"+"00"+";"+"00"
 unixtime00=varptr$(date_to_unix_time(varptr(date00)))

	'if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(2) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then    	
if val(unixtimeov)>=val(unixtime00)-(1440*60*3) and val(unixtimeov)<val(unixtime00)+(1440*60*3) then
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(2) + 6 , incrov))*val(overlaychartsratiolist.item(2)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if
    
    if charttf(displayedfile)=43200 then
    indicolor(drawid)=red '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(2)/7+1)   
    if MID$(replacesubstr$(Grid.Cell(Overlay_Chartbuffer(2) + 1 , incrov),"-",".") , 1 , 7)=MID$(replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") , 1 , 7) then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(2) + 6 , incrov))*val(overlaychartsratiolist.item(2)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

drawid=drawid+2    

    end if
    
    if overlaychartslist.itemcount>3 then
    
    if charttf(displayedfile)<=240 then
    indicolor(drawid)=brown '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(3)/7+1)       
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(3) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") and Grid.Cell(Overlay_Chartbuffer(3) + 2 , incrov)=Grid.Cell(rowgridoffset + 2 , ibar) then       
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(3) + 6 , incrov))*val(overlaychartsratiolist.item(3)))
    exit for
    'else
    '.Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if
    
    if charttf(displayedfile)=1440 then
    indicolor(drawid)=brown '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(3)/7+1)   
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(3) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(3) + 6 , incrov))*val(overlaychartsratiolist.item(3)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

if charttf(displayedfile)=10080 then
	indicolor(drawid)=brown '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(3)/7+1)

 yearov=mid$(Grid.Cell(Overlay_Chartbuffer(3) + 1 , incrov),1,4)
 monthov=mid$(Grid.Cell(Overlay_Chartbuffer(3) + 1 , incrov),6,2)
 dayov=mid$(Grid.Cell(Overlay_Chartbuffer(3) + 1 , incrov),9,2)
 dateov=yearov+";"+monthov+";"+dayov+";"+"00"+";"+"00"+";"+"00"
 unixtimeov=varptr$(date_to_unix_time(varptr(dateov)))

 year00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),1,4)
 month00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),6,2)
 day00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),9,2)
 date00=year00+";"+month00+";"+day00+";"+"00"+";"+"00"+";"+"00"
 unixtime00=varptr$(date_to_unix_time(varptr(date00)))

	'if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(3) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then    	
if val(unixtimeov)>=val(unixtime00)-(1440*60*3) and val(unixtimeov)<val(unixtime00)+(1440*60*3) then
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(3) + 6 , incrov))*val(overlaychartsratiolist.item(3)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if
    
    if charttf(displayedfile)=43200 then
    indicolor(drawid)=brown '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(3)/7+1)   
    if MID$(replacesubstr$(Grid.Cell(Overlay_Chartbuffer(3) + 1 , incrov),"-",".") , 1 , 7)=MID$(replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") , 1 , 7) then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(3) + 6 , incrov))*val(overlaychartsratiolist.item(3)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

    drawid=drawid+2
    
    end if
    
    if overlaychartslist.itemcount>4 then
    
    if charttf(displayedfile)<=240 then
    indicolor(drawid)=yellow '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(4)/7+1)       
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(4) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") and Grid.Cell(Overlay_Chartbuffer(4) + 2 , incrov)=Grid.Cell(rowgridoffset + 2 , ibar) then       
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(4) + 6 , incrov))*val(overlaychartsratiolist.item(4)))
    exit for
    'else
    '.Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if
    
    if charttf(displayedfile)=1440 then
    indicolor(drawid)=yellow '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(4)/7+1)   
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(4) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(4) + 6 , incrov))*val(overlaychartsratiolist.item(4)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

if charttf(displayedfile)=10080 then
	indicolor(drawid)=yellow '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(4)/7+1)

 yearov=mid$(Grid.Cell(Overlay_Chartbuffer(4) + 1 , incrov),1,4)
 monthov=mid$(Grid.Cell(Overlay_Chartbuffer(4) + 1 , incrov),6,2)
 dayov=mid$(Grid.Cell(Overlay_Chartbuffer(4) + 1 , incrov),9,2)
 dateov=yearov+";"+monthov+";"+dayov+";"+"00"+";"+"00"+";"+"00"
 unixtimeov=varptr$(date_to_unix_time(varptr(dateov)))

 year00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),1,4)
 month00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),6,2)
 day00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),9,2)
 date00=year00+";"+month00+";"+day00+";"+"00"+";"+"00"+";"+"00"
 unixtime00=varptr$(date_to_unix_time(varptr(date00)))

	'if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(4) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then    	
if val(unixtimeov)>=val(unixtime00)-(1440*60*3) and val(unixtimeov)<val(unixtime00)+(1440*60*3) then
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(4) + 6 , incrov))*val(overlaychartsratiolist.item(4)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if
    
    if charttf(displayedfile)=43200 then
    indicolor(drawid)=yellow '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(4)/7+1)   
    if MID$(replacesubstr$(Grid.Cell(Overlay_Chartbuffer(4) + 1 , incrov),"-",".") , 1 , 7)=MID$(replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") , 1 , 7) then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(4) + 6 , incrov))*val(overlaychartsratiolist.item(4)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

    drawid=drawid+2
    
    end if
    
    if overlaychartslist.itemcount>5 then
    
    if charttf(displayedfile)<=240 then
    indicolor(drawid)=orange '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(5)/7+1)       
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(5) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") and Grid.Cell(Overlay_Chartbuffer(5) + 2 , incrov)=Grid.Cell(rowgridoffset + 2 , ibar) then       
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(5) + 6 , incrov))*val(overlaychartsratiolist.item(5)))
    exit for
    'else
    '.Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if
    
    if charttf(displayedfile)=1440 then
    indicolor(drawid)=orange '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(5)/7+1)   
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(5) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(5) + 6 , incrov))*val(overlaychartsratiolist.item(5)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

if charttf(displayedfile)=10080 then
	indicolor(drawid)=orange '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(5)/7+1)

 yearov=mid$(Grid.Cell(Overlay_Chartbuffer(5) + 1 , incrov),1,4)
 monthov=mid$(Grid.Cell(Overlay_Chartbuffer(5) + 1 , incrov),6,2)
 dayov=mid$(Grid.Cell(Overlay_Chartbuffer(5) + 1 , incrov),9,2)
 dateov=yearov+";"+monthov+";"+dayov+";"+"00"+";"+"00"+";"+"00"
 unixtimeov=varptr$(date_to_unix_time(varptr(dateov)))

 year00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),1,4)
 month00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),6,2)
 day00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),9,2)
 date00=year00+";"+month00+";"+day00+";"+"00"+";"+"00"+";"+"00"
 unixtime00=varptr$(date_to_unix_time(varptr(date00)))

	'if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(5) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then    	
if val(unixtimeov)>=val(unixtime00)-(1440*60*3) and val(unixtimeov)<val(unixtime00)+(1440*60*3) then
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(5) + 6 , incrov))*val(overlaychartsratiolist.item(5)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if
    
    if charttf(displayedfile)=43200 then
    indicolor(drawid)=orange '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(5)/7+1)   
    if MID$(replacesubstr$(Grid.Cell(Overlay_Chartbuffer(5) + 1 , incrov),"-",".") , 1 , 7)=MID$(replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") , 1 , 7) then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(5) + 6 , incrov))*val(overlaychartsratiolist.item(5)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

    drawid=drawid+2
    
    end if
    
    if overlaychartslist.itemcount>6 then
    
    if charttf(displayedfile)<=240 then
    indicolor(drawid)=purple '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(6)/7+1)       
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(6) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") and Grid.Cell(Overlay_Chartbuffer(6) + 2 , incrov)=Grid.Cell(rowgridoffset + 2 , ibar) then       
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(6) + 6 , incrov))*val(overlaychartsratiolist.item(6)))
    exit for
    'else
    '.Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if
    
    if charttf(displayedfile)=1440 then
    indicolor(drawid)=purple '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(6)/7+1)   
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(6) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(6) + 6 , incrov))*val(overlaychartsratiolist.item(6)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

if charttf(displayedfile)=10080 then
	indicolor(drawid)=purple '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(6)/7+1)

 yearov=mid$(Grid.Cell(Overlay_Chartbuffer(6) + 1 , incrov),1,4)
 monthov=mid$(Grid.Cell(Overlay_Chartbuffer(6) + 1 , incrov),6,2)
 dayov=mid$(Grid.Cell(Overlay_Chartbuffer(6) + 1 , incrov),9,2)
 dateov=yearov+";"+monthov+";"+dayov+";"+"00"+";"+"00"+";"+"00"
 unixtimeov=varptr$(date_to_unix_time(varptr(dateov)))

 year00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),1,4)
 month00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),6,2)
 day00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),9,2)
 date00=year00+";"+month00+";"+day00+";"+"00"+";"+"00"+";"+"00"
 unixtime00=varptr$(date_to_unix_time(varptr(date00)))

	'if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(6) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then    	
if val(unixtimeov)>=val(unixtime00)-(1440*60*3) and val(unixtimeov)<val(unixtime00)+(1440*60*3) then
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(6) + 6 , incrov))*val(overlaychartsratiolist.item(6)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if
    
    if charttf(displayedfile)=43200 then
    indicolor(drawid)=purple '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(6)/7+1)   
    if MID$(replacesubstr$(Grid.Cell(Overlay_Chartbuffer(6) + 1 , incrov),"-",".") , 1 , 7)=MID$(replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") , 1 , 7) then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(6) + 6 , incrov))*val(overlaychartsratiolist.item(6)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

    drawid=drawid+2
    
    end if
    
    if overlaychartslist.itemcount>7 then
    
    if charttf(displayedfile)<=240 then
    indicolor(drawid)=gray '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(7)/7+1)       
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(7) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") and Grid.Cell(Overlay_Chartbuffer(7) + 2 , incrov)=Grid.Cell(rowgridoffset + 2 , ibar) then       
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(7) + 6 , incrov))*val(overlaychartsratiolist.item(7)))
    exit for
    'else
    '.Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if
    
    if charttf(displayedfile)=1440 then
    indicolor(drawid)=gray '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(7)/7+1)   
    if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(7) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(7) + 6 , incrov))*val(overlaychartsratiolist.item(7)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

if charttf(displayedfile)=10080 then
	indicolor(drawid)=gray '<--- replace with your color
	for incrov=chartstart to chartbars(Overlay_Chartbuffer(7)/7+1)

 yearov=mid$(Grid.Cell(Overlay_Chartbuffer(7) + 1 , incrov),1,4)
 monthov=mid$(Grid.Cell(Overlay_Chartbuffer(7) + 1 , incrov),6,2)
 dayov=mid$(Grid.Cell(Overlay_Chartbuffer(7) + 1 , incrov),9,2)
 dateov=yearov+";"+monthov+";"+dayov+";"+"00"+";"+"00"+";"+"00"
 unixtimeov=varptr$(date_to_unix_time(varptr(dateov)))

 year00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),1,4)
 month00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),6,2)
 day00=mid$(Grid.Cell(rowgridoffset + 1 , ibar),9,2)
 date00=year00+";"+month00+";"+day00+";"+"00"+";"+"00"+";"+"00"
 unixtime00=varptr$(date_to_unix_time(varptr(date00)))

	'if replacesubstr$(Grid.Cell(Overlay_Chartbuffer(7) + 1 , incrov),"-",".")=replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") then    	
if val(unixtimeov)>=val(unixtime00)-(1440*60*3) and val(unixtimeov)<val(unixtime00)+(1440*60*3) then
	.Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(7) + 6 , incrov))*val(overlaychartsratiolist.item(7)))
	exit for
	'else	
	'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
	'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
	'exit for
	end if
	next incrov
	end if
    
    if charttf(displayedfile)=43200 then
    indicolor(drawid)=gray '<--- replace with your color
    for incrov=chartstart to chartbars(Overlay_Chartbuffer(7)/7+1)   
    if MID$(replacesubstr$(Grid.Cell(Overlay_Chartbuffer(7) + 1 , incrov),"-",".") , 1 , 7)=MID$(replacesubstr$(Grid.Cell(rowgridoffset + 1 , ibar),"-",".") , 1 , 7) then      
    .Data_Indi.Cell(drawid,lbar)=str$(val(Grid.Cell(Overlay_Chartbuffer(7) + 6 , incrov))*val(overlaychartsratiolist.item(7)))
    exit for
    'else   
    'if lbar<=1 then .Data_Indi.Cell(drawid,lbar)="0"
    'if lbar>1 then .Data_Indi.Cell(drawid,lbar)=.Data_Indi.Cell(drawid,lbar-1)
    'exit for
    end if
    next incrov
    end if

    drawid=drawid+2
    
    end if
    
    'indicolor(drawid)=blue '<--- replace with your color
    '.Data_Indi.Cell(drawid,lbar)= str$(val(Grid.Cell(Overlay_Chartbuffer(1) + 6 , ibar))*val(overlaychartsratiolist.item(Overlay_Chartbuffer(1)/7)))
    'drawid=drawid+2

    'indicolor(drawid)=blue '<--- replace with your color
    '.Data_Indi.Cell(drawid,lbar)= str$(val(Grid.Cell(Overlay_Chartbuffer(2) + 6 , ibar))*val(overlaychartsratiolist.item(Overlay_Chartbuffer(2)/7)))
    'drawid=drawid+2
end if

end if
'------------------------- End Overlay_Chart -------------------------------------------------
'------------------------- past regression deviated -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=past_regression_deviatedperiodedit.text
cpptmpfuncreturn=varptr$(past_regression_deviated(varptr(periodstr)))
end if

barsback=numbars '<--- can also be something like VAL(past_regression_deviatedbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="prd_high2Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="prd_low2Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End past regression deviated -------------------------------------------------
'------------------------- Planetary lines -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
Planetary_lines
end if

barsback=val(barslimitedit.text) '<--- can also be something like VAL(Planetary_linesbarsbackedit.text)

if ibar>=lastbar-barsback then

if earth.checked=1 then
defint increarth
for increarth=0 to 12
    indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_earthbuffer(increarth,offset))
    drawid=drawid+2
next increarth
end if

if jupiter.checked=1 then
defint incrjupiter
for incrjupiter=0 to 12
	indicolor(drawid)=olive '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_jupiterbuffer(incrjupiter,offset))
    drawid=drawid+2
next incrjupiter
end if

if mars.checked=1 then
defint incrmars
for incrmars=0 to 12
indicolor(drawid)=red '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_marsbuffer(incrmars,offset))
    drawid=drawid+2
next incrmars
end if

if mercury.checked=1 then
defint incrmercury
for incrmercury=0 to 12
indicolor(drawid)=orange '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_mercurybuffer(incrmercury,offset))
    drawid=drawid+2
next incrmercury
end if

if neptune.checked=1 then
defint incrneptune
for incrneptune=0 to 12
indicolor(drawid)=purple '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_neptunebuffer(incrneptune,offset))
    drawid=drawid+2
next incrneptune
end if

if saturn.checked=1 then
defint incrsaturn
for incrsaturn=0 to 12
indicolor(drawid)=gray '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_saturnbuffer(incrsaturn,offset))
    drawid=drawid+2
next incrsaturn
end if

if uranus.checked=1 then
defint incruranus
for incruranus=0 to 12
indicolor(drawid)=lightblue '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_uranusbuffer(incruranus,offset))
    drawid=drawid+2
next incruranus
end if

if venus.checked=1 then
defint incrvenus
for incrvenus=0 to 12
indicolor(drawid)=pink '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_venusbuffer(incrvenus,offset))
    drawid=drawid+2
next incrvenus
end if

if sun.checked=1 then
defint incrsun
for incrsun=0 to 12
indicolor(drawid)=yellow '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_sunbuffer(incrsun,offset))
    drawid=drawid+2
next incrsun
end if

if moon.checked=1 then
defint incrmoon
for incrmoon=0 to 12
indicolor(drawid)=white '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_moonbuffer(incrmoon,offset))
    drawid=drawid+2
next incrmoon
end if

if pluto.checked=1 then
defint incrpluto
for incrpluto=0 to 12
indicolor(drawid)=black '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_plutobuffer(incrpluto,offset))
    drawid=drawid+2
next incrpluto
end if

if mean_node.checked=1 then
defint incrmean_node
for incrmean_node=0 to 12
indicolor(drawid)=green '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_mean_nodebuffer(incrmean_node,offset))
    drawid=drawid+2
next incrmean_node
end if

if true_node.checked=1 then
defint incrtrue_node
for incrtrue_node=0 to 12
indicolor(drawid)=red '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_true_nodebuffer(incrtrue_node,offset))
    drawid=drawid+2
next incrtrue_node
end if

if mean_apog.checked=1 then
defint incrmean_apog
for incrmean_apog=0 to 12
indicolor(drawid)=blue '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_mean_apogbuffer(incrmean_apog,offset))
    drawid=drawid+2
next incrmean_apog
end if

if oscu_apog.checked=1 then
defint incroscu_apog
for incroscu_apog=0 to 12
indicolor(drawid)=olive '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_oscu_apogbuffer(incroscu_apog,offset))
    drawid=drawid+2
next incroscu_apog
end if

if chiron.checked=1 then
defint incrchiron
for incrchiron=0 to 12
indicolor(drawid)=orange '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_chironbuffer(incrchiron,offset))
    drawid=drawid+2
next incrchiron
end if

if pholus.checked=1 then
defint incrpholus
for incrpholus=0 to 12
indicolor(drawid)=red '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_pholusbuffer(incrpholus,offset))
    drawid=drawid+2
next incrpholus
end if

if ceres.checked=1 then
defint incrceres
for incrceres=0 to 12
indicolor(drawid)=pink '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_ceresbuffer(incrceres,offset))
    drawid=drawid+2
next incrceres
end if

if pallas.checked=1 then
defint incrpallas
for incrpallas=0 to 12
indicolor(drawid)=gray '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_pallasbuffer(incrpallas,offset))
    drawid=drawid+2
next incrpallas
end if

if juno.checked=1 then
defint incrjuno
for incrjuno=0 to 12
indicolor(drawid)=purple '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_junobuffer(incrjuno,offset))
    drawid=drawid+2
next incrjuno
end if

if vesta.checked=1 then
defint incrvesta
for incrvesta=0 to 12
indicolor(drawid)=lightblue '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_vestabuffer(incrvesta,offset))
    drawid=drawid+2
next incrvesta
end if

if nplanets.checked=1 then
defint incrnplanets
for incrnplanets=0 to 12
indicolor(drawid)=white '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_nplanetsbuffer(incrnplanets,offset))
    drawid=drawid+2
next incrnplanets
end if

if ast_offset.checked=1 then
defint incrast_offset
for incrast_offset=0 to 12
indicolor(drawid)=yellow '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_ast_offsetbuffer(incrast_offset,offset))
    drawid=drawid+2
next incrast_offset
end if

if Planetary_average_checkbox.checked=1 then
defint incravg
for incravg=0 to 12
indicolor(drawid)=yellow '<--- replace with your color	
    .Data_Indi.Cell(drawid,lbar)= STR$(Planetary_lines_averagebuffer(incravg,offset))
    drawid=drawid+2
next incrvenus
end if

end if

end if
'------------------------- End Planetary lines -------------------------------------------------
'------------------------- planetsqn -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
planetsqn
end if

barsback=numbars '<--- can also be something like VAL(planetsqnbarsbackedit.text)

if ibar>=lastbar-barsback then
'defint incrj
for incrj=0 to 12
.Data_Indi.Cell(drawid,lbar)=""
    indicolor(drawid)=blue '<--- replace with your color

'defint k
'for k=2 to 961
'anglist.cell(0,k)=getanglesubsq9_2(k)
'next k

defstr tempsqn

for k=ceil(graphvhigh) to floor(graphvlow) step -1
if round(getanglesubsq9_2(k))=round(val(planetsqnbuffer2.cell(incrj,offset))) then
planetsqnbuffer3.cell(incrj,offset)=str$(k)
tempsqn=str$(k)
exit for
end if
next k

if planetsqnbuffer3.cell(incrj,offset)="" then
planetsqnbuffer3.cell(incrj,offset)=tempsqn
end if

    .Data_Indi.Cell(drawid,lbar)= planetsqnbuffer3.cell(incrj,offset)
planetsqnbuffer3.cell(incrj,offset)=""
    drawid=drawid+2
next incrj
end if

end if
'------------------------- End planetsqn -------------------------------------------------
'------------------------- priceclose1440 -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
priceclose1440
end if

barsback=200 '<--- can also be something like VAL(priceclose1440barsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(priceclose1440buffer(offset))
    drawid=drawid+2
end if

end if
'------------------------- End priceclose1440 -------------------------------------------------
'------------------------- RSTL -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=RSTLperiodedit.text
cpptmpfuncreturn=varptr$(RSTL(varptr(periodstr)))
end if

barsback=200 '<--- can also be something like VAL(RSTLbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=purple '<--- replace with your color
    bufnamestr="RSTLbuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End RSTL -------------------------------------------------
'------------------------- Fibo MA Channels -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
smafibo
end if

barsback=500 '<--- can also be something like VAL(myindibarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=red '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(fibobuffer1(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
	indicolor(drawid)=orange '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(fibobuffer2(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
	indicolor(drawid)=yellow '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(fibobuffer3(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
	indicolor(drawid)=white '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(fibobuffer4(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
	indicolor(drawid)=white '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(fibobuffer5(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
	indicolor(drawid)=yellow '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(fibobuffer6(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
	indicolor(drawid)=orange '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(fibobuffer7(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
	indicolor(drawid)=red '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(fibobuffer8(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
end if

end if
'------------------------- End Fibo MA Channels -------------------------------------------------
'------------------------- Square numbers -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
Square_numbers
end if

barsback=numbars '<--- can also be something like VAL(Square_numbersbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer1(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer2(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer3(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer4(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer5(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer6(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer7(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer8(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer9(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer10(offset))
    drawid=drawid+2
    indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer11(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer12(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer13(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer14(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer15(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer16(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer17(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer18(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer19(offset))
    drawid=drawid+2
indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(Square_numbersbuffer20(offset))
    drawid=drawid+2
end if

end if
'------------------------- End Square numbers -------------------------------------------------
'------------------------- Synodic Cycle -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
synodic_cycle
end if

barsback=numbars '<--- can also be something like VAL(synodic_cyclebarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=blue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(synodic_cyclebuffer(offset))
    drawid=drawid+2
end if

end if
'------------------------- End Synodic Cycle -------------------------------------------------
'------------------------- TD_Sequential -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
TD_Sequential
end if

barsback=val(TD_Sequentialbarsbackedit.text) '<--- can also be something like VAL(TD_Sequentialbarsbackedit.text)

'if ibar>=lastbar-barsback then
    'indicolor(drawid)=lightblue '<--- replace with your color
    '.Data_Indi.Cell(drawid,lbar)= STR$(TD_Sequentialbuffer(offset))
    'drawid=drawid+2
'end if

end if
'------------------------- End TD_Sequential -------------------------------------------------
'------------------------- TMA_CG -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if TMA_CGautotf.checked=0 then curtfstr=TMA_CGcurtfedit.text
if TMA_CGautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(TMA_CG(varptr(curtfstr)))
end if

barsback=numbars '<--- can also be something like VAL(TMA_CGbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=dimgray '<--- replace with your color
    bufnamestr="tmBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="upBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=limegreen '<--- replace with your color
    bufnamestr="dnBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End TMA_CG -------------------------------------------------
'------------------------- TriangularMA1H -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if TriangularMA1Hautotf.checked=0 then curtfstr=TriangularMA1Hcurtfedit.text
if TriangularMA1Hautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(TriangularMA1H(varptr(curtfstr)))
end if

barsback=numbars '<--- can also be something like VAL(TriangularMA1Hbarsbackedit.text)

if ibar>=lastbar-barsback then

indicolor(drawid)=dimgray '<--- replace with your color
    bufnamestr="TriangularMA1Hbuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="TriangularMA1Hbuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="TriangularMA1Hbuffer3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End TriangularMA1H -------------------------------------------------
'------------------------- TriangularMA4H -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
atrmultstr=TriangularMA4Hatrmultedit.text
if TriangularMA4Hautotf.checked=0 then curtfstr=TriangularMA4Hcurtfedit.text
if TriangularMA4Hautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(TriangularMA4H(varptr(curtfstr),varptr(atrmultstr)))
end if

barsback=numbars '<--- can also be something like VAL(TriangularMA4Hbarsbackedit.text)

if ibar>=lastbar-barsback then

indicolor(drawid)=dimgray '<--- replace with your color
    bufnamestr="TriangularMA4Hbuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=saddlebrown '<--- replace with your color
    bufnamestr="TriangularMA4Hbuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=saddlebrown '<--- replace with your color
    bufnamestr="TriangularMA4Hbuffer3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End TriangularMA4H -------------------------------------------------
'------------------------- Time Series Forecast -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
TSF
end if

barsback=VAL(TSFbarsback.text) '<--- can also be something like VAL(myindibarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=Green '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(tsfbuffer(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
end if

end if
'------------------------- End Time Series Forecast -------------------------------------------------
'--------Vegas-------------------------------------------------------------
indiid++
        
                    if indicatorslistsel.item(indiid)="x" then 

                        if lbar=1 then     
                            vegas
                        end if

                         barsback=VAL(vegasbarsbackedit.text)
                    
                        if ibar>=lastbar-barsback then
            
                            indicolor(drawid)=red
                            .Data_Indi.Cell(drawid,lbar)= STR$(vegasup(offset))
				drawid=drawid+2            
                            indicolor(drawid)=red
                            .Data_Indi.Cell(drawid,lbar)= STR$(vegasdn(offset))
				drawid=drawid+2
            
                        end if                                                          
         
                    end if
        
        '--------End Vegas----------------------------------------------------------        
'------------------------- Vegascpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
defstr pointstr=Vegascpppointedit.text
defstr Vegascppriskmodelstr=Vegascppriskmodel.item(Vegascppriskmodel.itemindex)
if Vegascppautotf.checked=0 then curtfstr=Vegascppcurtfedit.text
if Vegascppautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Vegascpp(varptr(Vegascppriskmodelstr),varptr(pointstr),varptr(curtfstr)))
end if

barsback=bars '<--- can also be something like VAL(Vegascppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=olive '<--- replace with your color
    bufnamestr="vegasExtMapBuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=olive '<--- replace with your color
    bufnamestr="vegasExtMapBuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="vegasExtMapBuffer3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="vegasExtMapBuffer4"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="vegasExtMapBuffer5"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="vegasExtMapBuffer6"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="vegasExtMapBuffer7"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="vegasExtMapBuffer8"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Vegascpp -------------------------------------------------
'------------------------- Volatility Pivot cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=Volatility_Pivot_cppperiodedit.text
'cpptmpfuncreturn=varptr$(Volatility_Pivot_cpp(varptr(periodstr)))
if Volatility_Pivot_cppautotf.checked=0 then curtfstr=Volatility_Pivot_cppcurtfedit.text
if Volatility_Pivot_cppautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Volatility_Pivot_cpp(varptr(periodstr),varptr(curtfstr)))
end if

barsback=bars '<--- can also be something like VAL(Volatility_Pivot_cppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="Volatility_Pivot_cppbuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Volatility Pivot cpp -------------------------------------------------
'------------------------- Volatility Pivot -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
VolatilityPivot
end if

barsback=val(VolatilityPivotbarsbackedit.text) '<--- can also be something like VAL(myindibarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=lightblue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= volatilitypivottrstopgrid.cell(1,offset) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
end if

end if
'------------------------- End Volatility Pivot -------------------------------------------------
'------------------------- Volatility Stop -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=VolatilityStopperiodedit.text
cpptmpfuncreturn=varptr$(VolatilityStop(varptr(periodstr)))
end if

barsback=200 '<--- can also be something like VAL(VolatilityStopbarsbackedit.text)

if ibar>=lastbar-barsback then
    'indicolor(drawid)=red '<--- replace with your color
    'bufnamestr="volatilitystopBuffer1"
    '.Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    'drawid=drawid+2
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="volatilitystopBuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Volatility Stop -------------------------------------------------
'------------------------- VWAP -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=VWAPbarsbackedit.text
if VWAPautotf.checked=0 then curtfstr=VWAPcurtfedit.text
if VWAPautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(VWAP(varptr(barsbackstr),varptr(curtfstr)))
end if

barsback=VAL(VWAPbarsbackedit.text) '<--- can also be something like VAL(VWAPbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=Yellow '<--- replace with your color
    bufnamestr="VWAPbuffer1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=Red '<--- replace with your color
    bufnamestr="VWAPbuffer2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
indicolor(drawid)=Green '<--- replace with your color
    bufnamestr="VWAPbuffer3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End VWAP -------------------------------------------------
'------------------------- WaterLevel cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=waterlevelcppperiodedit.text
if waterlevelcppautotf.checked=0 then curtfstr=waterlevelcppcurtfedit.text
if waterlevelcppautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(initwaterlevelcpp(varptr(curtfstr)))
cpptmpfuncreturn=varptr$(waterlevelcpp(varptr(periodstr),varptr(curtfstr)))
end if

barsback=200 '<--- can also be something like VAL(waterlevelcppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=gold '<--- replace with your color
    bufnamestr="TimeFrame1Level"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=green '<--- replace with your color
    bufnamestr="TimeFrame2Level"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=red '<--- replace with your color
    bufnamestr="SellPrice"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=olive '<--- replace with your color
    bufnamestr="BuyPrice"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=orange '<--- replace with your color
    bufnamestr="TimeFrame2AverageMA1"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=sweetblue '<--- replace with your color
    bufnamestr="TimeFrame2AverageMA2"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=pink '<--- replace with your color
    bufnamestr="TimeFrame2AverageMA3"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=blue '<--- replace with your color
    bufnamestr="TimeFrame2AverageMA4"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End WaterLevel cpp -------------------------------------------------
'------------------------- Weekly Pivot cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=weeklypivotcppbarsbackedit.text
cpptmpfuncreturn=varptr$(weeklypivotcpp(varptr(barsbackstr)))
end if

barsback=bars 'val(barsbackstr) '<--- can also be something like VAL(weeklypivotcppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=magenta '<--- replace with your color
    bufnamestr="PBuffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=royalblue '<--- replace with your color
    bufnamestr="S1Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=crimson '<--- replace with your color
    bufnamestr="R1Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=royalblue '<--- replace with your color
    bufnamestr="S2Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=crimson '<--- replace with your color
    bufnamestr="R2Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=seagreen '<--- replace with your color
    bufnamestr="S3Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    indicolor(drawid)=seagreen '<--- replace with your color
    bufnamestr="R3Buffer"
    .Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Weekly Pivot cpp -------------------------------------------------
'------------------------- ZigZag -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
zigzag
end if

barsback=VAL(zigzagbarsbackedit.text) '<--- can also be something like VAL(myindibarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=purple '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(zigzagbuffer(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
end if

end if
'------------------------- End ZigZag -------------------------------------------------
'------------------------- ZigZag cpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=zigzagcppbarsbackedit.text
defstr extdepthstr=zzcppextdepthedit.text
cpptmpfuncreturn=varptr$(zigzagcpp(varptr(barsbackstr),varptr(extdepthstr)))
FOR delallj=1 to 10
	    FOR delalli = 1 TO 1000 - 1
                    if trendlinesdb.Cell(5 , delalli) = "zigzagcpp" then			
			trendlinesdb.deleterow(delalli)
			trendlinesoffset--
			if trendlinesoffset<0 then trendlinesoffset=0
		    end if
            NEXT delalli
	trendlinesdb.RowCount = 100
	next delallj
end if

barsback=numbars 'val(zigzagcppbarsbackedit.text) '<--- can also be something like VAL(zigzagcppbarsbackedit.text)

if ibar>=lastbar-barsback then
    indicolor(drawid)=purple '<--- replace with your color
    bufnamestr="zigzagbuffer"
    '.Data_Indi.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
if val(varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr))))>0 then
defint ijk
defstr ijkstr
for ijk=offset-1 to 0 step -1
ijkstr=str$(ijk)
if val(varptr$(getbufferdata(varptr(bufnamestr),varptr(ijkstr))))>0 then

year0=mid$(date(offset),1,4)
month0=mid$(date(offset),6,2)
day0=mid$(date(offset),9,2)
hours0=mid$(time(offset),1,2)
minutes0=mid$(time(offset),4,2) 
$mydate0=year0+";"+month0+";"+day0+";"+hours0+";"+minutes0+";"+"00"
cpptmpfuncreturn=varptr$(date_to_unix_time(varptr($mydate0)))
trendlinesoffset++
trendlinesdb.Cell(1 , trendlinesoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
trendlinesdb.Cell(3 , trendlinesoffset) = cpptmpfuncreturn

year0=mid$(date(ijk),1,4)
month0=mid$(date(ijk),6,2)
day0=mid$(date(ijk),9,2)
hours0=mid$(time(ijk),1,2)
minutes0=mid$(time(ijk),4,2) 
$mydate0=year0+";"+month0+";"+day0+";"+hours0+";"+minutes0+";"+"00"
cpptmpfuncreturn=varptr$(date_to_unix_time(varptr($mydate0)))
trendlinesdb.Cell(2 , trendlinesoffset) = varptr$(getbufferdata(varptr(bufnamestr),varptr(ijkstr)))
trendlinesdb.Cell(4 , trendlinesoffset) = cpptmpfuncreturn
trendlinesdb.Cell(5 , trendlinesoffset) = "zigzagcpp"
exit for

end if
next ijk
end if
    drawid=drawid+2
end if

end if
'------------------------- End ZigZag cpp -------------------------------------------------
'------------------------- ztrendine_slope_pi_ratio -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
ztrendine_slope_pi_ratio
end if

barsback=numbars '<--- can also be something like VAL(ztrendine_slope_pi_ratiobarsbackedit.text)

if ibar>=lastbar-barsback then
defint incrjj
for incrjj=0 to 100
    indicolor(drawid)=lightblue '<--- replace with your color
    .Data_Indi.Cell(drawid,lbar)= STR$(ztrendine_slope_pi_ratiobuffer(incrjj,offset))
    drawid=drawid+2
next incrjj
end if

end if
'------------------------- End ztrendine_slope_pi_ratio -------------------------------------------------
'-================================= End indicators area ========================================-
END IF

drawidmaincanvas=drawid

IF l = 1 THEN
    valmin = VAL(Grid.Cell(rowgridoffset + 5 , i))
    valmax = VAL(Grid.Cell(rowgridoffset + 4 , i))
END IF

if i<=chartstart + .DATA.ColCount then

IF VAL(Grid.Cell(rowgridoffset + 5 , i)) < valmin THEN
    valmin = VAL(Grid.Cell(rowgridoffset + 5 , i))
END IF

IF VAL(Grid.Cell(rowgridoffset + 4 , i)) > valmax THEN
    valmax = VAL(Grid.Cell(rowgridoffset + 4 , i))
END IF

end if

'-==================================== Separate indicators area ==============================-


IF scrollmode = 0 THEN
    IF useindi.Checked = 1 THEN

        'FOR lo = 1 TO canvas.separateindicator1.RowCount STEP 2
        '    canvas.separateindicator1.Cell(lo , l) = STR$(l) 'Legend in Row 0 of Each Col
        '    doevents
        'NEXT lo
        'FOR lo = 2 TO canvas.separateindicator1.RowCount STEP 2
        '    canvas.separateindicator1.Cell(lo , l) = STR$(0)
        '    doevents
        'NEXT lo
        
        if i = chartstart then
            defint typeincr
            for typeincr=0 to 100
            drawtype(typeincr)=0
            doevents
            next typeincr
        end if
        
    END IF

    drawid = 2        

    canvasid ++
    
    

'------------------------- Accelerator -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
Accelerator
end if

barsback=200 '<--- can also be something like VAL(myindibarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightblue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(acceleratorbuffer0(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
end if

end if
'------------------------- End Accelerator -------------------------------------------------
'------------------------- astro_retrograde -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
astro_retrograde
end if

barsback=200 '<--- can also be something like VAL(astro_retrogradebarsbackedit.text)

if ibar>=lastbar-barsback then

drawtype(drawid)=2
sepindicolormulti(drawid,lbar)=white
if astro_retrograde_mercurybuffer(offset)=1 then sepindicolormulti(drawid,lbar)=orange
    canvas.separateindicator1.Cell(drawid,lbar)= "0"
    drawid=drawid+2

drawtype(drawid)=2
sepindicolormulti(drawid,lbar)=white
if astro_retrograde_venusbuffer(offset)=1 then sepindicolormulti(drawid,lbar)=pink
    canvas.separateindicator1.Cell(drawid,lbar)= "10"
    drawid=drawid+2

drawtype(drawid)=2
sepindicolormulti(drawid,lbar)=white
if astro_retrograde_earthbuffer(offset)=1 then sepindicolormulti(drawid,lbar)=blue
    canvas.separateindicator1.Cell(drawid,lbar)= "20"
    drawid=drawid+2

drawtype(drawid)=2
sepindicolormulti(drawid,lbar)=white
if astro_retrograde_marsbuffer(offset)=1 then sepindicolormulti(drawid,lbar)=red
    canvas.separateindicator1.Cell(drawid,lbar)= "30"
    drawid=drawid+2

drawtype(drawid)=2
sepindicolormulti(drawid,lbar)=white
if astro_retrograde_jupiterbuffer(offset)=1 then sepindicolormulti(drawid,lbar)=olive
    canvas.separateindicator1.Cell(drawid,lbar)= "40"
    drawid=drawid+2

drawtype(drawid)=2
sepindicolormulti(drawid,lbar)=white
if astro_retrograde_saturnbuffer(offset)=1 then sepindicolormulti(drawid,lbar)=gray
    canvas.separateindicator1.Cell(drawid,lbar)= "50"
    drawid=drawid+2

drawtype(drawid)=2
sepindicolormulti(drawid,lbar)=white
if astro_retrograde_uranusbuffer(offset)=1 then sepindicolormulti(drawid,lbar)=lightblue
    canvas.separateindicator1.Cell(drawid,lbar)= "60"
    drawid=drawid+2

drawtype(drawid)=2
sepindicolormulti(drawid,lbar)=white
if astro_retrograde_neptunebuffer(offset)=1 then sepindicolormulti(drawid,lbar)=purple
    canvas.separateindicator1.Cell(drawid,lbar)= "70"
    drawid=drawid+2

drawtype(drawid)=2
sepindicolormulti(drawid,lbar)=white
if astro_retrograde_plutobuffer(offset)=1 then sepindicolormulti(drawid,lbar)=black
    canvas.separateindicator1.Cell(drawid,lbar)= "80"
    drawid=drawid+2

end if

if autoadjustsepindi.checked=1 then     
sepindivalminedit.text="-20"             
sepindivalmaxedit.text="90"                             
end if

end if
'------------------------- End astro_retrograde -------------------------------------------------
'------------------------- Average True Range -------------------------------------------------
indiid++
         
                    if indicatorslistsel.item(indiid)="x" then 
            
                        if lbar=1 then           
                            atr(1)
                        end if

                         barsback=VAL(atrbarsbackedit.text)
                        
                    if ibar>=lastbar-barsback then
                        sepindicolor(drawid)=lightblue
                        canvas.separateindicator1.Cell(drawid,lbar)= STR$(atrbuffer(offset))
            		drawid=drawid+2
                    end if                      
                     
                end if                                  

        '------------------------- End Average True Range -------------------------------------------------
'------------------------- Candle Average -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
CandleAvg
end if

barsback=200 '<--- can also be something like VAL(myindibarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightblue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(candleavgbuffer(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
end if

end if
'------------------------- End Candle Average -------------------------------------------------
'------------------------- CoronaSwingPosition -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if CoronaSwingPositionautotf.checked=0 then curtfstr=CoronaSwingPositioncurrenttfedit.text
if CoronaSwingPositionautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(CoronaSwingPosition(varptr(curtfstr)))
end if

barsback=numbars '<--- can also be something like VAL(CoronaSwingPositionbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="CoronaSwingPositionbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End CoronaSwingPosition -------------------------------------------------
'------------------------- CoronaTrendVigor -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=CoronaTrendVigorbarsbackedit.text
if CoronaTrendVigorautotf.checked=0 then curtfstr=CoronaTrendVigorcurtfedit.text
if CoronaTrendVigorautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(CoronaTrendVigor(varptr(barsbackstr),varptr(curtfstr)))
end if

barsback=numbars '<--- can also be something like VAL(CoronaTrendVigorbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="TV"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="TVmax"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="TVmin"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-11"             
        sepindivalmaxedit.text="11"        
end if

end if
'------------------------- End CoronaTrendVigor -------------------------------------------------
'------------------------- CyAn_1_Fty -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=CyAn_1_Ftyperiodedit.text
if CyAn_1_Ftyautotf.checked=0 then curtfstr=CyAn_1_Ftycurtfedit.text
if CyAn_1_Ftyautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(CyAn_1_Fty(varptr(periodstr),varptr(curtfstr)))
end if

barsback=222 '<--- can also be something like VAL(CyAn_1_Ftybarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=orange '<--- replace with your color
    bufnamestr="AuxBufferCyAn"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="AuxBufferMaxCyAn"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="AuxBufferMinCyAn"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-1"             
        sepindivalmaxedit.text="1"        
end if

end if
'------------------------- End CyAn_1_Fty -------------------------------------------------
'------------------------- declination_system -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
declination_system
end if

barsback=300 '<--- can also be something like VAL(declination_systembarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=blue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(declination_systembuffer(offset))
    drawid=drawid+2
end if

end if
'------------------------- End declination_system -------------------------------------------------
'------------------------- Directional_Volume_Index -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=Directional_Volume_Indexperiodedit.text
'cpptmpfuncreturn=varptr$(Directional_Volume_Index(varptr(periodstr)))
if Directional_Volume_Indexautotf.checked=0 then curtfstr=Directional_Volume_Indexcurtfedit.text
if Directional_Volume_Indexautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Directional_Volume_Index(varptr(periodstr),varptr(curtfstr)))
end if

barsback=bars '<--- can also be something like VAL(Directional_Volume_Indexbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=gold '<--- replace with your color
    bufnamestr="Directional_Volume_Indexbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="Directional_Volume_Indexzerobuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-1"             
        sepindivalmaxedit.text="1"        
end if

end if
'------------------------- End Directional_Volume_Index -------------------------------------------------
'------------------------- DVI_valuechart -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
barsbackstr=DVI_valuechartbarsbackedit.text
periodstr=DVI_valuechartperiodedit.text
cpptmpfuncreturn=varptr$(DVI_valuechart(varptr(barsbackstr)))
end if

barsback=numbars '<--- can also be something like VAL(DVI_valuechartbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=deepskyblue '<--- replace with your color
    bufnamestr="DVI_valuechartbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End DVI_valuechart -------------------------------------------------
'------------------------- Ehlers fisher transform -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=Ehlersfishertransformperiodedit.text
if Ehlersfishertransformautotf.checked=0 then curtfstr=Ehlersfishertransformcurtfedit.text
if Ehlersfishertransformautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Ehlersfishertransform(varptr(periodstr),varptr(curtfstr)))
end if

barsback=200 '<--- can also be something like VAL(Ehlersfishertransformbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="Ehlersfishertransformbuffer1"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=mediumseagreen '<--- replace with your color
    bufnamestr="eftbandsmovingbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=mediumseagreen '<--- replace with your color
    bufnamestr="eftbandsupperbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=mediumseagreen '<--- replace with your color
    bufnamestr="eftbandslowerbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End Ehlers fisher transform -------------------------------------------------
'------------------------- energy -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
energy
end if

barsback=numbars '<--- can also be something like VAL(energybarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightblue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(energybuffer(offset))
    drawid=drawid+2
end if

end if
'------------------------- End energy -------------------------------------------------
'------------------------- fftspectro -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if autoadjustsepindi.checked=1 then 	                
	if chartbars(displayedfile)>=513 then
		barsdisplayed.Text="513"
		numbars = VAL(barsdisplayed.Text)
    		numbarsstr=str$(numbars):cpptmpfuncreturn=varptr$(setnumbars(varptr(numbarsstr)))
    		IF openedfilesnb = 0 THEN
        		EXIT SUB
    		END IF
    		Scrollchart.Max = chartbars(displayedfile)
    		Scrollchart.Position = chartbars(displayedfile)
    		chartstart = Scrollchart.Position - numbars
	else
		barsdisplayed.Text=str$(chartbars(displayedfile))
		numbars = VAL(barsdisplayed.Text)
    		numbarsstr=str$(numbars):cpptmpfuncreturn=varptr$(setnumbars(varptr(numbarsstr)))
    		IF openedfilesnb = 0 THEN
        		EXIT SUB
    		END IF
    		Scrollchart.Max = chartbars(displayedfile)
    		Scrollchart.Position = chartbars(displayedfile)
    		chartstart = Scrollchart.Position - numbars
		showmessage "Not enough displayed bars to calculate this indicator (at lease 513 needed)"
	end if
end if
fftspectro
end if

barsback=511 '<--- can also be something like VAL(fftspectrobarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=blue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(fftspectrobuffer(1,offset))
    drawid=drawid+2

sepindicolor(drawid)=lightblue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(fftspectrobuffer(2,offset))
    drawid=drawid+2

sepindicolor(drawid)=olive '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(fftspectrobuffer(3,offset))
    drawid=drawid+2

sepindicolor(drawid)=pink '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(fftspectrobuffer(4,offset))
    drawid=drawid+2

sepindicolor(drawid)=red '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(fftspectrobuffer(5,offset))
    drawid=drawid+2

sepindicolor(drawid)=yellow '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(fftspectrobuffer(6,offset))
    drawid=drawid+2

sepindicolor(drawid)=lightblue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(fftspectrobuffer(7,offset))
    drawid=drawid+2

sepindicolor(drawid)=purple '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(fftspectrobuffer(8,offset))
    drawid=drawid+2

sepindicolor(drawid)=black '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(fftspectrobuffer(9,offset))
    drawid=drawid+2

end if

if autoadjustsepindi.checked=1 then 	        
        sepindivalmaxedit.text=str$(graphvlow*-1)
	defint fftincr
	sepindivalminedit.text="-"
	for fftincr=1 to len(str$(int(val(sepindivalmaxedit.text))))-1
		sepindivalminedit.text=sepindivalminedit.text+"1"  
	next fftincr
end if

end if
'------------------------- End fftspectro -------------------------------------------------
'------------------------- Force Index -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
ForceIndex
end if

barsback=200 '<--- can also be something like VAL(myindibarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightblue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(forceindexbuffer(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
end if

end if
'------------------------- End Force Index -------------------------------------------------
'------------------------- Gauquelin_sector -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
Gauquelin_sector
end if

barsback=200 '<--- can also be something like VAL(Gauquelin_sectorbarsbackedit.text)

if ibar>=lastbar-barsback then

defdbl gauqrads

gauqrads=sin(deg2rad((Gauquelin_sector_mercurybuffer(offset)-1)*10))
'gauqrads=sin(deg2rad(360*(Gauquelin_sector_mercurybuffer(offset)-1)/11))
sepindicolor(drawid)=orange
canvas.separateindicator1.Cell(drawid,lbar)= str$(gauqrads)
'print str$(lbar)+" "+canvas.separateindicator1.Cell(drawid,lbar)
drawid=drawid+2

gauqrads=sin(deg2rad((Gauquelin_sector_venusbuffer(offset)-1)*10))
'gauqrads=sin(deg2rad(360*(Gauquelin_sector_venusbuffer(offset)-1)/11))
sepindicolor(drawid)=pink
canvas.separateindicator1.Cell(drawid,lbar)= str$(gauqrads)
'print str$(lbar)+" "+canvas.separateindicator1.Cell(drawid,lbar)
drawid=drawid+2

gauqrads=sin(deg2rad((Gauquelin_sector_earthbuffer(offset)-1)*10))
'gauqrads=sin(deg2rad(360*(Gauquelin_sector_earthbuffer(offset)-1)/11))
sepindicolor(drawid)=blue
canvas.separateindicator1.Cell(drawid,lbar)= str$(gauqrads)
'print str$(lbar)+" "+canvas.separateindicator1.Cell(drawid,lbar)
drawid=drawid+2

gauqrads=sin(deg2rad((Gauquelin_sector_marsbuffer(offset)-1)*10))
'gauqrads=sin(deg2rad(360*(Gauquelin_sector_marsbuffer(offset)-1)/11))
sepindicolor(drawid)=red
canvas.separateindicator1.Cell(drawid,lbar)= str$(gauqrads)
'print str$(lbar)+" "+canvas.separateindicator1.Cell(drawid,lbar)
drawid=drawid+2

gauqrads=sin(deg2rad((Gauquelin_sector_jupiterbuffer(offset)-1)*10))
'gauqrads=sin(deg2rad(360*(Gauquelin_sector_jupiterbuffer(offset)-1)/11))
sepindicolor(drawid)=olive
canvas.separateindicator1.Cell(drawid,lbar)= str$(gauqrads)
'print str$(lbar)+" "+canvas.separateindicator1.Cell(drawid,lbar)
drawid=drawid+2

gauqrads=sin(deg2rad((Gauquelin_sector_saturnbuffer(offset)-1)*10))
'gauqrads=sin(deg2rad(360*(Gauquelin_sector_saturnbuffer(offset)-1)/11))
sepindicolor(drawid)=gray
canvas.separateindicator1.Cell(drawid,lbar)= str$(gauqrads)
'print str$(lbar)+" "+canvas.separateindicator1.Cell(drawid,lbar)
drawid=drawid+2

gauqrads=sin(deg2rad((Gauquelin_sector_uranusbuffer(offset)-1)*10))
'gauqrads=sin(deg2rad(360*(Gauquelin_sector_uranusbuffer(offset)-1)/11))
sepindicolor(drawid)=lightblue
canvas.separateindicator1.Cell(drawid,lbar)= str$(gauqrads)
'print str$(lbar)+" "+canvas.separateindicator1.Cell(drawid,lbar)
drawid=drawid+2

gauqrads=sin(deg2rad((Gauquelin_sector_neptunebuffer(offset)-1)*10))
'gauqrads=sin(deg2rad(360*(Gauquelin_sector_neptunebuffer(offset)-1)/11))
sepindicolor(drawid)=purple
canvas.separateindicator1.Cell(drawid,lbar)= str$(gauqrads)
'print str$(lbar)+" "+canvas.separateindicator1.Cell(drawid,lbar)
drawid=drawid+2

gauqrads=sin(deg2rad((Gauquelin_sector_plutobuffer(offset)-1)*10))
'gauqrads=sin(deg2rad(360*(Gauquelin_sector_plutobuffer(offset)-1)/11))
sepindicolor(drawid)=black
canvas.separateindicator1.Cell(drawid,lbar)= str$(gauqrads)
'print str$(lbar)+" "+canvas.separateindicator1.Cell(drawid,lbar)
drawid=drawid+2

end if

end if
'------------------------- End Gauquelin_sector -------------------------------------------------
'------------------------- iadxindicator -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if iadxindicatorautotf.checked=0 then curtfstr=iadxindicatorcurtfedit.text
if iadxindicatorautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(iadxindicator(varptr(curtfstr)))
end if

barsback=200 '<--- can also be something like VAL(iadxindicatorbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightseagreen '<--- replace with your color
    bufnamestr="iadxbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    sepindicolor(drawid)=yellowgreen '<--- replace with your color
    bufnamestr="iplusdibuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    sepindicolor(drawid)=wheat '<--- replace with your color
    bufnamestr="iminusdibuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End iadxindicator -------------------------------------------------
'------------------------- irviindicator -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if irviindicatorautotf.checked=0 then curtfstr=irviindicatorcurtfedit.text
if irviindicatorautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(irviindicator(varptr(curtfstr)))
end if

barsback=200 '<--- can also be something like VAL(irviindicatorbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=green '<--- replace with your color
    bufnamestr="irviindicatorrvibuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    sepindicolor(drawid)=red '<--- replace with your color
    bufnamestr="irviindicatortriggerbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End irviindicator -------------------------------------------------
'------------------------- IVolume -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
IVolume
end if

barsback=200 '<--- can also be something like VAL(myindibarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightblue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(volumebuffer(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
end if

end if
'------------------------- End IVolume -------------------------------------------------
'------------------------- j_tpo -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=j_tpoperiodedit.text
cpptmpfuncreturn=varptr$(j_tpo(varptr(periodstr)))
end if

barsback=bars '<--- can also be something like VAL(j_tpobarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=DodgerBlue '<--- replace with your color
    bufnamestr="j_tpobuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=silver '<--- replace with your color
    bufnamestr="j_tpomaxbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=silver '<--- replace with your color
    bufnamestr="j_tpominbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-1"             
        sepindivalmaxedit.text="1"        
end if

end if
'------------------------- End j_tpo -------------------------------------------------
'------------------------- LaguerreRSI -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
LaguerreRSI
end if

barsback=bars '<--- can also be something like VAL(LaguerreRSIbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=red '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(LaguerreRSIbuffer(offset))
    drawid=drawid+2

    sepindicolor(drawid)=gray '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= "0.8"
    drawid=drawid+2

    sepindicolor(drawid)=gray '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= "0.2"
    drawid=drawid+2
end if

end if
'------------------------- End LaguerreRSI -------------------------------------------------
'------------------------- LSS Oscillator -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
LSS
end if

barsback=200 '<--- can also be something like VAL(LSSbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightblue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(LSSbuffer(offset))
    drawid=drawid+2
    sepindicolor(drawid)=gray '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(LSSbufferlevel1(offset))
    drawid=drawid+2
    sepindicolor(drawid)=gray '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(LSSbufferlevel2(offset))
    drawid=drawid+2
    sepindicolor(drawid)=gray '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(LSSbufferlevel3(offset))
    drawid=drawid+2
end if

end if
'------------------------- End LSS Oscillator -------------------------------------------------
'------------------------- MACDonRSI -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if MACDonRSIautotf.checked=0 then curtfstr=MACDonRSIcurtfedit.text
if MACDonRSIautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(MACDonRSI(varptr(curtfstr)))
end if

barsback=numbars '<--- can also be something like VAL(MACDonRSIbarsbackedit.text)

if ibar>=lastbar-barsback then
    'sepindicolor(drawid)=lightblue '<--- replace with your color
    'bufnamestr="MACDonRSIbuffer"
    'canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    'drawid=drawid+2
    drawtype(drawid)=1
    sepindicolormulti(drawid,lbar)=crimson '<--- replace with your color
    bufnamestr="BufMACD"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    
    sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="MACDonRSIindicator_level1"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

	sepindicolor(drawid)=limegreen '<--- replace with your color
    bufnamestr="BufRSI"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

	sepindicolor(drawid)=blue '<--- replace with your color
    bufnamestr="BufSign"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-1"             
        sepindivalmaxedit.text="1"        
end if

end if
'------------------------- End MACDonRSI -------------------------------------------------
'------------------------- Money Flow Index -------------------------------------------------
indiid++
         
                     if indicatorslistsel.item(indiid)="x" then 
            
                        if lbar=1 then           
                            mfi
                        end if

                         barsback=VAL(mfibarsbackedit.text)                        

                        if ibar>=lastbar-barsback then
                            sepindicolor(drawid)=lightblue
				canvas.separateindicator1.Cell(drawid,lbar)= STR$(extmfibuffer(offset))
				drawid=drawid+2
                            sepindicolor(drawid)=gray
				canvas.separateindicator1.Cell(drawid,lbar)= STR$(mfilevelup(offset))
				drawid=drawid+2
                            sepindicolor(drawid)=gray                                                        
                            canvas.separateindicator1.Cell(drawid,lbar)= STR$(mfileveldn(offset))
				drawid=drawid+2
                
                        end if  
                        if autoadjustsepindi.checked=1 then 
                            sepindivalminedit.text="-20"             
                            sepindivalmaxedit.text="20"        
                        end if           
                     
                    end if                                  

        '------------------------- End Money Flow Index -------------------------------------------------
'------------------------- Moon_Phases -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
Moon_Phases
end if

barsback=numbars '<--- can also be something like VAL(Moon_Phasesbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=blue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(Moon_Phasesbuffer(offset))
    drawid=drawid+2

    sepindicolor(drawid)=gray '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(Moon_Phases_level_1_buffer(offset))
    drawid=drawid+2

    sepindicolor(drawid)=gray '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(Moon_Phases_level_2_buffer(offset))
    drawid=drawid+2
end if

end if
'------------------------- End Moon_Phases -------------------------------------------------
'------------------------- moon_scale -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
moon_scale
end if

barsback=numbars '<--- can also be something like VAL(moon_scalebarsbackedit.text)

if ibar>=lastbar-barsback then

defint incrplanetmoon
for incrplanetmoon=0 to 10
    sepindicolor(drawid)=olive '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(moonplanets_scalebuffer(incrplanetmoon,offset))
    drawid=drawid+2
next incrplanetmoon

sepindicolor(drawid)=red '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(moonprice_scalebuffer(offset))
    drawid=drawid+2

sepindicolor(drawid)=blue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(moonprice_scalebuffer2(offset))
    drawid=drawid+2

end if

end if
'------------------------- End moon_scale -------------------------------------------------
'------------------------- Planetary Speed -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
planetary_speed
end if

barsback=numbars '<--- can also be something like VAL(planetary_speedbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=blue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(planetary_speedbuffer(offset))
    drawid=drawid+2
    sepindicolor(drawid)=yellow '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(planetary_speed_sun_buffer(offset))
    drawid=drawid+2
end if

end if
'------------------------- End Planetary Speed -------------------------------------------------
'------------------------- planetcycles -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
planetcycles
end if

barsback=numbars '<--- can also be something like VAL(planetcyclesbarsbackedit.text)

if ibar>=lastbar-barsback then

sepindicolor(drawid)=red '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(planetcyclesbuffer0(offset))
    drawid=drawid+2

end if

end if
'------------------------- End planetcycles -------------------------------------------------
'------------------------- planets_scale -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
planets_scale
end if

barsback=numbars '<--- can also be something like VAL(planets_scalebarsbackedit.text)

if ibar>=lastbar-barsback then

defint incrplanet
for incrplanet=0 to 10
    sepindicolor(drawid)=olive '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(planets_scalebuffer(incrplanet,offset))
    drawid=drawid+2
next incrplanet

sepindicolor(drawid)=red '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(price_scalebuffer(offset))
    drawid=drawid+2

sepindicolor(drawid)=blue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(price_scalebuffer2(offset))
    drawid=drawid+2
end if

end if
'------------------------- End planets_scale -------------------------------------------------
'------------------------- Close Price -------------------------------------------------
indiid++
         
                     if indicatorslistsel.item(indiid)="x" then 
            
                        if lbar=1 then           
                            closepriceindi                        
                        end if

                         barsback=VAL(mabarsbackedit.text)                        

                        if ibar>=lastbar-barsback then
                            sepindicolor(drawid)=blue
                            canvas.separateindicator1.Cell(drawid,lbar)= STR$(closepricebuffer(offset))
				drawid=drawid+2
            
                        end if                      
                     
                    end if                                  

        '------------------------- End Close Price -------------------------------------------------
'------------------------- RBCI -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=RBCIperiodedit.text
cpptmpfuncreturn=varptr$(RBCI(varptr(periodstr)))
end if

barsback=numbars '<--- can also be something like VAL(RBCIbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=blue '<--- replace with your color
    bufnamestr="RBCIbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End RBCI -------------------------------------------------
'------------------------- RD_COMBO -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if RD_COMBOautotf.checked=0 then curtfstr=RD_COMBOcurtfedit.text
if RD_COMBOautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(RD_COMBO(varptr(curtfstr)))
end if

barsback=333 '<--- can also be something like VAL(RD_COMBObarsbackedit.text)

if ibar>=lastbar-barsback then 

    drawtype(drawid)=1
    sepindicolormulti(drawid,lbar)=gray '<--- replace with your color
    bufnamestr="NeutralBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    drawtype(drawid)=1
    sepindicolormulti(drawid,lbar)=orangered '<--- replace with your color
    bufnamestr="ShortSignalBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    drawtype(drawid)=1
    sepindicolormulti(drawid,lbar)=lawngreen '<--- replace with your color
    bufnamestr="LongSignalBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    sepindicolor(drawid)=gold '<--- replace with your color
    bufnamestr="SignalBuffer2"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-1"             
        sepindivalmaxedit.text="1"        
end if

end if
'------------------------- End RD_COMBO -------------------------------------------------
'------------------------- realMACD -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if realMACDautotf.checked=0 then curtfstr=realMACDcurtfedit.text
if realMACDautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(realMACD(varptr(curtfstr)))
end if

barsback=numbars '<--- can also be something like VAL(realMACDbarsbackedit.text)

if ibar>=lastbar-barsback then
    drawtype(drawid)=1
    sepindicolormulti(drawid,lbar)=yellow '<--- replace with your color
    bufnamestr="HistogramBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    sepindicolor(drawid)=red '<--- replace with your color
    bufnamestr="SignalLineBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    sepindicolor(drawid)=blue '<--- replace with your color
    bufnamestr="MACDLineBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End realMACD -------------------------------------------------
'------------------------- Relative Strength Index -------------------------------------------------
indiid++
         
                     if indicatorslistsel.item(indiid)="x" then 
            
                        if lbar=1 then           
                            rsi
                        end if

                         barsback=VAL(rsibarsbackedit.text)                        

                        if ibar>=lastbar-barsback then
                            sepindicolor(drawid)=lightblue
				canvas.separateindicator1.Cell(drawid,lbar)= STR$(rsibuffer(offset))
				drawid=drawid+2
                            sepindicolor(drawid)=gray
				canvas.separateindicator1.Cell(drawid,lbar)= STR$(rsilevelup(offset))
				drawid=drawid+2
                            sepindicolor(drawid)=gray                                                        
                            canvas.separateindicator1.Cell(drawid,lbar)= STR$(rsileveldn(offset))
				drawid=drawid+2
                
                        end if  
                        if autoadjustsepindi.checked=1 then 
                            sepindivalminedit.text="-20"             
                            sepindivalmaxedit.text="20"        
                        end if           
                     
                    end if                                  

        '------------------------- End Relative Strength Index -------------------------------------------------
'------------------------- smFisherTransform3nr -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=smFisherTransform3nrperiodedit.text
if smFisherTransform3nrautotf.checked=0 then curtfstr=smFisherTransform3nrcurtfedit.text
if smFisherTransform3nrautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(smFisherTransform3nr(varptr(periodstr),varptr(curtfstr)))
end if

barsback=200 '<--- can also be something like VAL(smFisherTransform3nrbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="ExtBuffer0"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2    
end if

end if
'------------------------- End smFisherTransform3nr -------------------------------------------------
'------------------------- spectrometer -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=spectrometerperiodedit.text
if spectrometerautotf.checked=0 then curtfstr=spectrometercurtfedit.text
if spectrometerautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(spectrometer(varptr(periodstr),varptr(curtfstr)))
end if

barsback=500 '<--- can also be something like VAL(spectrometerbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=red '<--- replace with your color
    bufnamestr="spectrometerbuffer1"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=orange '<--- replace with your color
    bufnamestr="spectrometerbuffer2"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=yellow '<--- replace with your color
    bufnamestr="spectrometerbuffer3"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=lime '<--- replace with your color
    bufnamestr="spectrometerbuffer4"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=blue '<--- replace with your color
    bufnamestr="spectrometerbuffer5"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=dodgerblue '<--- replace with your color
    bufnamestr="spectrometerbuffer6"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=darkviolet '<--- replace with your color
    bufnamestr="spectrometerbuffer7"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=dimgray '<--- replace with your color
    bufnamestr="spectrometerbuffer8"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End spectrometer -------------------------------------------------
'------------------------- Spud2 -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=Spud2periodedit.text
'cpptmpfuncreturn=varptr$(Spud2(varptr(periodstr)))
if Spud2autotf.checked=0 then curtfstr=Spud2curtfedit.text
if Spud2autotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Spud2(varptr(periodstr),varptr(curtfstr)))
end if

barsback=bars '<--- can also be something like VAL(Spud2barsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=DarkGray '<--- replace with your color
    bufnamestr="Spud2SBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    sepindicolor(drawid)=Red '<--- replace with your color
    bufnamestr="Spud2MaBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    sepindicolor(drawid)=Black '<--- replace with your color
    bufnamestr="Spud2MaxBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-22"             
        sepindivalmaxedit.text="11"        
end if

end if
'------------------------- End Spud2 -------------------------------------------------
'------------------------- stepftvcprdl -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=stepftvcprdlperiodedit.text
cpptmpfuncreturn=varptr$(stepftvcprdl(varptr(periodstr)))
end if

barsback=chartbars(displayedfile) '<--- can also be something like VAL(ftvcprdlbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=orange '<--- replace with your color
    bufnamestr="Line1Buffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    sepindicolor(drawid)=lightblue '<--- replace with your color
    bufnamestr="Line2Buffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    sepindicolor(drawid)=red '<--- replace with your color
    bufnamestr="Line3Buffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="steplevelup"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="stepleveldn"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End stepftvcprdl -------------------------------------------------
'------------------------- StepRSI -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
steprsi
end if

barsback=999 '<--- can also be something like VAL(myindibarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=orange '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(line1buffer(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
    sepindicolor(drawid)=lightblue '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(line2buffer(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
    sepindicolor(drawid)=purple '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(line3buffer(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
    sepindicolor(drawid)=gray '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(steprsilevelup(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2
    sepindicolor(drawid)=gray '<--- replace with your color
    canvas.separateindicator1.Cell(drawid,lbar)= STR$(steprsileveldn(offset)) '<--- replace myindibuffer with your indicator buffer name
    drawid=drawid+2	
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-20"             
	sepindivalmaxedit.text="20"        
end if  

end if
'------------------------- End StepRSI -------------------------------------------------
'------------------------- StepRSIcpp -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=StepRSIcppperiodedit.text
if StepRSIcppautotf.checked=0 then curtfstr=StepRSIcppcurtfedit.text
if StepRSIcppautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(StepRSIcpp(varptr(periodstr),varptr(curtfstr)))

end if

barsback=999 '<--- can also be something like VAL(StepRSIcppbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=orange '<--- replace with your color
    bufnamestr="Line1Buffer2"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=skyblue '<--- replace with your color
    bufnamestr="Line2Buffer2"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=magenta '<--- replace with your color
    bufnamestr="Line3Buffer2"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End StepRSIcpp -------------------------------------------------
'------------------------- Stochastic -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
'periodstr=stochasticperiodedit.text
'cpptmpfuncreturn=varptr$(stochastic(varptr(periodstr)))

barsbackstr=stochasticbarsbackedit.text
defstr stochastickperiodstr=stochastickperiodedit.text
defstr stochasticdperiodstr=stochasticdperiodedit.text
defstr stochasticslowingstr=stochasticslowingedit.text

if stochasticautotf.checked=0 then curtfstr=stochasticcurtfedit.text
if stochasticautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
parameters=barsbackstr+";"+stochastickperiodstr+";"+stochasticdperiodstr+";"+stochasticslowingstr+";"+curtfstr
cpptmpfuncreturn=varptr$(stochastic(varptr(parameters)))
end if

barsback=VAL(stochasticbarsbackedit.text) '<--- can also be something like VAL(stochasticbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=lightseagreen '<--- replace with your color
    bufnamestr="MainBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    sepindicolor(drawid)=red '<--- replace with your color
    bufnamestr="SignalBuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="stochup"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=gray '<--- replace with your color
    bufnamestr="stochdn"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-1"             
        sepindivalmaxedit.text="1"        
end if

end if
'------------------------- End Stochastic -------------------------------------------------
'------------------------- StochasticRSI -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=StochasticRSIperiodedit.text
cpptmpfuncreturn=varptr$(StochasticRSI(varptr(periodstr)))
end if

barsback=bars '<--- can also be something like VAL(StochasticRSIbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=red '<--- replace with your color
    bufnamestr="StocRSI"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
	
	sepindicolor(drawid)=blue '<--- replace with your color
    bufnamestr="Trigger"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=black '<--- replace with your color
    bufnamestr="StocRSImax"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=black '<--- replace with your color
    bufnamestr="StocRSImin"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-1"             
        sepindivalmaxedit.text="1"        
end if

end if
'------------------------- End StochasticRSI -------------------------------------------------
'------------------------- SwamiRSI_v1 -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=SwamiRSI_v1periodedit.text
if SwamiRSI_v1autotf.checked=0 then curtfstr=SwamiRSI_v1curtfedit.text
if SwamiRSI_v1autotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(SwamiRSI_v1(varptr(periodstr),varptr(curtfstr)))
end if

barsback=222 '<--- can also be something like VAL(SwamiRSI_v1barsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=DarkOrchid '<--- replace with your color
    bufnamestr="RSI3"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    sepindicolor(drawid)=Chocolate '<--- replace with your color
    bufnamestr="sumRSI"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    sepindicolor(drawid)=Black '<--- replace with your color
    bufnamestr="SwamiRSImin"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

    sepindicolor(drawid)=Black '<--- replace with your color
    bufnamestr="SwamiRSImax"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-22"             
        sepindivalmaxedit.text="22"        
end if

end if
'------------------------- End SwamiRSI_v1 -------------------------------------------------
'------------------------- threeD Oscilator -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=threeD_Oscilatorperiodedit.text
if threeD_Oscilatorautotf.checked=0 then curtfstr=threeD_Oscilatorcurtfedit.text
if threeD_Oscilatorautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(threeD_Oscilator(varptr(periodstr),varptr(curtfstr)))
end if

barsback=200 '<--- can also be something like VAL(threeD_Oscilatorbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=blue '<--- replace with your color
    bufnamestr="sig1n"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
    sepindicolor(drawid)=red '<--- replace with your color
    bufnamestr="sig2n"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End threeD Oscilator -------------------------------------------------
'------------------------- TSCD -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if TSCDautotf.checked=0 then curtfstr=TSCDcurtfedit.text
if TSCDautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(TSCD(varptr(curtfstr)))
end if

barsback=numbars '<--- can also be something like VAL(TSCDbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=red '<--- replace with your color
    bufnamestr="TSCDbuffer"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-1"             
        sepindivalmaxedit.text="1"        
end if

end if
'------------------------- End TSCD -------------------------------------------------
'------------------------- Value Chart -------------------------------------------------
indiid++
         
                    if indicatorslistsel.item(indiid)="x" then 
            
                        if lbar=1 then           
                            valuechart
                        end if

                         barsback=VAL(valuechartbarsbackedit.text)
                        
                    if ibar>=lastbar-barsback then
                        sepindicolor(drawid)=green
                        canvas.separateindicator1.Cell(drawid,lbar)= STR$(vo(offset))
			drawid=drawid+2
			sepindicolor(drawid)=red
                        canvas.separateindicator1.Cell(drawid,lbar)= STR$(vh(offset))
			drawid=drawid+2
			sepindicolor(drawid)=red
                        canvas.separateindicator1.Cell(drawid,lbar)= STR$(vb(offset))
			drawid=drawid+2
			sepindicolor(drawid)=purple
                        canvas.separateindicator1.Cell(drawid,lbar)= STR$(vc(offset))
			drawid=drawid+2
			sepindicolor(drawid)=gray
                        canvas.separateindicator1.Cell(drawid,lbar)= STR$(valuechartlevelup1(offset))
			drawid=drawid+2
			sepindicolor(drawid)=gray
                        canvas.separateindicator1.Cell(drawid,lbar)= STR$(valuechartlevelup2(offset))
			drawid=drawid+2
			sepindicolor(drawid)=gray
                        canvas.separateindicator1.Cell(drawid,lbar)= STR$(valuechartleveldn1(offset))
			drawid=drawid+2
			sepindicolor(drawid)=gray
                        canvas.separateindicator1.Cell(drawid,lbar)= STR$(valuechartleveldn2(offset))
			drawid=drawid+2
                                                                                                                                                                                  
                    end if
                    if autoadjustsepindi.checked=1 then     
                        sepindivalminedit.text="-4"             
                        sepindivalmaxedit.text="4"                             
                    end if
         
                end if                                  

        '------------------------- End Value Chart -------------------------------------------------
        '------------------------- Value Chart of ATR Channels -------------------------------------------------
indiid++
         
                    if indicatorslistsel.item(indiid)="x" then 
            
                        if lbar=1 then           
                            valuechartofatrchannels
                        end if

                         barsback=VAL(vcatrcbarsbackedit.text)                       

                    if ibar>=lastbar-barsback then
                        sepindicolor(drawid)=green
			canvas.separateindicator1.Cell(drawid,lbar)= STR$(vo3(offset))
			drawid=drawid+2
                        sepindicolor(drawid)=red
			canvas.separateindicator1.Cell(drawid,lbar)= STR$(vh3(offset))
			drawid=drawid+2
                        sepindicolor(drawid)=red
			canvas.separateindicator1.Cell(drawid,lbar)= STR$(vb3(offset))
			drawid=drawid+2
                        sepindicolor(drawid)=purple
			canvas.separateindicator1.Cell(drawid,lbar)= STR$(vc3(offset))
			drawid=drawid+2
                        sepindicolor(drawid)=gray
			canvas.separateindicator1.Cell(drawid,lbar)= STR$(valuechart3levelup1(offset))
			drawid=drawid+2
                        sepindicolor(drawid)=gray
			canvas.separateindicator1.Cell(drawid,lbar)= STR$(valuechart3levelup2(offset))
			drawid=drawid+2
                        sepindicolor(drawid)=gray
			canvas.separateindicator1.Cell(drawid,lbar)= STR$(valuechart3leveldn1(offset))
			drawid=drawid+2
                        sepindicolor(drawid)=gray
			canvas.separateindicator1.Cell(drawid,lbar)= STR$(valuechart3leveldn2(offset))
			drawid=drawid+2
                                                                                                                                                                                                            
                    end if
                    if autoadjustsepindi.checked=1 then        
                        sepindivalminedit.text="-4"             
                        sepindivalmaxedit.text="4"              
                    end if
                     
                end if                                  

        '------------------------- End Value Chart of ATR Channels  ------------------------------------------------- 
'------------------------- VWAP_Oscillator -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
periodstr=VWAP_Oscillatorperiodedit.text
if VWAP_Oscillatorautotf.checked=0 then curtfstr=VWAP_Oscillatorcurtfedit.text
if VWAP_Oscillatorautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(VWAP_Oscillator(varptr(periodstr),varptr(curtfstr)))
end if

barsback=222 '<--- can also be something like VAL(VWAP_Oscillatorbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=gold '<--- replace with your color
    bufnamestr="Daily"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2

sepindicolor(drawid)=red '<--- replace with your color
    bufnamestr="Weekly"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

end if
'------------------------- End VWAP_Oscillator -------------------------------------------------
'------------------------- Weighted WCCI -------------------------------------------------
indiid++
if indicatorslistsel.item(indiid)="x" then

if lbar=1 then
if Weighted_WCCIautotf.checked=0 then curtfstr=Weighted_WCCIcurrenttfedit.text
if Weighted_WCCIautotf.checked=1 then curtfstr=str$(charttf(displayedfile))
cpptmpfuncreturn=varptr$(Weighted_WCCI(varptr(curtfstr)))
end if

barsback=numbars '<--- can also be something like VAL(Weighted_WCCIbarsbackedit.text)

if ibar>=lastbar-barsback then
    sepindicolor(drawid)=Red '<--- replace with your color
    bufnamestr="WCCIExtMapBuffer1"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=DodgerBlue '<--- replace with your color
    bufnamestr="WCCIExtMapBuffer2"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=CadetBlue '<--- replace with your color
    bufnamestr="WCCIExtMapBuffer3"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=Red '<--- replace with your color
    bufnamestr="WCCIExtMapBuffer4"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=Red '<--- replace with your color
    bufnamestr="WCCIExtMapBuffer5"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=RoyalBlue '<--- replace with your color
    bufnamestr="WCCIExtMapBuffer6"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=RoyalBlue '<--- replace with your color
    bufnamestr="WCCIExtMapBuffer7"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
sepindicolor(drawid)=PaleGreen '<--- replace with your color
    bufnamestr="WCCIExtMapBuffer8"
    canvas.separateindicator1.Cell(drawid,lbar)= varptr$(getbufferdata(varptr(bufnamestr),varptr(offsetstr)))
    drawid=drawid+2
end if

if autoadjustsepindi.checked=1 then 
	sepindivalminedit.text="-33"             
        sepindivalmaxedit.text="33"        
end if

end if
'------------------------- End Weighted WCCI -------------------------------------------------
'-==================================== End Separate indicators area ==============================-

drawidseparatecanvas=drawid

IF l = 1 THEN
    sepindivalmin = VAL(canvas.separateindicator1.Cell(2 , lbar))
    sepindivalmax = VAL(canvas.separateindicator1.Cell(2 , lbar))
END IF

if i<=chartstart + .DATA.ColCount then

IF VAL(canvas.separateindicator1.Cell(2 , lbar)) < sepindivalmin THEN
    sepindivalmin = VAL(canvas.separateindicator1.Cell(2 , lbar))
END IF

IF VAL(canvas.separateindicator1.Cell(2 , lbar)) > sepindivalmax THEN
    sepindivalmax = VAL(canvas.separateindicator1.Cell(2 , lbar))
END IF

end if

END IF
'doevents
NEXT i

IF scrollmode = 0 THEN
    sepindivalmin = sepindivalmin + VAL(sepindivalminedit.Text)
    sepindivalmax = sepindivalmax + VAL(sepindivalmaxedit.Text)

    barsdisplayed2 = VAL(barsdisplayed.Text)
    canvas.initializechart2
    canvas.drawchart2
END IF


.YAxis.Min = valmin
.YAxis.Max = valmax

.DrawChart(FALSE) 'Draw it!

END WITH
graph.buffer.Font.Name = Font.Name
graph.buffer.Font.Size = Font.Size
canvas.BMP.Font.Name = Font.Name
canvas.BMP.Font.Size = Font.Size
scrollmodeofftimer.Enabled = TRUE
frmmain.Caption = "QChartist"

WITH graph
    .firstbufcntreset
    .savebuffertmp
    .paintchart
END WITH

IF scrollmode = 0 THEN
    
    graphcursorpos2

    DIM drawi AS INTEGER
    defdbl mytimeratio
    defdbl mypriceratio
    
    DIM graphhratio1 AS DOUBLE  
    DIM graphhratio2 AS DOUBLE
    DIM graphvratio1 AS DOUBLE 
    DIM graphvratio2 AS DOUBLE 

    FOR drawi = 1 TO val(maxnbofpersistobjectsedit.text)

        IF (VAL(trendlinesdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(trendlinesdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(trendlinesdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(trendlinesdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(trendlinesdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(trendlinesdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(trendlinesdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(trendlinesdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(trendlinesdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(trendlinesdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(trendlinesdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtrendlinex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(trendlinesdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(trendlinesdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(trendlinesdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtrendlinex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(trendlinesdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtrendliney1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(trendlinesdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtrendliney2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(0 , drawtrendlinex1 , drawtrendliney1 , drawtrendlinex2 , drawtrendliney2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(fibofandb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(fibofandb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(fibofandb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(fibofandb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(fibofandb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(fibofandb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(fibofandb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(fibofandb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(fibofandb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(fibofandb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibofandb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibofanx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(fibofandb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(fibofandb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibofandb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibofanx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(fibofandb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibofany1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(fibofandb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibofany2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(1 , drawfibofanx1 , drawfibofany1 , drawfibofanx2 , drawfibofany2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(fiboretdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(fiboretdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(fiboretdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(fiboretdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(fiboretdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(fiboretdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(fiboretdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(fiboretdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(fiboretdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(fiboretdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fiboretdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfiboretx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(fiboretdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(fiboretdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fiboretdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfiboretx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(fiboretdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfiborety1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(fiboretdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfiborety2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(2 , drawfiboretx1 , drawfiborety1 , drawfiboretx2 , drawfiborety2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(paradb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(paradb.Cell(4 , drawi)) <= graphserialdateend) AND _
            (VAL(paradb.Cell(5 , drawi)) >= graphserialdatebegin AND VAL(paradb.Cell(5 , drawi)) <= graphserialdateend) AND_
            (VAL(paradb.Cell(6 , drawi)) >= graphserialdatebegin AND VAL(paradb.Cell(6 , drawi)) <= graphserialdateend) AND_
            (VAL(paradb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(paradb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(paradb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(paradb.Cell(2 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(paradb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(paradb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(paradb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(paradb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(paradb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawparax1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(paradb.Cell(5 , drawi))>=timechartpos(i,0) and VAL(paradb.Cell(5 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(paradb.Cell(5 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawparax2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(paradb.Cell(6 , drawi))>=timechartpos(i,0) and VAL(paradb.Cell(6 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(paradb.Cell(6 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawparax3=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(paradb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawparay1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(paradb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawparay2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(paradb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawparay3=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(0 , drawparax1 , drawparay1 , drawparax2 , drawparay2 , 0 , 0)
            Graph.savebuffertmpsimplez
            graph.drawp(3 , drawparax1 , drawparay1 , drawparax3 , drawparay3 , drawparax2 , drawparay2)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(hlinedb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(hlinedb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(hlinedb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(hlinedb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(hlinedb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(hlinedb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(hlinedb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(hlinedb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(hlinedb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(hlinedb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(hlinedb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawhlinex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(hlinedb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(hlinedb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(hlinedb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawhlinex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(hlinedb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawhliney1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(hlinedb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawhliney2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(4 , drawhlinex1 , drawhliney1 , drawhlinex2 , drawhliney2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(vlinedb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(vlinedb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(vlinedb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(vlinedb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(vlinedb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(vlinedb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(vlinedb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(vlinedb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(vlinedb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(vlinedb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(vlinedb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawvlinex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(vlinedb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(vlinedb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(vlinedb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawvlinex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(vlinedb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawvliney1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(vlinedb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawvliney2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(5 , drawvlinex1 , drawvliney1 , drawvlinex2 , drawvliney2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(sqrdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(sqrdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(sqrdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(sqrdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(sqrdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(sqrdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(sqrdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(sqrdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(sqrdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(sqrdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sqrdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsqrx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(sqrdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(sqrdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sqrdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsqrx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(sqrdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsqry1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(sqrdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsqry2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(6 , drawsqrx1 , drawsqry1 , drawsqrx2 , drawsqry2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(tridb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(tridb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(tridb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(tridb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(tridb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(tridb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(tridb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(tridb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(tridb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(tridb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(tridb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtrix1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(tridb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(tridb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(tridb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtrix2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(tridb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtriy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(tridb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtriy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(7 , drawtrix1 , drawtriy1 , drawtrix2 , drawtriy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(circledb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(circledb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(circledb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(circledb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(circledb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(circledb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(circledb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(circledb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(circledb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(circledb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(circledb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawcirclex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(circledb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(circledb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(circledb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawcirclex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(circledb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawcircley1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(circledb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawcircley2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(8 , drawcirclex1 , drawcircley1 , drawcirclex2 , drawcircley2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(crossdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(crossdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(crossdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(crossdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(crossdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(crossdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(crossdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(crossdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(crossdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(crossdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(crossdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawcrossx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(crossdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(crossdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(crossdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawcrossx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(crossdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawcrossy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(crossdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawcrossy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(9 , drawcrossx1 , drawcrossy1 , drawcrossx2 , drawcrossy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(invcircledb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(invcircledb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(invcircledb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(invcircledb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(invcircledb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(invcircledb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(invcircledb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(invcircledb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(invcircledb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(invcircledb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(invcircledb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawinvcirclex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(invcircledb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(invcircledb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(invcircledb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawinvcirclex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(invcircledb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawinvcircley1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(invcircledb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawinvcircley2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(10 , drawinvcirclex1 , drawinvcircley1 , drawinvcirclex2 , drawinvcircley2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(aimingdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(aimingdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(aimingdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(aimingdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(aimingdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(aimingdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(aimingdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(aimingdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(aimingdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(aimingdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(aimingdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawaimingx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(aimingdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(aimingdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(aimingdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawaimingx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(aimingdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawaimingy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(aimingdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawaimingy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(11 , drawaimingx1 , drawaimingy1 , drawaimingx2 , drawaimingy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(sindb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(sindb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(sindb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(sindb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(sindb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(sindb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(sindb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(sindb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(sindb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(sindb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sindb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsinx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(sindb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(sindb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sindb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsinx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(sindb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsiny1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(sindb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsiny2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(13 , drawsinx1 , drawsiny1 , drawsinx2 , drawsiny2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(logdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(logdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(logdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(logdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(logdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(logdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(logdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(logdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(logdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(logdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(logdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawlogx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(logdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(logdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(logdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawlogx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(logdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawlogy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(logdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawlogy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(14 , drawlogx1 , drawlogy1 , drawlogx2 , drawlogy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(expdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(expdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(expdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(expdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(expdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(expdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(expdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(expdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(expdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(expdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(expdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawexpx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(expdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(expdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(expdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawexpx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(expdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawexpy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(expdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawexpy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(15 , drawexpx1 , drawexpy1 , drawexpx2 , drawexpy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(ellipsedb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(ellipsedb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(ellipsedb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(ellipsedb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(ellipsedb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(ellipsedb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(ellipsedb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(ellipsedb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(ellipsedb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(ellipsedb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(ellipsedb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawellipsex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(ellipsedb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(ellipsedb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(ellipsedb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawellipsex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(ellipsedb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawellipsey1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(ellipsedb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawellipsey2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(16 , drawellipsex1 , drawellipsey1 , drawellipsex2 , drawellipsey2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(ellipse3db.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(ellipse3db.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(ellipse3db.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(ellipse3db.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(ellipse3db.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(ellipse3db.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(ellipse3db.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(ellipse3db.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(ellipse3db.Cell(3 , drawi))>=timechartpos(i,0) and VAL(ellipse3db.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(ellipse3db.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawellipse3x1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(ellipse3db.Cell(4 , drawi))>=timechartpos(i,0) and VAL(ellipse3db.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(ellipse3db.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawellipse3x2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(ellipse3db.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawellipse3y1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(ellipse3db.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawellipse3y2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(44 , drawellipse3x1 , drawellipse3y1 , drawellipse3x2 , drawellipse3y2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(pentagdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(pentagdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(pentagdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(pentagdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(pentagdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(pentagdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(pentagdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(pentagdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(pentagdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(pentagdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(pentagdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpentagx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(pentagdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(pentagdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(pentagdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpentagx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(pentagdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpentagy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(pentagdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpentagy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(27 , drawpentagx1 , drawpentagy1 , drawpentagx2 , drawpentagy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(sq9fdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(sq9fdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(sq9fdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(sq9fdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(sq9fdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(sq9fdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(sq9fdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(sq9fdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(sq9fdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(sq9fdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sq9fdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsq9fx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(sq9fdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(sq9fdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sq9fdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsq9fx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(sq9fdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsq9fy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(sq9fdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsq9fy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(19 , drawsq9fx1 , drawsq9fy1 , drawsq9fx2 , drawsq9fy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

	IF (VAL(sq144fdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(sq144fdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(sq144fdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(sq144fdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(sq144fdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(sq144fdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(sq144fdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(sq144fdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(sq144fdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(sq144fdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sq144fdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsq144fx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(sq144fdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(sq144fdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sq144fdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsq144fx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(sq144fdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsq144fy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(sq144fdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsq144fy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(20 , drawsq144fx1 , drawsq144fy1 , drawsq144fx2 , drawsq144fy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(sqr2db.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(sqr2db.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(sqr2db.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(sqr2db.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(sqr2db.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(sqr2db.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(sqr2db.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(sqr2db.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(sqr2db.Cell(3 , drawi))>=timechartpos(i,0) and VAL(sqr2db.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sqr2db.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsqr2x1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(sqr2db.Cell(4 , drawi))>=timechartpos(i,0) and VAL(sqr2db.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(sqr2db.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawsqr2x2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(sqr2db.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsqr2y1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(sqr2db.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawsqr2y2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(31 , drawsqr2x1 , drawsqr2y1 , drawsqr2x2 , drawsqr2y2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(tri2db.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(tri2db.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(tri2db.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(tri2db.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(tri2db.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(tri2db.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(tri2db.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(tri2db.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(tri2db.Cell(3 , drawi))>=timechartpos(i,0) and VAL(tri2db.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(tri2db.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtri2x1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(tri2db.Cell(4 , drawi))>=timechartpos(i,0) and VAL(tri2db.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(tri2db.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtri2x2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(tri2db.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtri2y1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(tri2db.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtri2y2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(32 , drawtri2x1 , drawtri2y1 , drawtri2x2 , drawtri2y2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(orderbuydb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(orderbuydb.Cell(3 , drawi)) <= graphserialdateend+charttf(displayedfile)*60) AND _            
            (VAL(orderbuydb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(orderbuydb.Cell(1 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(orderbuydb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(orderbuydb.Cell(3 , drawi))<=timechartpos(i+1,0)+charttf(displayedfile)*60 then
            mytimeratio=(VAL(orderbuydb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint draworderbuyx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i            
            
            mypriceratio=(VAL(orderbuydb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint draworderbuyy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)            

            graph.drawp(34 , draworderbuyx1 , draworderbuyy1 , 0 , 0 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(orderselldb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(orderselldb.Cell(3 , drawi)) <= graphserialdateend+charttf(displayedfile)*60) AND _            
            (VAL(orderselldb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(orderselldb.Cell(1 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(orderselldb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(orderselldb.Cell(3 , drawi))<=timechartpos(i+1,0)+charttf(displayedfile)*60 then
            mytimeratio=(VAL(orderselldb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawordersellx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i            
            
            mypriceratio=(VAL(orderselldb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint draworderselly1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)            

            graph.drawp(35 , drawordersellx1 , draworderselly1 , 0 , 0 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(textlabelsdb.Cell(2 , drawi)) >= graphserialdatebegin AND VAL(textlabelsdb.Cell(2 , drawi)) <= graphserialdateend+charttf(displayedfile)*60) AND _            
            (VAL(textlabelsdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(textlabelsdb.Cell(1 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(textlabelsdb.Cell(2 , drawi))>=timechartpos(i,0) and VAL(textlabelsdb.Cell(2 , drawi))<=timechartpos(i+1,0)+charttf(displayedfile)*60 then
            mytimeratio=(VAL(textlabelsdb.Cell(2 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtextlabelsx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i            
            
            mypriceratio=(VAL(textlabelsdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtextlabelsy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)            

            Graph.buffer.TextOut(drawtextlabelsx1 , drawtextlabelsy1 , textlabelsdb.Cell(3 , drawi) , val(textlabelsdb.Cell(4 , drawi)) , val(textlabelsdb.Cell(6 , drawi)))

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(arrowsdb.Cell(2 , drawi)) >= graphserialdatebegin AND VAL(arrowsdb.Cell(2 , drawi)) <= graphserialdateend+charttf(displayedfile)*60) AND _            
            (VAL(arrowsdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(arrowsdb.Cell(1 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(arrowsdb.Cell(2 , drawi))>=timechartpos(i,0) and VAL(arrowsdb.Cell(2 , drawi))<=timechartpos(i+1,0)+charttf(displayedfile)*60 then
            mytimeratio=(VAL(arrowsdb.Cell(2 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawarrowsx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i            
            
            mypriceratio=(VAL(arrowsdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawarrowsy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)            
     
            dim arrowsfont as qfont
            arrowsfont.name="Wingdings" 
            arrowsfont.size=12
            dim arialfont as qfont
            arialfont.name="Arial" 
            arialfont.size=9
            arialfont.color=textcolor
            Graph.buffer.font=arrowsfont
            Graph.buffer.TextOut(drawarrowsx1 , drawarrowsy1 , arrowsdb.Cell(3 , drawi) , val(arrowsdb.Cell(4 , drawi)) , val(arrowsdb.Cell(6 , drawi)))
            Graph.buffer.font=arialfont

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(vectortextdb.Cell(2 , drawi)) >= graphserialdatebegin AND VAL(vectortextdb.Cell(2 , drawi)) <= graphserialdateend+charttf(displayedfile)*60) AND _            
            (VAL(vectortextdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(vectortextdb.Cell(1 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(vectortextdb.Cell(2 , drawi))>=timechartpos(i,0) and VAL(vectortextdb.Cell(2 , drawi))<=timechartpos(i+1,0)+charttf(displayedfile)*60 then
            mytimeratio=(VAL(vectortextdb.Cell(2 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawvectortextsx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i            
            
            mypriceratio=(VAL(vectortextdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawvectortextsy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)            

            'Graph.buffer.TextOut(drawvectortextsx1 , drawvectortextsy1 , vectortextdb.Cell(3 , drawi) , val(vectortextdb.Cell(4 , drawi)) , val(vectortextdb.Cell(6 , drawi)))
            VPrintAng drawvectortextsx1, drawvectortextsy1, vectortextdb.Cell(3 , drawi), val(vectortextdb.Cell(4 , drawi)), val(vectortextdb.Cell(7 , drawi)), val(vectortextdb.Cell(8 , drawi)), val(vectortextdb.Cell(9 , drawi)), 0
            '(xx as integer, yy as integer, text$ as string, clr as integer, xf as integer, yf as integer, angle as double, canvas as integer)

            graph.savebuffertmp
            graph.paintchart

        END IF

	IF (VAL(griddb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(griddb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(griddb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(griddb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(griddb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(griddb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(griddb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(griddb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(griddb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(griddb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(griddb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawgridx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(griddb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(griddb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(griddb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawgridx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(griddb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawgridy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(griddb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawgridy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(37 , drawgridx1 , drawgridy1 , drawgridx2 , drawgridy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
    IF (VAL(speedresdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(speedresdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(speedresdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(speedresdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(speedresdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(speedresdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(speedresdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(speedresdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(speedresdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(speedresdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(speedresdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawspeedresx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(speedresdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(speedresdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(speedresdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawspeedresx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(speedresdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawspeedresy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(speedresdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawspeedresy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(38 , drawspeedresx1 , drawspeedresy1 , drawspeedresx2 , drawspeedresy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(fiboarcsdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(fiboarcsdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(fiboarcsdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(fiboarcsdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(fiboarcsdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(fiboarcsdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(fiboarcsdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(fiboarcsdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(fiboarcsdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(fiboarcsdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fiboarcsdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfiboarcsx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(fiboarcsdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(fiboarcsdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fiboarcsdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfiboarcsx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(fiboarcsdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfiboarcsy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(fiboarcsdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfiboarcsy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(39 , drawfiboarcsx1 , drawfiboarcsy1 , drawfiboarcsx2 , drawfiboarcsy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
	IF (VAL(seedoflifedb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(seedoflifedb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(seedoflifedb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(seedoflifedb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(seedoflifedb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(seedoflifedb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(seedoflifedb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(seedoflifedb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(seedoflifedb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(seedoflifedb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(seedoflifedb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawseedoflifex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(seedoflifedb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(seedoflifedb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(seedoflifedb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawseedoflifex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(seedoflifedb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawseedoflifey1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(seedoflifedb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawseedoflifey2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(40 , drawseedoflifex1 , drawseedoflifey1 , drawseedoflifex2 , drawseedoflifey2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
	
	IF (VAL(pricecyclesdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(pricecyclesdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(pricecyclesdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(pricecyclesdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(pricecyclesdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(pricecyclesdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(pricecyclesdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(pricecyclesdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(pricecyclesdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(pricecyclesdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(pricecyclesdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpricecyclesx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(pricecyclesdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(pricecyclesdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(pricecyclesdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpricecyclesx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(pricecyclesdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpricecyclesy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(pricecyclesdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpricecyclesy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(24 , drawpricecyclesx1 , drawpricecyclesy1 , drawpricecyclesx2 , drawpricecyclesy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

	IF (VAL(timecyclesdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(timecyclesdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(timecyclesdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(timecyclesdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(timecyclesdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(timecyclesdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(timecyclesdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(timecyclesdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(timecyclesdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(timecyclesdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(timecyclesdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtimecyclesx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(timecyclesdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(timecyclesdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(timecyclesdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtimecyclesx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(timecyclesdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtimecyclesy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(timecyclesdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtimecyclesy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(25 , drawtimecyclesx1 , drawtimecyclesy1 , drawtimecyclesx2 , drawtimecyclesy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

	IF (VAL(gannsquaredb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(gannsquaredb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(gannsquaredb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(gannsquaredb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(gannsquaredb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(gannsquaredb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(gannsquaredb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(gannsquaredb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(gannsquaredb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(gannsquaredb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(gannsquaredb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawgannsquarex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(gannsquaredb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(gannsquaredb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(gannsquaredb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawgannsquarex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(gannsquaredb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawgannsquarey1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(gannsquaredb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawgannsquarey2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(41 , drawgannsquarex1 , drawgannsquarey1 , drawgannsquarex2 , drawgannsquarey2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

	IF (VAL(fibospiraldb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(fibospiraldb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(fibospiraldb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(fibospiraldb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(fibospiraldb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(fibospiraldb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(fibospiraldb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(fibospiraldb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(fibospiraldb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(fibospiraldb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibospiraldb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibospiralx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(fibospiraldb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(fibospiraldb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibospiraldb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibospiralx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(fibospiraldb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibospiraly1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(fibospiraldb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibospiraly2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(42 , drawfibospiralx1 , drawfibospiraly1 , drawfibospiralx2 , drawfibospiraly2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

	IF (VAL(archimedspiraldb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(archimedspiraldb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(archimedspiraldb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(archimedspiraldb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(archimedspiraldb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(archimedspiraldb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(archimedspiraldb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(archimedspiraldb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(archimedspiraldb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(archimedspiraldb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(archimedspiraldb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawarchimedspiralx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(archimedspiraldb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(archimedspiraldb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(archimedspiraldb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawarchimedspiralx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(archimedspiraldb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawarchimedspiraly1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(archimedspiraldb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawarchimedspiraly2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(43 , drawarchimedspiralx1 , drawarchimedspiraly1 , drawarchimedspiralx2 , drawarchimedspiraly2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
    IF (VAL(fibocirclesdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(fibocirclesdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(fibocirclesdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(fibocirclesdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(fibocirclesdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(fibocirclesdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(fibocirclesdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(fibocirclesdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(fibocirclesdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(fibocirclesdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibocirclesdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibocirclesx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(fibocirclesdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(fibocirclesdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibocirclesdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibocirclesx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(fibocirclesdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibocirclesy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(fibocirclesdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibocirclesy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(48 , drawfibocirclesx1 , drawfibocirclesy1 , drawfibocirclesx2 , drawfibocirclesy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
    IF (VAL(timerulerdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(timerulerdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(timerulerdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(timerulerdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(timerulerdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(timerulerdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(timerulerdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(timerulerdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(timerulerdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(timerulerdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(timerulerdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtimerulerx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(timerulerdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(timerulerdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(timerulerdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtimerulerx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(timerulerdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtimerulery1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(timerulerdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtimerulery2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(49 , drawtimerulerx1 , drawtimerulery1 , drawtimerulerx2 , drawtimerulery2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
    IF (VAL(pricerulerdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(pricerulerdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(pricerulerdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(pricerulerdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(pricerulerdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(pricerulerdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(pricerulerdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(pricerulerdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(pricerulerdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(pricerulerdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(pricerulerdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpricerulerx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(pricerulerdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(pricerulerdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(pricerulerdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpricerulerx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(pricerulerdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpricerulery1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(pricerulerdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpricerulery2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(50 , drawpricerulerx1 , drawpricerulery1 , drawpricerulerx2 , drawpricerulery2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF

        IF (VAL(fillregiondb.Cell(2 , drawi)) >= graphserialdatebegin AND VAL(fillregiondb.Cell(2 , drawi)) <= graphserialdateend) AND _
            (VAL(fillregiondb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(fillregiondb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(fillregiondb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(fillregiondb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(fillregiondb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(fillregiondb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(fillregiondb.Cell(2 , drawi))>=timechartpos(i,0) and VAL(fillregiondb.Cell(2 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fillregiondb.Cell(2 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfillregionx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(fillregiondb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(fillregiondb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fillregiondb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfillregionx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(fillregiondb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfillregiony1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(fillregiondb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfillregiony2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(51 , drawfillregionx1 , drawfillregiony1 , drawfillregionx2 , drawfillregiony2 , val(fillregiondb.Cell(5 , drawi)) , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(speedresarcsdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(speedresarcsdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(speedresarcsdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(speedresarcsdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(speedresarcsdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(speedresarcsdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(speedresarcsdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(speedresarcsdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp
                       
            for i=0 to 1000
            if VAL(speedresarcsdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(speedresarcsdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(speedresarcsdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawspeedresarcsx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(speedresarcsdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(speedresarcsdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(speedresarcsdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawspeedresarcsx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(speedresarcsdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawspeedresarcsy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(speedresarcsdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawspeedresarcsy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(52 , drawspeedresarcsx1 , drawspeedresarcsy1 , drawspeedresarcsx2 , drawspeedresarcsy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(gannfandb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(gannfandb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(gannfandb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(gannfandb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(gannfandb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(gannfandb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(gannfandb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(gannfandb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(gannfandb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(gannfandb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(gannfandb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawgannfanx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(gannfandb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(gannfandb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(gannfandb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawgannfanx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(gannfandb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawgannfany1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(gannfandb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawgannfany2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(54 , drawgannfanx1 , drawgannfany1 , drawgannfanx2 , drawgannfany2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(gannboxdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(gannboxdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(gannboxdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(gannboxdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(gannboxdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(gannboxdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(gannboxdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(gannboxdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(gannboxdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(gannboxdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(gannboxdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawgannboxx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(gannboxdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(gannboxdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(gannboxdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawgannboxx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(gannboxdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawgannboxy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(gannboxdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawgannboxy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(55 , drawgannboxx1 , drawgannboxy1 , drawgannboxx2 , drawgannboxy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(triangledb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(triangledb.Cell(4 , drawi)) <= graphserialdateend) AND _
            (VAL(triangledb.Cell(5 , drawi)) >= graphserialdatebegin AND VAL(triangledb.Cell(5 , drawi)) <= graphserialdateend) AND_
            (VAL(triangledb.Cell(6 , drawi)) >= graphserialdatebegin AND VAL(triangledb.Cell(6 , drawi)) <= graphserialdateend) AND_
            (VAL(triangledb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(triangledb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(triangledb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(triangledb.Cell(2 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(triangledb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(triangledb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(triangledb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(triangledb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(triangledb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtrianglex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(triangledb.Cell(5 , drawi))>=timechartpos(i,0) and VAL(triangledb.Cell(5 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(triangledb.Cell(5 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtrianglex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(triangledb.Cell(6 , drawi))>=timechartpos(i,0) and VAL(triangledb.Cell(6 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(triangledb.Cell(6 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtrianglex3=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(triangledb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtriangley1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(triangledb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtriangley2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(triangledb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtriangley3=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
                        
            graph.drawp(0 , drawtrianglex1 , drawtriangley1 , drawtrianglex2 , drawtriangley2 , 0 , 0)
            Graph.savebuffertmpsimplez
            graph.drawp(56 , drawtrianglex1 , drawtriangley1 , drawtrianglex3 , drawtriangley3 , drawtrianglex2 , drawtriangley2)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(rectangledb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(rectangledb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(rectangledb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(rectangledb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(rectangledb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(rectangledb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(rectangledb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(rectangledb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(rectangledb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(rectangledb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(rectangledb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawrectanglex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(rectangledb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(rectangledb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(rectangledb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawrectanglex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(rectangledb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawrectangley1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(rectangledb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawrectangley2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(57 , drawrectanglex1 , drawrectangley1 , drawrectanglex2 , drawrectangley2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(diamonddb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(diamonddb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(diamonddb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(diamonddb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(diamonddb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(diamonddb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(diamonddb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(diamonddb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(diamonddb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(diamonddb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(diamonddb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawdiamondx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(diamonddb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(diamonddb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(diamonddb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawdiamondx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(diamonddb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawdiamondy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(diamonddb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawdiamondy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(58 , drawdiamondx1 , drawdiamondy1 , drawdiamondx2 , drawdiamondy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(rotatedrectangledb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(rotatedrectangledb.Cell(4 , drawi)) <= graphserialdateend) AND _
            (VAL(rotatedrectangledb.Cell(5 , drawi)) >= graphserialdatebegin AND VAL(rotatedrectangledb.Cell(5 , drawi)) <= graphserialdateend) AND_
            (VAL(rotatedrectangledb.Cell(6 , drawi)) >= graphserialdatebegin AND VAL(rotatedrectangledb.Cell(6 , drawi)) <= graphserialdateend) AND_
            (VAL(rotatedrectangledb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(rotatedrectangledb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(rotatedrectangledb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(rotatedrectangledb.Cell(2 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(rotatedrectangledb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(rotatedrectangledb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(rotatedrectangledb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(rotatedrectangledb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(rotatedrectangledb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawrotatedrectanglex1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(rotatedrectangledb.Cell(5 , drawi))>=timechartpos(i,0) and VAL(rotatedrectangledb.Cell(5 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(rotatedrectangledb.Cell(5 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawrotatedrectanglex2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(rotatedrectangledb.Cell(6 , drawi))>=timechartpos(i,0) and VAL(rotatedrectangledb.Cell(6 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(rotatedrectangledb.Cell(6 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawrotatedrectanglex3=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(rotatedrectangledb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawrotatedrectangley1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(rotatedrectangledb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawrotatedrectangley2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(rotatedrectangledb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawrotatedrectangley3=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
                        
            graph.drawp(0 , drawrotatedrectanglex1 , drawrotatedrectangley1 , drawrotatedrectanglex2 , drawrotatedrectangley2 , 0 , 0)
            Graph.savebuffertmpsimplez
            graph.drawp(59 , drawrotatedrectanglex1 , drawrotatedrectangley1 , drawrotatedrectanglex3 , drawrotatedrectangley3 , drawrotatedrectanglex2 , drawrotatedrectangley2)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(pitchforkdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(pitchforkdb.Cell(4 , drawi)) <= graphserialdateend) AND _
            (VAL(pitchforkdb.Cell(5 , drawi)) >= graphserialdatebegin AND VAL(pitchforkdb.Cell(5 , drawi)) <= graphserialdateend) AND_
            (VAL(pitchforkdb.Cell(6 , drawi)) >= graphserialdatebegin AND VAL(pitchforkdb.Cell(6 , drawi)) <= graphserialdateend) AND_
            (VAL(pitchforkdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(pitchforkdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(pitchforkdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(pitchforkdb.Cell(2 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(pitchforkdb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(pitchforkdb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(pitchforkdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(pitchforkdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(pitchforkdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpitchforkx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(pitchforkdb.Cell(5 , drawi))>=timechartpos(i,0) and VAL(pitchforkdb.Cell(5 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(pitchforkdb.Cell(5 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpitchforkx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(pitchforkdb.Cell(6 , drawi))>=timechartpos(i,0) and VAL(pitchforkdb.Cell(6 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(pitchforkdb.Cell(6 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpitchforkx3=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(pitchforkdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpitchforky1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(pitchforkdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpitchforky2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(pitchforkdb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpitchforky3=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
                        
            graph.drawp(0 , drawpitchforkx1 , drawpitchforky1 , drawpitchforkx2 , drawpitchforky2 , 0 , 0)
            Graph.savebuffertmpsimplez
            graph.drawp(17 , drawpitchforkx1 , drawpitchforky1 , drawpitchforkx3 , drawpitchforky3 , drawpitchforkx2 , drawpitchforky2)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(priceextdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(priceextdb.Cell(4 , drawi)) <= graphserialdateend) AND _
            (VAL(priceextdb.Cell(5 , drawi)) >= graphserialdatebegin AND VAL(priceextdb.Cell(5 , drawi)) <= graphserialdateend) AND_
            (VAL(priceextdb.Cell(6 , drawi)) >= graphserialdatebegin AND VAL(priceextdb.Cell(6 , drawi)) <= graphserialdateend) AND_
            (VAL(priceextdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(priceextdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(priceextdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(priceextdb.Cell(2 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(priceextdb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(priceextdb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(priceextdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(priceextdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(priceextdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpriceextx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(priceextdb.Cell(5 , drawi))>=timechartpos(i,0) and VAL(priceextdb.Cell(5 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(priceextdb.Cell(5 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpriceextx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(priceextdb.Cell(6 , drawi))>=timechartpos(i,0) and VAL(priceextdb.Cell(6 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(priceextdb.Cell(6 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpriceextx3=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(priceextdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpriceexty1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(priceextdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpriceexty2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(priceextdb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpriceexty3=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
                        
            graph.drawp(0 , drawpriceextx1 , drawpriceexty1 , drawpriceextx2 , drawpriceexty2 , 0 , 0)
            Graph.savebuffertmpsimplez
            graph.drawp(18 , drawpriceextx1 , drawpriceexty1 , drawpriceextx3 , drawpriceexty3 , drawpriceextx2 , drawpriceexty2)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(timeextdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(timeextdb.Cell(4 , drawi)) <= graphserialdateend) AND _
            (VAL(timeextdb.Cell(5 , drawi)) >= graphserialdatebegin AND VAL(timeextdb.Cell(5 , drawi)) <= graphserialdateend) AND_
            (VAL(timeextdb.Cell(6 , drawi)) >= graphserialdatebegin AND VAL(timeextdb.Cell(6 , drawi)) <= graphserialdateend) AND_
            (VAL(timeextdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(timeextdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(timeextdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(timeextdb.Cell(2 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(timeextdb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(timeextdb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(timeextdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(timeextdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(timeextdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtimeextx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(timeextdb.Cell(5 , drawi))>=timechartpos(i,0) and VAL(timeextdb.Cell(5 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(timeextdb.Cell(5 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtimeextx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(timeextdb.Cell(6 , drawi))>=timechartpos(i,0) and VAL(timeextdb.Cell(6 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(timeextdb.Cell(6 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawtimeextx3=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(timeextdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtimeexty1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(timeextdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtimeexty2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(timeextdb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawtimeexty3=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
                        
            graph.drawp(0 , drawtimeextx1 , drawtimeexty1 , drawtimeextx2 , drawtimeexty2 , 0 , 0)
            Graph.savebuffertmpsimplez
            graph.drawp(21 , drawtimeextx1 , drawtimeexty1 , drawtimeextx3 , drawtimeexty3 , drawtimeextx2 , drawtimeexty2)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(orcyclesdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(orcyclesdb.Cell(4 , drawi)) <= graphserialdateend) AND _
            (VAL(orcyclesdb.Cell(5 , drawi)) >= graphserialdatebegin AND VAL(orcyclesdb.Cell(5 , drawi)) <= graphserialdateend) AND_
            (VAL(orcyclesdb.Cell(6 , drawi)) >= graphserialdatebegin AND VAL(orcyclesdb.Cell(6 , drawi)) <= graphserialdateend) AND_
            (VAL(orcyclesdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(orcyclesdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(orcyclesdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(orcyclesdb.Cell(2 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(orcyclesdb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(orcyclesdb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(orcyclesdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(orcyclesdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(orcyclesdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint draworcyclesx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(orcyclesdb.Cell(5 , drawi))>=timechartpos(i,0) and VAL(orcyclesdb.Cell(5 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(orcyclesdb.Cell(5 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint draworcyclesx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(orcyclesdb.Cell(6 , drawi))>=timechartpos(i,0) and VAL(orcyclesdb.Cell(6 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(orcyclesdb.Cell(6 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint draworcyclesx3=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(orcyclesdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint draworcyclesy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(orcyclesdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint draworcyclesy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(orcyclesdb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint draworcyclesy3=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
                        
            graph.drawp(0 , draworcyclesx1 , draworcyclesy1 , draworcyclesx2 , draworcyclesy2 , 0 , 0)
            Graph.savebuffertmpsimplez
            graph.drawp(28 , draworcyclesx1 , draworcyclesy1 , draworcyclesx3 , draworcyclesy3 , draworcyclesx2 , draworcyclesy2)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(schiffpitchforkdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(schiffpitchforkdb.Cell(4 , drawi)) <= graphserialdateend) AND _
            (VAL(schiffpitchforkdb.Cell(5 , drawi)) >= graphserialdatebegin AND VAL(schiffpitchforkdb.Cell(5 , drawi)) <= graphserialdateend) AND_
            (VAL(schiffpitchforkdb.Cell(6 , drawi)) >= graphserialdatebegin AND VAL(schiffpitchforkdb.Cell(6 , drawi)) <= graphserialdateend) AND_
            (VAL(schiffpitchforkdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(schiffpitchforkdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(schiffpitchforkdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(schiffpitchforkdb.Cell(2 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(schiffpitchforkdb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(schiffpitchforkdb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(schiffpitchforkdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(schiffpitchforkdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(schiffpitchforkdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawschiffpitchforkx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(schiffpitchforkdb.Cell(5 , drawi))>=timechartpos(i,0) and VAL(schiffpitchforkdb.Cell(5 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(schiffpitchforkdb.Cell(5 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawschiffpitchforkx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(schiffpitchforkdb.Cell(6 , drawi))>=timechartpos(i,0) and VAL(schiffpitchforkdb.Cell(6 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(schiffpitchforkdb.Cell(6 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawschiffpitchforkx3=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(schiffpitchforkdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawschiffpitchforky1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(schiffpitchforkdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawschiffpitchforky2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(schiffpitchforkdb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawschiffpitchforky3=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
                        
            graph.drawp(0 , drawschiffpitchforkx1 , drawschiffpitchforky1 , drawschiffpitchforkx2 , drawschiffpitchforky2 , 0 , 0)
            Graph.savebuffertmpsimplez
            graph.drawp(53 , drawschiffpitchforkx1 , drawschiffpitchforky1 , drawschiffpitchforkx3 , drawschiffpitchforky3 , drawschiffpitchforkx2 , drawschiffpitchforky2)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(circlegiven3pointsdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(circlegiven3pointsdb.Cell(4 , drawi)) <= graphserialdateend) AND _
            (VAL(circlegiven3pointsdb.Cell(5 , drawi)) >= graphserialdatebegin AND VAL(circlegiven3pointsdb.Cell(5 , drawi)) <= graphserialdateend) AND_
            (VAL(circlegiven3pointsdb.Cell(6 , drawi)) >= graphserialdatebegin AND VAL(circlegiven3pointsdb.Cell(6 , drawi)) <= graphserialdateend) AND_
            (VAL(circlegiven3pointsdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(circlegiven3pointsdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(circlegiven3pointsdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(circlegiven3pointsdb.Cell(2 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(circlegiven3pointsdb.Cell(3 , drawi)) >= pricechartpos(0,0) AND VAL(circlegiven3pointsdb.Cell(3 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(circlegiven3pointsdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(circlegiven3pointsdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(circlegiven3pointsdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawcirclegiven3pointsx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(circlegiven3pointsdb.Cell(5 , drawi))>=timechartpos(i,0) and VAL(circlegiven3pointsdb.Cell(5 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(circlegiven3pointsdb.Cell(5 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawcirclegiven3pointsx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(circlegiven3pointsdb.Cell(6 , drawi))>=timechartpos(i,0) and VAL(circlegiven3pointsdb.Cell(6 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(circlegiven3pointsdb.Cell(6 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawcirclegiven3pointsx3=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(circlegiven3pointsdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawcirclegiven3pointsy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(circlegiven3pointsdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawcirclegiven3pointsy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(circlegiven3pointsdb.Cell(3 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawcirclegiven3pointsy3=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
                        
            'graph.drawp(0 , drawcirclegiven3pointsx1 , drawcirclegiven3pointsy1 , drawcirclegiven3pointsx2 , drawcirclegiven3pointsy2 , 0 , 0)
            
            circlegiven3pointsx(1)=drawcirclegiven3pointsx1
            circlegiven3pointsy(1)=drawcirclegiven3pointsy1
            circlegiven3pointsx(2)=drawcirclegiven3pointsx2
            circlegiven3pointsy(2)=drawcirclegiven3pointsy2
            circlegiven3pointsx(3)=drawcirclegiven3pointsx3
            circlegiven3pointsy(3)=drawcirclegiven3pointsy3
            circlegiven3pointsclicknb=3            
            
            Graph.savebuffertmpsimplez
            graph.drawp(45 , drawcirclegiven3pointsx1 , drawcirclegiven3pointsy1 , drawcirclegiven3pointsx3 , drawcirclegiven3pointsy3 , drawcirclegiven3pointsx2 , drawcirclegiven3pointsy2)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(logspiraldb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(logspiraldb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(logspiraldb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(logspiraldb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(logspiraldb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(logspiraldb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(logspiraldb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(logspiraldb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(logspiraldb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(logspiraldb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(logspiraldb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawlogspiralx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(logspiraldb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(logspiraldb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(logspiraldb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawlogspiralx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(logspiraldb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawlogspiraly1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(logspiraldb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawlogspiraly2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(26 , drawlogspiralx1 , drawlogspiraly1 , drawlogspiralx2 , drawlogspiraly2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(polygdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(polygdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(polygdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(polygdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(polygdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(polygdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(polygdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(polygdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(polygdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(polygdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(polygdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpolygx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(polygdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(polygdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(polygdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawpolygx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(polygdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpolygy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(polygdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawpolygy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(29 , drawpolygx1 , drawpolygy1 , drawpolygx2 , drawpolygy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(fibotimezonesdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(fibotimezonesdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(fibotimezonesdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(fibotimezonesdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(fibotimezonesdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(fibotimezonesdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(fibotimezonesdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(fibotimezonesdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(fibotimezonesdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(fibotimezonesdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibotimezonesdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibotimezonesx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(fibotimezonesdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(fibotimezonesdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibotimezonesdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibotimezonesx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(fibotimezonesdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibotimezonesy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(fibotimezonesdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibotimezonesy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(46 , drawfibotimezonesx1 , drawfibotimezonesy1 , drawfibotimezonesx2 , drawfibotimezonesy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        IF (VAL(fibopricezonesdb.Cell(3 , drawi)) >= graphserialdatebegin AND VAL(fibopricezonesdb.Cell(3 , drawi)) <= graphserialdateend) AND _
            (VAL(fibopricezonesdb.Cell(4 , drawi)) >= graphserialdatebegin AND VAL(fibopricezonesdb.Cell(4 , drawi)) <= graphserialdateend) AND_
            (VAL(fibopricezonesdb.Cell(1 , drawi)) >= pricechartpos(0,0) AND VAL(fibopricezonesdb.Cell(1 , drawi)) <= pricechartpos(1,0)) AND_
            (VAL(fibopricezonesdb.Cell(2 , drawi)) >= pricechartpos(0,0) AND VAL(fibopricezonesdb.Cell(2 , drawi)) <= pricechartpos(1,0)) THEN

            graph.bufcntreset
            graph.savebuffertmp

            for i=0 to 1000
            if VAL(fibopricezonesdb.Cell(3 , drawi))>=timechartpos(i,0) and VAL(fibopricezonesdb.Cell(3 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibopricezonesdb.Cell(3 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibopricezonesx1=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            for i=0 to 1000
            if VAL(fibopricezonesdb.Cell(4 , drawi))>=timechartpos(i,0) and VAL(fibopricezonesdb.Cell(4 , drawi))<=timechartpos(i+1,0) then
            mytimeratio=(VAL(fibopricezonesdb.Cell(4 , drawi))-timechartpos(i,0))/(timechartpos(i+1,0)-timechartpos(i,0))
            defint drawfibopricezonesx2=timechartpos(i,1)+round((timechartpos(i+1,1)-timechartpos(i,1))*mytimeratio)
            exit for
            end if
            next i
            
            mypriceratio=(VAL(fibopricezonesdb.Cell(1 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibopricezonesy1=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)
            
            mypriceratio=(VAL(fibopricezonesdb.Cell(2 , drawi))-pricechartpos(0,0))/(pricechartpos(1,0)-pricechartpos(0,0))
            defint drawfibopricezonesy2=pricechartpos(0,1)-round((pricechartpos(0,1)-pricechartpos(1,1))*mypriceratio)

            graph.drawp(47 , drawfibopricezonesx1 , drawfibopricezonesy1 , drawfibopricezonesx2 , drawfibopricezonesy2 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF
        
        doevents
    NEXT drawi
    
IF (googlerealtimecheckbox.checked=1) THEN

            graph.bufcntreset
            graph.savebuffertmp

            graph.drawp(33 , 0 , 0 , 0 , 0 , 0 , 0)

            graph.savebuffertmp
            graph.paintchart

        END IF                                    

END IF

IF showcanvas = 1 THEN
    WITH canvas
        .firstbufcntreset
        .savebuffertmp
        .Paint
    END WITH
END IF
CASE "HLC Style 1"
    'NOTE: If values for .Data.Cells 2, 3 and 4 are set equal,
    'Box routine will draw a Hi-Lo-Close antenna style graph
    WITH Graph
        .Initialize  'Set defaults
        .ChartType = ctBox  'Hi-Lo-Close Plot
        .ChartStyle = csHiLo
        .MainTitle.Text = "Hi-Lo-Close Plot"  'change desired options
        .SubTitle.Text = "Antenna Style"
        .XTitle.Text = "X Axis"
        .YTitle.Text = "Y Axis"
        .XAxis.Grid = FALSE
        .DoLegend = FALSE
        .DATA.ColCount = 12  'Set .Data Grid dimensions
        .DATA.RowCount = 5
        k = 10  'Load the data
        RANDOMIZE
        FOR i = 1 TO .DATA.ColCount  'for each col
            .Series(i).AutoColor = FALSE
            .Series(i).Color = .Colors(8)
            .DATA.Cell(i , 0) = "Grp " + STR$(i) 'Legend in Row 0 of Each Col
            .DATA.Cell(i , 1) = STR$(RND * k + 100) 'Hi Value
            .DATA.Cell(i , 2) = STR$(RND * k + 75) '<-- Set all Three to
            .DATA.Cell(i , 3) = .DATA.Cell(i , 2) '<-- the mid or "Close"
            .DATA.Cell(i , 4) = .DATA.Cell(i , 2) '<-- Value
            .DATA.Cell(i , 5) = STR$(RND * k + 50) 'Lo Value
        NEXT i
        .DrawChart(FALSE) 'Draw it!
    END WITH

CASE "HLC Style 2"
    'NOTE: If values for .Data.Cells 1 & 2 and 4 & 5 are set equal,
    'Box routine will draw a Hi-Lo-Close box style graph
    WITH Graph
        .Initialize  'Set defaults
        .ChartType = ctBox  'Hi-Lo-Close Plot
        .ChartStyle = csWhisker  'Whiskers are hidden :)
        .MainTitle.Text = "Hi-Lo-Close Plot"  'change desired options
        .SubTitle.Text = "Box Style"
        .XTitle.Text = "X Axis"
        .YTitle.Text = "Y Axis"
        .XAxis.Grid = FALSE
        .XAxis.Tics = FALSE
        .XAxis.Labeled = FALSE
        .DATA.ColCount = 12  'Set .Data Grid dimensions
        .DATA.RowCount = 5
        k = 10  'Load the data
        RANDOMIZE
        FOR i = 1 TO .DATA.ColCount  'for each col
            .DATA.Cell(i , 0) = "Group " + STR$(i) 'Legend in Row 0 of Each Col
            .DATA.Cell(i , 1) = STR$(RND * k + 75) 'Hi Value
            .DATA.Cell(i , 2) = .DATA.Cell(i , 1) '<-- Set = to Hi Value
            .DATA.Cell(i , 3) = STR$(RND * k + 50) 'Close Value
            .DATA.Cell(i , 4) = STR$(RND * k + 25) 'Lo Value
            .DATA.Cell(i , 5) = .DATA.Cell(i , 4) '<-- Set = Lo Value
        NEXT i
        .DrawChart(FALSE) 'Draw it!
    END WITH

CASE "Redraw"
    WITH Graph
        .MainFont.Name = "Times New Roman"  'Change some options
        .SubFont.Name = "Times New Roman"  'on the currently defined chart
        .PlotAreaColor = .Colors(24)
        SELECT CASE .SubFont.Size
            CASE .MainFont.Size
                .SubFont.Size = 12
            CASE ELSE
                .SubFont.Size = .MainFont.Size
        END SELECT
        SELECT CASE .DoLegend
            CASE TRUE
                .DoLegend = FALSE
            CASE FALSE
                .DoLegend = TRUE
        END SELECT
        SELECT CASE .GreyScale
            CASE TRUE
                .GreyScale = FALSE
            CASE FALSE
                .GreyScale = TRUE
        END SELECT
        .RedrawChart  'and redraw the chart
    END WITH

CASE "Default"
    WITH Graph  'The minimum (2) required calls
        .Initialize  'Always call this first
        .MainTitle.Text = "Default Chart Settings"  '(With one option changed)
        .DrawChart(FALSE) 'Always call this last
    END WITH

CASE "Save"
    IF openedfilesnb = 0 THEN
        EXIT SUB
    END IF
    Graph.SaveChart("")

CASE "Print"
    IF openedfilesnb = 0 THEN
        EXIT SUB
    END IF
    Graph.PrintChart(Printer.PrinterIndex , 1 , 40 , 1 , FALSE)

CASE "Exit"
    frmMain.Close

END SELECT

END SUB

'-------------------------------------------------------------------------------------------
