Dukascopy
 
 
Wiki JStore Search Login

Loops and Get Historical Candles in revers order.
 Post subject: Loops and Get Historical Candles in revers order. Post rating: 0   New post Posted: Sun 10 May, 2015, 21:48 
User avatar

User rating: 0
Joined: Sun 01 Feb, 2015, 22:49
Posts: 81
Location: RomaniaRomania
Hi there,

1.
I see that Get Historical Candles retrieves the last Candle Amount of candles
while Loop Viewer scrolls through them in chronological order.

Is there a way I can set Loop Viewer to scroll through my array of Candles in reverse order?
A workaround could be found, but very, very inefficient.

2.
If I found what I am looking for in the array, it does not make sense to continue looping.
How can I exit the Loop cycle when my condition is met?

I see point 2 should be possible because it is mentioned in the specs:
"
A loop is a sequence of instruction(s) that is continually repeated until a certain condition is reached
"

Cheers,
mosu_d


 
 Post subject: Re: Get Historical Candles in revers order. Post rating: 1   New post Posted: Mon 11 May, 2015, 16:46 
Visual JForex expert at Dukascopy
User avatar

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

Quote:
1. I see that Get Historical Candles retrieves the last Candle Amount of candles
while Loop Viewer scrolls through them in chronological order.
Is there a way I can set Loop Viewer to scroll through my array of Candles in reverse order?
A workaround could be found, but very, very inefficient.

The upper statement is correct, but can you please elaborate on the need of going through an array of data in a reversed order ??

Quote:
2. If I found what I am looking for in the array, it does not make sense to continue looping.
How can I exit the Loop cycle when my condition is met?


Well, theoretically speaking, as long as there is new candles upcoming, the loop viewer continues to retrieve the data. The second exit allow the user to stop the iteration (Cycle end) till the next event (new candle) if you need to do a single loop in the entire strategy then you can insert a logical trigger that stops the loop viewer iteration for example.


 
 Post subject: Re: Get Historical Candles in revers order. Post rating: 0   New post Posted: Mon 11 May, 2015, 20:52 
User avatar

User rating: 0
Joined: Sun 01 Feb, 2015, 22:49
Posts: 81
Location: RomaniaRomania
Hi,

1. Going through an array in revers order:

Image

Looping through candles in chronological order: example 1 shows a good scalping position, so I should record it or place an order.
But, going through the rest of the loop I get to example 2
meaning that the window of opportunity has already closed.

If I loop backwards (through example 2) it is obvious there is no scalping position.


2. I did not understand how I can make a logical trigger to stop the looping if a logical condition is met (except for stop strategy ;) ).
Can you show me an example?

Cheers,
mosu_d


Attachments:
Example.png [4.31 KiB]
Downloaded 642 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: Get Historical Candles in revers order. Post rating: 0   New post Posted: Tue 12 May, 2015, 09:21 
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 an example with some notes so that you can get the main idea.


Attachments:
Loop_processing.vfs [41.44 KiB]
Downloaded 124 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: Get Historical Candles in revers order. Post rating: 0   New post Posted: Tue 12 May, 2015, 09:28 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Just to add a comment to your point 1:

Quote:
Looping through candles in chronological order: example 1 shows a good scalping position, so I should record it or place an order.


You don't necessarily need to record the whole sequence but instead you can create a variable "A" that gets the value 1 for example once your figure is detected (in your example the sequence of X number of red candles) and then you can keep going if another figure is detected and assign the value 2 to A etc ... Once your target is met, lets say 50 figures the variable A will be updated accordingly. You can also reset its value of the condition is broken ... several workarounds can be considered here..

Hope this helps...


 
 Post subject: Re: Get Historical Candles in revers order. Post rating: 0   New post Posted: Tue 12 May, 2015, 13:17 
User avatar

User rating: 0
Joined: Sun 01 Feb, 2015, 22:49
Posts: 81
Location: RomaniaRomania
Thank you for the fast replies !

For me the comment for the Loop is contradicting its definition:

Image

I can't see how to set a "Loop ... While" expression. Don't get me wrong, I have 2 digit experience with coding, I think I got the main ideas :).

Cheers,
mosu_d


Attachments:
Contradicting.png [49.32 KiB]
Downloaded 633 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: Get Historical Candles in revers order. Post rating: 0   New post Posted: Wed 13 May, 2015, 13:55 
Visual JForex expert at Dukascopy
User avatar

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

Well the definition itself needs some improvement but the main idea is that out of the second exit the loop viewer block has performed the asked sequence but this doesn't necessarily means that it will definitely stop. The loop viewer function when used alone is only doing a cyclic "look" but if you need to add a "while" function you need to add an IF block specifying this.


 
 Post subject: Re: Get Historical Candles in revers order. Post rating: 0   New post Posted: Fri 15 May, 2015, 10:14 
User avatar

User rating: 0
Joined: Sun 01 Feb, 2015, 22:49
Posts: 81
Location: RomaniaRomania
Sorry, but I don't find this reply useful.

Please provide an example or photo of an example on
how to stop a loop when a condition is met.

