Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

How to recognise position added as a last one?
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=146&t=51668
Page 1 of 1

Author:  nine99 [ Tue 16 Sep, 2014, 14:55 ]
Post subject:  How to recognise position added as a last one?

Good morning,

i have gained some knowledge about using Visual Jforex to this day, but i've found a 'task' which i have troubles in getting through.

Let's say: Our strategy, in some circumstances, openes positions - we never know how many of positions may appear, number of positions in our strategy isn't fixed, or restricted in any way. There can be for example 3, just as well there can be 14 pending positions, or filled positions at the same time and there is no way of 'predicting' number of them.

And now, my problem:
how could i send some commands to NEWEST position only...?

If we would have, let's say, max 2 positions at a time, it would be very simple. We could just 'name' positions by using 'output value' in 'open at market' or 'pending order' block, and then compare 'create time' of those 2 positions in 'calculation' block, to see which creation time is bigger.

But if we don't know how many position they may be, how could we 'tell' the Visual Jforex, that we want to send commands >>only<< to position, that was added, or opened, or filled as last?

My little thoughts about possibilities of solving that:

1. making mechanism, which compares any creation time of all existing positions, and 'picking up' the largest value. Visual jforex has unix time, so bigger time value = later.
I'm not able to find blocks which can make it, i mean - function like 'compare all opening times and pick up biggest one'.

2. having somethins like 'get historical candle' - 'shift' function. If i place in 'get historical candle' block 'shift' 0 - it means 'newest candle', 'Shift' 1 - means previous, etc. I don't see something like that for positions.

3. making mechanism which is automatically naming positions with some numbers, like - first positions named 'position1', next one 'position2' etc - and than a mechanism, that somehow 'reads and understands' which position label has the greatest number value.

I'm not trying to say, that it is important to me to solve this problem at any particular way, i'm just showing up my thoughts. I just need any 'working answer' :)

I'm just wasting time now by being not able to work this at my own,
please write me a solution, i would be truly grateful,


Thank You in advance,
nine99

Author:  nine99 [ Wed 17 Sep, 2014, 20:21 ]
Post subject:  Re: How to recognise position added as a last one?

Please, help me to solve this problem,
thank You.

Author:  amine_chourou [ Thu 18 Sep, 2014, 14:13 ]
Post subject:  Re: How to recognise position added as a last one?

Greetings,

Thanks for your post.
It is possible to identify your orders/ positions based on several criteria but the main question would be Why you need to identify them by sending time ??
Any open position or pending order can be monitored by several conditions (status / price / indicator levels / P&L / and much more...) using loop functions that performs real time checks, in our case it would be the Position Viewer block.
Limiting the positions number is not mandatory for a given strategy you can easily bypass such use.

Please describe in depth the way you want to manage your positions based on concrete example and we'll do our best to help you.

Thanks

Author:  amine_chourou [ Fri 19 Sep, 2014, 13:33 ]
Post subject:  Re: How to recognise position added as a last one?

Hi again,

Here is a genius example inspired by an idea of our dev team lead which initially developed a strategy to close half of the opened positions. Using a simple counter and a calculation block, the idea was to divide the available number of open positions by 2 and close this half (whatever the number of the opened positions)
I modified this in order to have a subtraction instead and an order identification based on its creation time. As a result for this example, any open position will be systematically closed except the first one. Up to you to enhance the closing conditions based on your criteria.

Cheers!

Attachments:
HalfPositionsDemo.vfs [28.68 KiB]
Downloaded 98 times

  Page 1 of 1