How to have varying Currencies through external parameters.
Posted: Tue May 31, 2016 8:34 pm
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
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