Page 1 of 1

Comm. between Excel and MC ,Usefull MC & Excel functions

Posted: 21 Jul 2011
by arjfca
Hello
I'm using XLInputs , a more updated version of ELExcel.dll to send data from MC to Excel.

I opted to transmit one big comma separated string that content all the information that i want to sent.

Ex:
Datastring = 1.43910,1.43945,1.43905,1.43910,1.43875,1.43965,1.43810,1.43905,1.43430,1.43070,1.43545,1.43500,10:27,-,0,0.0000,0

Is the informations of
- the actual bar OHLC
- The Previous bar
- Last to Pivot High
-Last Two Pivot Low
- Actual Position string (Long, Short, - )
- Actual Position size
etc

Once in Excel, I wrote a function to place all the value to is appropriate cell.
Basically, you call the function with a string and the position of the wanted information

Cell actuallow = SplitFunction(Datastring,3) 3 representing the value of the actual low of the active bar.
Cell ActualLow = 1.43905.

** I named all my cell. But it could be cell (B10)

Install the function in a module. It would be accessible for your vba code and directly on your sheet cell formula

Code: Select all

Public Function SplitString(ByVal Text1 As String, WordPos As Long) As String
' EXCEL VBA SplitString FUNCTION
'By Martin Thériault
'July 21 2011

Dim CommaPos As Long
Dim LeftBorder, RightBorder As Long
Dim WordCounter As Long
Dim tempstring As String
Dim TestString As String
Dim pos As Long

pos = WordPos
CommaPos = 0
WordCounter = pos

'LeftBorder
If InStr(1, Text1, ",") <> 0 Then
While WordCounter - 1 <> 0
CommaPos = InStr(CommaPos + 1, Text1, ",")
pos = pos - 1
WordCounter = WordCounter - 1
Wend
LeftBorder = CommaPos + 1
If InStr(LeftBorder + 1, Text1, ",") <> 0 Then
RightBorder = InStr(LeftBorder + 1, Text1, ",")
Else
RightBorder = 9999
End If

Else
LeftBorder = 1
RightBorder = 9999
End If

SplitString = Mid(Text1, LeftBorder, (RightBorder - LeftBorder))

End Function

Re: Communication between Excel and MC,A usefull Excel funct

Posted: 21 Jul 2011
by arjfca
I did create a similar function for MC. Since Instr function is not the same in Excel and MC, I modified my approach

Code: Select all

//Split String. Enter a string and a number representing the position of the extract of the string
//By Martin Th?riault
//July 21 2011

inputs:
text1 (StringSImple),
counter (Numeric);

variables:
IntraBarPersist CommaPos (0),
IntraBarPersist WordCounter (0),
IntraBarPersist position (0),
intrabarpersist tempstring (""),
IntrabarPersist TempPos (0),
IntraBarPersist TestString ("");

//Code___________________________________________________________________

TestString =Text1;
Position = Counter;

If instr(TestString, ",") > 0 then begin
TempPos = Instr(TestString,",");
While Position > 1 begin
TempPos = Instr(TestString,",");
TestString = MidStr(TestString,TempPos+1,999);
//Print(TestString, " ", TempPos:0:0);
Position = Position -1;
end;

SplitString = Midstr(testString, 0,TempPos-1);
//Print (SplitString, " ", teststring, " ", TempPos-1:0:0);
end;
Martin

Re: Comm. between Excel and MC ,Usefull MC & Excel functio

Posted: 15 Sep 2011
by teo
Hi, I got XLInputs and it's working very well, support from David is great.

Re: Comm. between Excel and MC ,Usefull MC & Excel functio

Posted: 15 Sep 2011
by arjfca
OK
Nice to see that I'm not alone :)
Once well install, it is easy to use and stable
Yes, David Odell give great support

Don't hesitate to share tool that you create with it

Martin