Range check error?

Posted By ecmihai Wednesday, June 16, 2010
Add to Favorites0
Author Message
ecmihai
 Posted Wednesday, June 16, 2010
Junior Member

Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)

Group: Forum Members
Last Active: Sunday, June 20, 2010
Posts: 2, Visits: 17
10
Hello,

I have built a strategy that runs ok in testing enviroment. However, when I put it in the real market, I got an exception: Range check error at the line marked with [ERROR] below. The exception was raised when trying to access the last element in a candle history or PSAR indicator history (see the line below). Do you have any possible explanation for this or suggestion hw to avoid it? To me it seems that both the candle/PSAR history should have been available.

The error occured only once in a few days of testing in real market, still it is worrying me that repeating it might lead to undesirable effects.

Notice that the exception was raised in the 'OnNewRate' method, which is called when the price is updated.

Thank you, and if someone has encountered the same type of error, I would be grateful if he would share his experience!

Mihai

P.S. This script is a trimmed version of the strategy, only to ilustrate the conditions.

var
Account: TAccount;
History: TCandleHistory;
PSAR: TIndicatorParabolicSAR;

procedure OnCreate;
begin
AddAccountSetting(@Account, 'Account', '');
AddCandleHistorySetting(@History, 'Candle History', '', CI_1_Minute, 20);
History.OnNewCandleEvent := @OnNewCandle;
History.OnNewRateEvent := @OnNewRate;

PSAR := TIndicatorParabolicSAR.Create(History, 'ParabolicSAR');
PSAR.InitStep := 0.02;
PSAR.MaxStep := 2;
end;

procedure OnNewRate;
begin
[ERROR] if PSAR.Graph.Last(0) >= History.Last(0).High() then begin
...
end;
end;

Rodorush
 Posted Wednesday, June 16, 2010
Supreme Being

Supreme Being - (97 reputation)Supreme Being - (97 reputation)Supreme Being - (97 reputation)Supreme Being - (97 reputation)Supreme Being - (97 reputation)Supreme Being - (97 reputation)Supreme Being - (97 reputation)Supreme Being - (97 reputation)Supreme Being - (97 reputation)

Group: Forum Members
Last Active: Thursday, June 30, 2011
Posts: 29, Visits: 67
97
Hello, i dont know, but try try replacing the error line to this:

if PSAR.Graph.Last >= History.Last.High then begin

without pararenteses.
I think that is a bad idea works with indicators and unclosed candles (actual candles). Try to work with closed candles. I think that the error is this.

Line with closed candles:
if PSAR.Graph.Last(1) >= History.Last(1).High then begin

I don´t know what impact this would have on your strategy but I think the error would disappear, working with closed candles and indicators.


[ ]´s

Rodolfo Andrade
www.rodorush.com.br
rodolfo@rodorush.com.br
+55(16)9193-6808
ecmihai
 Posted Wednesday, June 16, 2010
Junior Member

Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)Junior Member - (10 reputation)

Group: Forum Members
Last Active: Sunday, June 20, 2010
Posts: 2, Visits: 17
10
Hello,

Thank you very much for your answer!

I will definetly try your first advice: modifying the code to if PSAR.Graph.Last >= History.Last.High then begin

You might be right about the second too, but unfortunately data from the previous candle/PSAR value is of no use for this strategy because I need to detect the PSAR change as soon as it happens. However if this is the case then it's a bug - I should have no problem accessing the latest data.

I have also submitted the issue to the EXTO support team. In the meantime any other ideas would be very appreciated Smile

Thanks again!

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top