Dukascopy
 
 
Wiki JStore Search Login

Candle counter
 Post subject: Candle counter Post rating: 0   New post Posted: Sun 27 Jul, 2014, 12:10 
User avatar

User rating: 0
Joined: Mon 07 May, 2012, 07:24
Posts: 69
Location: CroatiaCroatia
Hello!

I need solution how to count number of candles starting when position is open and reset it when position is closed.

Is it possible and how?

Regards


 
The Best Answer  Post subject: Re: Candle counter Post rating: 0   New post Posted: Mon 28 Jul, 2014, 08:17 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Greetings,

Yes indeed:
Assuming that your strategy is subscribed to a given period, once a position is opened, your set a trigger (any variable that takes a given value, the best is to use a True/False Boolean variable) and then IF this var is TRUE, you set your counter (simple calculation block that performs an incrementation by 1). Afterwords, once the position is closed, your trigger has to take the value FALSE and therefore you set your counter to 0.


 
 Post subject: Re: Candle counter Post rating: 0   New post Posted: Mon 28 Jul, 2014, 18:31 
User avatar

User rating: 0
Joined: Mon 07 May, 2012, 07:24
Posts: 69
Location: CroatiaCroatia
Hello and thanx for quick reply.

I know everything what you meant except what variable in calculation block would increase (count) number of candles.
F.E.: Time frame is 4H, and there are 5 candles between open and close position, so number of candles will be from 1 to 5 and again 0 after closing position.

Can you put some example please?

Regards


 
 Post subject: Re: Candle counter Post rating: 0   New post Posted: Tue 29 Jul, 2014, 13:04 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
HI,

Here is two examples of strategies that fairly implements your idea:
- The first one opens a single position within a range of 4 candles and once this position is closed it will reset the counter to zero
- the second one open and close positions every 4 candles.

Cheers


Attachments:
Sample2.vfs [33.3 KiB]
Downloaded 101 times
Sample1.vfs [30.74 KiB]
Downloaded 111 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Candle counter Post rating: 0   New post Posted: Tue 29 Jul, 2014, 13:05 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
cancel / replace

:)


Attachments:
Sample2.vfs [32.8 KiB]
Downloaded 107 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Candle counter Post rating: 0   New post Posted: Wed 30 Jul, 2014, 12:19 
User avatar

User rating: 0
Joined: Mon 07 May, 2012, 07:24
Posts: 69
Location: CroatiaCroatia
Hello Amine.

After yours examples, got it finally!

Thank You!
Regards


 
 Post subject: Re: Candle counter Post rating: 0   New post Posted: Mon 04 Aug, 2014, 21:05 
User avatar

User rating: 0
Joined: Mon 07 May, 2012, 07:24
Posts: 69
Location: CroatiaCroatia
Hello Amine.
Just a little update...
Is it first IF block (rounded in picture) absolutely necessary? Isn't enough just check state position (filled) in second IF block? I ask this to avoid redundancy.

Regards
Image


Attachments:
counter.png [30.94 KiB]
Downloaded 318 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Candle counter Post rating: 1   New post Posted: Tue 05 Aug, 2014, 10:13 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Hi there,

Well it's good question. Obviously a simple check of position state should be sufficient but for the time being the system 'read' this condition with the assumption that position variable should have a value (Created/opened/filled/closed etc) and often when we work with position variables (except when we use position viewer block) the direct verification of the position state generate an error as the system consider that position variable gets already an assigned value which is not always the case: for instance, when a position is not created yet (Value null). Therefore, this block is a simple check that make sure position variable gets a value. When using position viewer block, I believe such condition is not mandatory as the iteration clears out empty variables and takes into account variables that has a value. Hope this clear enough for you.

Beside that, this 'NoValue' can be used for other variables to avoid useless checks and errors.

Cheers


 
 Post subject: Re: Candle counter Post rating: 0   New post Posted: Tue 05 Aug, 2014, 12:17 
User avatar

User rating: 0
Joined: Mon 07 May, 2012, 07:24
Posts: 69
Location: CroatiaCroatia
amine_chourou wrote:
Hi there,

Well it's good question. Obviously a simple check of position state should be sufficient but for the time being the system 'read' this condition with the assumption that position variable should have a value (Created/opened/filled/closed etc) and often when we work with position variables (except when we use position viewer block) the direct verification of the position state generate an error as the system consider that position variable gets already an assigned value which is not always the case: for instance, when a position is not created yet (Value null). Therefore, this block is a simple check that make sure position variable gets a value. When using position viewer block, I believe such condition is not mandatory as the iteration clears out empty variables and takes into account variables that has a value. Hope this clear enough for you.

Beside that, this 'NoValue' can be used for other variables to avoid useless checks and errors.

Cheers

Hello!
I'm glad to ask this. From now on I will implement this solution into my strategies.

Regards


 

Jump to:  

  © 1998-2024 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