Cheers,
mosu_d


 
 Post subject: Re: Get Historical Candles in revers order. Post rating: 0   New post Posted: Fri 15 May, 2015, 17:48 
Visual JForex expert at Dukascopy
User avatar

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

In my previous example "LoopProcessing" you can see that if the var "Highest" is greater than the high price of the candle (shift 6) then the loop is simply stopped with the help of "GO variable. In other words, we're doing a loop as long as "Highest" > Candle19:Candle high ... else, No loop.

Hope this helps.


 
 Post subject: Re: Loops and Get Historical Candles in revers order. Post rating: 0   New post Posted: Fri 15 May, 2015, 21:50 
User avatar

User rating: 0
Joined: Sun 01 Feb, 2015, 22:49
Posts: 81
Location: RomaniaRomania
Hi Amine,

I think there is a confusion in your example between

- The Loop block
- Strategy Loop that executes at each candle.
Image

In your example, the Go variable just stops the Loop block from executing (altogether) after it has been executed once and the Order is placed (and open).

But it does not stop the Loop Block from stopping at ...
for example 3rd loop out of 5 possible loops

because the Go variable is assigned value true outside the Loop block cycle.

Cheers,
Dan.


Attachments:
Untitled.png [110.85 KiB]
Downloaded 599 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: Loops and Get Historical Candles in revers order. Post rating: 0   New post Posted: Mon 18 May, 2015, 12:45 
Visual JForex expert at Dukascopy
User avatar

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

Actually there is no confusion in my example but most probably the way you understood the Loop Viewer function.
1- You can change the way blocks are linked in order to include a "NO GO" inside the loop as shown:

Image

2- If you want to simply stop at the loop 3 out of 5 (without any further conditions), you can insert a counter.

In any case, if you can provide a concrete example of your trading idea and at which level you are blocked I can help further ...

Cheers


Attachments:
KeepOnLooping.JPG [231.12 KiB]
Downloaded 604 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: Loops and Get Historical Candles in revers order. Post rating: 0   New post Posted: Tue 19 May, 2015, 10:54 
User avatar

User rating: 0
Joined: Sun 01 Feb, 2015, 22:49
Posts: 81
Location: RomaniaRomania
Ok let us talk practice,

I created an example based on your suggestions: used a counter and Boolean var.

Image

You would expect to get just 2 Orders,
instead you get 4
for each OnCandle.

Cheers,
mosu_d


Attachments:
loop.png [71.39 KiB]
Downloaded 469 times
Default_1.03.vfs [41.23 KiB]
Downloaded 131 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: Loops and Get Historical Candles in revers order. Post rating: 0   New post Posted: Fri 22 May, 2015, 09:50 
User avatar

User rating: 0
Joined: Sun 01 Feb, 2015, 22:49
Posts: 81
Location: RomaniaRomania
.
.


No more feedback on Practical example... ?

.
.
.


 
 Post subject: Re: Loops and Get Historical Candles in revers order. Post rating: 0   New post Posted: Mon 25 May, 2015, 17:14 
Visual JForex expert at Dukascopy
User avatar

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

Kindly be patient and you'll get the needed feedback.
We'll get back to you asap.

Thanks for your understanding.


 
 Post subject: Re: Loops and Get Historical Candles in revers order. Post rating: 0   New post Posted: Tue 26 May, 2015, 10:42 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Quote:
Ok let us talk practice,

Thought we are doing that since the beginning :D

Alright, back to your query:

I've made the following modification to your file:
- The counter should be reset to 0 and not 1 otherwise it will start from 1 to 2 (one loop) and not from 0 to 2 (2 loops)
- I've blocked the pending open by the IF condition related to the counter to make sure only 2 loops are performed. In your previous example the Boolean check is not doing his job as the reset is sitting outside the Loop viewer I believe. I'll let you analyze and test further the attached flow. Your comments are welcome!

Cheers !


Attachments:
Default_1.03_2.vfs [45.05 KiB]
Downloaded 131 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: Loops and Get Historical Candles in revers order. Post rating: 0   New post Posted: Tue 02 Jun, 2015, 12:03 
User avatar

User rating: 0
Joined: Sun 01 Feb, 2015, 22:49
Posts: 81
Location: RomaniaRomania
Hi,

This is the final solution I have reached. Not the most elegant, but can't see a way to improve it.

Image


Thank you for the help.
This thread can be closed.

Cheers,
mosu_d


Attachments:
Loop and Order.png [85.32 KiB]
Downloaded 587 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: Loops and Get Historical Candles in revers order. Post rating: 0   New post Posted: Thu 04 Jun, 2015, 08:56 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Just to add a precision:

The variable "Candle amount" of "Get Historical Candles" block is used to select the number of previous candles data to be retrieved and stored as an array of data and NOT the number of loops to be performed by loop viewer block.
In other words, when ONE loop is made, the information related to the 4 previous candles is retrieved and stored in the output of the loop viewer. Up to the user to decide how to use these data.

Your last post became quite ambiguous with regards to the initial requirement. The use of the dynamic shift value is understood and is a common method to work with dynamic shift but I can't see the sense here.

Cheers


 

Jump to:  

cron
  © 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