Dukascopy
 
 
Wiki JStore Search Login

While loop for volume bars
 Post subject: While loop for volume bars Post rating: 0   Post Posted: Fri 01 Jul, 2016, 15:09 
User avatar

User rating: 1
Joined: Thu 23 Jun, 2016, 11:36
Posts: 45
Location: AustriaAustria
Hi, I would like to be able to do the equivalent of a while statement. I would like to hold the flow until the shift 0 volume bar on its close exceeds a defined value but I'm not sure how's the best way to do this. It seems it could be something that Loop viewer might be used for. But I'm not sure, and I also don't know if the loop viewer can handle volume bars. Your advice would be very appreciated. Thanks


 
 Post subject: Re: While loop for volume bars Post rating: 0   Post Posted: Fri 01 Jul, 2016, 15:47 
Visual JForex expert at Dukascopy
User avatar

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

I understand from your description that you'll work on Candle start based on a given period. The on candle start is updated (or executed) every candle close / Start of new candle. So the value of your volume will be retrieved at this moment exactly. So a simple IF condition to check the volume level is enough to do your requirement.

Check the attached example, I've included some comments in it.

Cheers


Attachments:
VolumeCheck.vfs [21.2 KiB]
Downloaded 149 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: While loop for volume bars Post rating: 0   Post Posted: Fri 01 Jul, 2016, 16:28 
User avatar

User rating: 1
Joined: Thu 23 Jun, 2016, 11:36
Posts: 45
Location: AustriaAustria
Thanks for that explanation. Just for my clarification, I note in your attached example that the shift 0 value comes from the Gethistorical Candle block. Shift 0 though is the "live" current bar (as opposed to a historical bar). So I guess there's some nuance that enables a shift 0 value can be obtained from the historical data. I see that calling for shift 0 close is like calling shift 1 open for price (and shift 1 is historical of course). But for volume, shift 0 close has a volume that is greater than zero, whereas for shift 1 open the volume is zero. I guess I'm missing something to make it all sensible.


 
 Post subject: Re: While loop for volume bars Post rating: 0   Post Posted: Fri 01 Jul, 2016, 16:41 
Visual JForex expert at Dukascopy
User avatar

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

Shift 0 is as you said referring to the current live candle. Shift one is historical.
There is no concept of shift open and shift close at all. For this example, the volume is retrieved from the predefined candle (using shift) and refreshed according to the start pooint and applied filters.
I advice you to play with that on real-time run using a demo account and drag and drop the value of the volume on the work-space to see its real time value (debugging)
I'm sure you'll get the way this works.


 
 Post subject: Re: While loop for volume bars Post rating: 0   Post Posted: Fri 01 Jul, 2016, 16:49 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
if you use shift 0 with the period filter and test on real time: you'll have volume approx. null why ? Because the check (update) is made at close price of the current candle (just at the time expiry of the candle period) and the start of the new candle (open price) which becomes the new current one and this is the reason why the volume retrieved is almost 0 or slightly more (if so then we can conclude that this little volume corresponds to the traded volume at the open price of the new candle)

Hope this is clear :)

Enjoy your WE !


 
 Post subject: Re: While loop for volume bars Post rating: 0   Post Posted: Tue 05 Jul, 2016, 13:54 
User avatar

User rating: 1
Joined: Thu 23 Jun, 2016, 11:36
Posts: 45
Location: AustriaAustria
Thank you. I'd like to be sure about something though. I get the impression that a WHILE loop can be achieved with an IF block with only one output. Is that right? Or is there another way for creating a WHILE loop? thanks.


 
 Post subject: Re: While loop for volume bars Post rating: 0   Post Posted: Wed 06 Jul, 2016, 17:30 
Visual JForex expert at Dukascopy
User avatar

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

With an IF condition associated to a loop Viewer you'll be able to achieve a "do..while" the IF should be one way exit indeed unless you have another condition.

cheers


 
 Post subject: Re: While loop for volume bars Post rating: 0   Post Posted: Sat 16 Jul, 2016, 15:13 
User avatar

User rating: 1
Joined: Thu 23 Jun, 2016, 11:36
Posts: 45
Location: AustriaAustria
I see - so does this mean that a Loop Viewer block can be broken out of early (i.e. before the LV finishes processing the full array) once the IF condition is achieved?


 
 Post subject: Re: While loop for volume bars Post rating: 0   Post Posted: Mon 18 Jul, 2016, 10:44 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Yes if the condition is implemented inside the loop.
but if it is build build this way for instance, you don't need to worry about your performed loops

Image


Attachments:
loopAndExit.JPG [122.24 KiB]
Downloaded 319 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.
 

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