Hi,
I'm having some difficulty dealing with the pointer associated with the external parameter for currency. I'm able to easily hardcode a specific currency into the code; however, when I attempt to replace it with an external user specified currency I'm unsure how to do it. The code below is basically an extract of the code generated by your tool with an addition of the SetCurrencyAndTimeframe function I require to set the currency for the rest of the code. How can I replace the 'EURUSD" with the externally chosen currency? I've tried putting in the pointer but it doesn't compile. I've tried to substitute with a string but the internally defined currency variable is a pointer. Seems to be a very basic requirement to have code generically written to work with any currency pair, but the solution somehow still eludes me.
I'm currently recompiling the exact same code but changing the hardcoding for the currency each time to accommodate different currencies.
Please help. Thanks in advance.
var
// External parameters
Currency: PChar = nil;
procedure InitStrategy; stdcall;
begin
RegOption('Currency', ot_Currency, Currency);
ReplaceStr(Currency, 'EURUSD'); // EURUSD HARDCODED each time.
SetCurrencyAndTimeframe(Currency, PERIOD_D1);
end;
Thanks,
Tek
How to have varying Currencies through external parameters.
-
- Posts: 4
- Joined: Sun May 29, 2016 3:33 pm
-
- Posts: 1479
- Joined: Mon Apr 01, 2013 3:55 am
Re: How to have varying Currencies through external parameters.
Hello
Please try to change
Currency: PChar = nil;
with
Currency: PAnsiChar = nil;
Does it help?
Please try to change
Currency: PChar = nil;
with
Currency: PAnsiChar = nil;
Does it help?
-
- Posts: 4
- Joined: Sun May 29, 2016 3:33 pm
Re: How to have varying Currencies through external parameters.
Hi,
I replaced it but I get a bunch of warnings from the compiler stating "Unsafe type for both Currency and PAnsiChar. Also when I try to run it in ForexTester2 it fails to run the program and states there is an access violation at some address.
I don't understand how this would work anyway as the ReplaceStr(Currency, 'EURUSD') is still hardcoding the currency in. I would like to use the external parameters to pick the currency. How do I do that?
Thanks,
Tek
I replaced it but I get a bunch of warnings from the compiler stating "Unsafe type for both Currency and PAnsiChar. Also when I try to run it in ForexTester2 it fails to run the program and states there is an access violation at some address.
I don't understand how this would work anyway as the ReplaceStr(Currency, 'EURUSD') is still hardcoding the currency in. I would like to use the external parameters to pick the currency. How do I do that?
Thanks,
Tek
-
- Posts: 1479
- Joined: Mon Apr 01, 2013 3:55 am
Re: How to have varying Currencies through external parameters.
Hello
Our programmer says that maybe the problem is that SetCurrencyAndTimeframe(Currency, PERIOD_D1); is placed in the InitStrategy procedure.
Please try to move SetCurrencyAndTimeframe into GetSingleTick procedure.
Our programmer says that maybe the problem is that SetCurrencyAndTimeframe(Currency, PERIOD_D1); is placed in the InitStrategy procedure.
Please try to move SetCurrencyAndTimeframe into GetSingleTick procedure.
-
- Posts: 4
- Joined: Sun May 29, 2016 3:33 pm
Re: How to have varying Currencies through external parameters.
Awesome! That was it! Thanks for your help!
Who is online
Users browsing this forum: No registered users and 17 guests