CreateIndicator Function error

How to create strategies and indicators
Message
Author
tanmay80
Posts: 10
Joined: Wed Jan 19, 2011 5:38 pm
Location: 92808
Contact:

CreateIndicator Function error

#1 Postby tanmay80 » Sat Jan 22, 2011 1:07 pm

Hi,

I want to look at EMA values using createIndicator function in a strategy.

I created the following for this,



procedure ResetStrategy; stdcall;
begin
OrderHandle := -1;
pTime := Time(0);
IndEMA1 := CreateIndicator(Currency, 240, 'MovingAverage', format('%d;%d;%d',[period1,0,0]) + StrMAType(ma_EMA) + ';Close');
IndEMA2 := CreateIndicator(Currency, 240, 'MovingAverage', '12;0;0;' + StrMAType(ma_EMA) + ';Close');


end;

{-----Process single tick---------------------------------------------------}
procedure GetSingleTick; stdcall;
var
sma1_c, sma2_c, sma1_p, sma2_p: double;


begin
try
// check our currency
// if Symbol <> string(Currency) then exit;

// set currency and timeframe
// SetCurrencyAndTimeframe(Symbol, TimeFrame);

// check number of bars and SMA period
// if (Bars < period1) or (Bars < period2) then exit;

if pTime <> Time(0) then
begin
// Print('Inside the Time Loop');
pTime := Time(0);

Print('Calculated SMAs, now moving to Orders');


// if there is no order and fast SMA crosses slow SMA from top
// then open SELL order
Print('In the else Loop');
end;
except
on E: Exception do
Print(E.ClassName+' error raised, error message : ' +E.Message);
end;
end;


Getting the attached error:
Attachments
EMA_Error.jpg
EMA_Error.jpg (92.91 KiB) Viewed 7700 times

tanmay80
Posts: 10
Joined: Wed Jan 19, 2011 5:38 pm
Location: 92808
Contact:

Additional Info

#2 Postby tanmay80 » Sat Jan 22, 2011 3:47 pm

Even when I strip everything else from the GetSingleTick Function as below, i still get the same error.

procedure GetSingleTick; stdcall;
var
sma1_c, sma2_c, sma1_p, sma2_p: double;


begin

end;

tanmay80
Posts: 10
Joined: Wed Jan 19, 2011 5:38 pm
Location: 92808
Contact:

Found the issue

#3 Postby tanmay80 » Sat Jan 22, 2011 4:01 pm

I found the issue in the parameters being passed to the CreateIndicator, I was not using semicolons in the format function for the last variable

Good:

IndEMA1 := CreateIndicator(Currency, 240, 'MovingAverage', format('%d;%d;%d;',[period1,0,0]) + StrMAType(ma_EMA) + ';Close');


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 32 guests