2 registered members (AndrewAMD, ChrstphFr),
941
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Sierra Chart Plugin
[Re: AndrewAMD]
#478654
11/20/19 20:46
11/20/19 20:46
|
Joined: May 2018
Posts: 134
SBGuy
Member
|
Member
Joined: May 2018
Posts: 134
|
Got some time today, so I thought I'd give it a try. It crashed in BrokerLogin. I did use my real username/login. I've never loaded a DLL function before in. Any guidance would be appreciated
#include <stdio.h>
#include <default.c>
#include <contract.c>
int __cdecl BrokerOpen (char*, FARPROC, FARPROC);
API(BrokerOpen,Plugin\\SierraChart)
int __cdecl BrokerLogin (char*, char*, char*, char* );
API(BrokerLogin,Plugin\\SierraChart)
int __cdecl BrokerHistory2 (char* , DATE , DATE , int , int , T6* );
API(BrokerHistory2,Plugin\\SierraChart)
void run()
{
StartDate = 20190101;
EndDate = 20191031;
Verbose = 7|DIAG;
String temp = "AAPL";
History = "_SC.t6";
BokerOpen("SierraChart",0, 0);
_POS("11111");
BrokerLogin ("USERXXX", "PWDXXXX", "Demo", "0000");
_POS("22222");
T6* myT6;
int items = BrokerHistory2 (temp, dmy(20190101), dmy(20191031), 1440, -1, myT6);
FILE *fp;
string fname = strf("History\\%s%s",temp, History);
fp = fopen(fname, "wb");
fwrite(myT6 , items , sizeof(myT6) , fp );
asset(temp);
var Price = priceClose();
printf("price = %.4f\n",Price);
}
Last edited by SBGuy; 11/20/19 20:46.
|
|
|
Re: Sierra Chart Plugin
[Re: AndrewAMD]
#478655
11/21/19 00:40
11/21/19 00:40
|
Joined: Feb 2017
Posts: 1,729 Chicago
AndrewAMD
OP
Serious User
|
OP
Serious User
Joined: Feb 2017
Posts: 1,729
Chicago
|
Why did you hand over null pointers to fpError and fpProgress? I bet my plugin crashes on calling BrokerError and BrokerProgress. (Obviously, there's no reason to check if the pointers are valid ) Also, char* Accounts is an output, so why are you supplying a string literal? Mind you, my plugin was designed to be used by Zorro.
|
|
|
Re: Sierra Chart Plugin
[Re: AndrewAMD]
#478657
11/21/19 03:35
11/21/19 03:35
|
Joined: Feb 2017
Posts: 1,729 Chicago
AndrewAMD
OP
Serious User
|
OP
Serious User
Joined: Feb 2017
Posts: 1,729
Chicago
|
Make up your own function and pass a function pointer. You know what to do, right? Just do what the manual says the functions do.
Also, your BrokerHistory2 call is wrong. You don't even know how much memory you need - you need to call GET_MAXTICKS, and then call malloc.
~~~~ IN GENERAL~~~~ Any time that the plugin outputs memory (such as T6 ticks or strings), the caller is responsible for supplying the memory. You have supplied memory zero times. Fix this.
If you're not sure whether or not it's an output, read the manual.
Last edited by AndrewAMD; 11/21/19 15:00.
|
|
|
Re: Sierra Chart Plugin
[Re: AndrewAMD]
#478659
11/21/19 16:52
11/21/19 16:52
|
Joined: May 2018
Posts: 134
SBGuy
Member
|
Member
Joined: May 2018
Posts: 134
|
Hi Andrew, my programming skills are not close to your level by any measure. This DLL loading thing is completely new to me. I've read the manual and continued to hack at it and still doesn't work. I even copied SierraChart.dll to SierraChart2.dll, put in the root Zorro directory, and tried a different way of loading the DLL. I'm getting a compile error about wrong type CONV:POINTER::DOUBLE at the BrokerOpen line. I don't think I'm passing the function pointers in correctly. I tried my best with my rusty skills. Here's my stripped down code. I'll worry about BrokerHistory once I get pass BrokerOpen :-) Any thoughts? Thanks.
#include <stdio.h>
#include <default.c>
#include <contract.c>
int __cdecl BrokerOpen (char*, FARPROC, FARPROC);
BrokerOpen = DefineApi("SierraChart2:BrokerOpen");
int __cdecl BrokerLogin (char*, char*, char*, char*);
BrokerLogin = DefineApi("SierraChart2:BrokerLogin");
int __cdecl BrokerHistory2 (char* , DATE , DATE , int , int , T6* );
BrokerLogin = DefineApi("SierraChart2:BrokerHistory2");
int BrokerError(char* message) {
printf(message);
}
int BrokerProgress(DWORD progress) {
printf("stuff");
}
void run()
{
StartDate = 20190101;
EndDate = 20191031;
Verbose = 7|DIAG;
string temp = "AAPL";
History = "_SC.t6";
string temp1[100];
BrokerOpen(temp1, &BrokerError, &BrokerProgress);
char retAcct[1024];
BrokerLogin ("XXXXX", "XXXXXX", "Demo", retAcct);
}
|
|
|
|