Exploration To Excel

Trady

Active Member
#1
Dear Members,

Can anyone Help me to Export the Exploration data to Excel Automatically Without using Copy and Paste..

I think it's possible using VB Script....

Code:
Buy = Cover =
 Cross(C,MA(C,5));

Sell = Short =
 Cross(MA(C,5),C);

PositionSize = IIf(Buy,BuyPrice,ShortPrice);

E = Equity(1);
Paper = Name();

EnableScript("vbscript");
<%
 'The exchange of variables between the AFL and VB script
 E = AFL("E")
 Paper = AFL("Paper")

 'Starting Excel
 Set Excel = CreateObject("Excel.Application")
 'Set Excel in a state of readiness
 Excel.WorkBooks.Add
 Set Sheet = Excel.WorkBooks(1).WorkSheets(1)

 'Writing to an Excel cell
 Sheet.Cells(1,1) = Paper
 Sheet.Cells(1,2) = "Equity"
 Sheet.Cells(1,3) = "DrawDown"

 'Initiation Equity maximum - will be needed
 ' to calculate DrawDownu
 MaxE = E(0)

 'Writing of the Equity and DrawDownu to Excel
 For i = 0 to UBound(E)
     Y = i+2
     Sheet.Cells(Y,2).Value = E(i)

     If E(i) > MaxE then
        MaxE = E(i)
     End If
     Drawdown = 0 - ((MaxE - E(i))/MaxE * 100)
     Sheet.Cells(Y,3).Value = Drawdown
 Next

 'And now the graphs
 Sheet.Activate
 Sheet.Columns(2).Select

 '...Equity...
 Excel.Charts.Add
 Set EquityCharts = Excel.Charts(1)
 EquityCharts.Name = Paper + " Equity"
 EquityCharts.Type = 1
 EquityCharts.HasLegend = 0
 EquityCharts.HasTitle = 0

 Sheet.Activate
 Sheet.Columns(3).Select

 '... and DrawDown (in percent)
 Excel.Charts.Add
 Set EquityCharts = Excel.Charts(2)
 EquityCharts.Name = Paper + " DrawDown"
 EquityCharts.Type = 1
 EquityCharts.HasLegend = 0
 EquityCharts.HasTitle = 0

 
 Excel.Visible = 1
%>
 

Similar threads