Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

custom trailing stop indicator error
 Post subject: custom trailing stop indicator error Post rating: 0   New post Posted: Mon 09 Jan, 2012, 22:00 
User avatar

User rating: 1
Joined: Wed 06 Jul, 2011, 23:12
Posts: 42
Location: Romania, Bucharest
Dear API Support,

I am trying to create an indicator that acts as a fixed distance trailing stop. The code that I have created is attached bellow.
I don't have compilation errors or other error messages during execution but at some moments the indicator is calculated incorrectly.
I attach a picture of the error. I spent many hours looking at the code but still I can't understand where is the error that produces that temporary miscalculation.

Can you please give me some advise ?

Attachment:
Test10.java [5.66 KiB]
Downloaded 315 times


Attachment:
indicator error.JPG [90.94 KiB]
Downloaded 360 times


 
 Post subject: Re: custom trailing stop indicator error Post rating: 0   New post Posted: Tue 10 Jan, 2012, 08:12 
User avatar

User rating: 1
Joined: Wed 06 Jul, 2011, 23:12
Posts: 42
Location: Romania, Bucharest
I should add that the error always appears in the real time display of the indicator and never in the part of the chart that represents historic values registered before the insertion of the indicator.

Also, after the error appears, if I right-click on indicator and select "edit indicator" than it seems that the indicator is automatically recalculated for the whole chart and the error disappears .... only to appear again in the future after a few minutes on another (subsequent) portion of the real time chart.

Thank you!


 
 Post subject: Re: custom trailing stop indicator error Post rating: 0   New post Posted: Thu 12 Jan, 2012, 11:14 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Your indicator results depend on input count:
up_trail = Math.min(up_trail, inputs[0][HIGH][i] + trail_distance);
dn_trail = Math.max(dn_trail, inputs[0][LOW][i] - trail_distance);
For unstable period you receive ~100 inputs, but on recalculation - ~4000. So that might be the cause of different values between standard calculation and recalculation.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com