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:
CreateIndicator Function error
-
- Posts: 10
- Joined: Wed Jan 19, 2011 5:38 pm
- Location: 92808
- Contact:
CreateIndicator Function error
- Attachments
-
- EMA_Error.jpg (92.91 KiB) Viewed 7700 times
-
- Posts: 10
- Joined: Wed Jan 19, 2011 5:38 pm
- Location: 92808
- Contact:
Additional Info
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;
procedure GetSingleTick; stdcall;
var
sma1_c, sma2_c, sma1_p, sma2_p: double;
begin
end;
-
- Posts: 10
- Joined: Wed Jan 19, 2011 5:38 pm
- Location: 92808
- Contact:
Found the issue
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');
Good:
IndEMA1 := CreateIndicator(Currency, 240, 'MovingAverage', format('%d;%d;%d;',[period1,0,0]) + StrMAType(ma_EMA) + ';Close');
Who is online
Users browsing this forum: No registered users and 32 guests