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

Enhancement request to add new variables to a Position.
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=140&t=53147
Page 1 of 1

Author:  mosu_d [ Tue 15 Sep, 2015, 22:48 ]
Post subject:  Enhancement request to add new variables to a Position.

Hi,

Requirement:
To add new variables to a Position, similar to Position.Comment
with getter and setter methods.

Reason:
Order management:
After placing an Order, there is no contextual information regarding the market situation when the order was placed.
For example, placing orders based on fibonacci levels. There are situations when (as a human) it is obvious the pattern got broken (while the order is still pending) and should be updated or canceled.

This is impossible to do in a strategy if you have several pending orders at the same time,
unless some value can be saved in the position itself.

My workaround:
1. I am placing one value in the Position.Comment. But Position.Comment has no setter, I can only give it a value with the Position object constructor at creation time. This is done by the Calculation Expression that handles this correctly(unexpectedly...).
Image

2. retrieve the value by updating the Java code
Double.parseDouble(_currentPosition.getComment());
and some dummy block used to host this code.

Step 2 is not very nice... and this leads me to
Enhancement request for adding string to double function to Calculation Expression.


Another example for extra variables:
Suppose I have a scalping strategy and the price gets very close to the entry: Entry - Price = X
Then the price retraces past what would have been the TP.

This is a miss and the order should be canceled. But one can't know the X value if there are many pending orders leaving at the same time.

Regards,
mosu_d

Attachments:
Untitled.png [59.89 KiB]
Downloaded 643 times

Author:  amine_chourou [ Wed 16 Sep, 2015, 13:01 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Hi,

Did yo tried to create a new comment variable and gave it a start value then changing this afterwards (upon your conditions) ?


Image

Attachments:
Comment_dynamic.JPG [77.17 KiB]
Downloaded 478 times

Author:  mosu_d [ Thu 17 Sep, 2015, 12:12 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Hi Amine,

Yes, I tried, but the data gets mixed up between the positions.
This is because the Strategy variable is updated, not the Position.Comment.

There is no setter method for the Position.Comment. Just the getter.

We talked about this in thread
Can't update the Position.Comment after the position has been created.
Image

Image

This is becomes obvious when you assign the Position.Comment=Position.Label
The report in the JForex tester is mixed up.


Even if this would work, I still need to convert string to double. This is just one variable I hijacked. But I need more variables. I am thinking of using the Label also.
But this gets dangerous in the long run if dukascopy decides to change behaviour for these vars in the future.

Another example for extra variables:
Suppose I have a scalping strategy and the price gets very close to the entry: Entry - Price = X
Then the price retraces past what would have been the TP.

This is a miss and the order should be canceled. But one can't know the X value if there are many pending orders leaving at the same time.

Regards,
mosu_d

Attachments:
Untitled.png [14.66 KiB]
Downloaded 621 times
7.png [16.06 KiB]
Downloaded 642 times

Author:  amine_chourou [ Thu 01 Oct, 2015, 10:35 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Hi there,

We did not forgot you on this matter, it will be reviewed by our technical lead and answered asap.

Thanks

Author:  Visual Support [ Fri 02 Oct, 2015, 09:36 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Quote:
Reason:
Order management:
After placing an Order, there is no contextual information regarding the market situation when the order was placed.

It is not true. Position has getters for getting info when the order was placed:
Creation Time
Fill Time
Close Time

Author:  Visual Support [ Fri 02 Oct, 2015, 09:41 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Quote:
This is becomes obvious when you assign the Position.Comment=Position.Label
The report in the JForex tester is mixed up.

Why you need this? You already have Position.Label.

Quote:
Another example for extra variables:
Suppose I have a scalping strategy and the price gets very close to the entry: Entry - Price = X
Then the price retraces past what would have been the TP.

In this case you can use Comment, or you can set the SL or TP for this case, what would be more good in this case.

I still misunderstand the need of extra variable inside Position. Can you provide another examples?

Author:  mosu_d [ Sun 04 Oct, 2015, 00:13 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Hi Visual Support,

Thank you very much for your feedback.


Requirement:
To add new variables to a Position, similar to Position.Comment
with getter and setter methods: Position.Var1, Position.Var2, Position.Var3, etc.

Reason 1:
Order management:
After placing an Order, there is no contextual information regarding the market situation when the order was placed.
I agree that I can get Creation Time, Fill Time, Close Time and others. I see this as generic information available in all strategies and for all Positions.

The context is specific to a strategy. For example:
Placing orders based on Fibonacci levels. There are situations when (for a human) it is obvious the pattern got broken (while the order is still pending) and should be updated or cancelled.

Suppose we have the following chart:

Image

When the price is between 23% and 38% I can place a pending Buy order at 38% with TP at 23%.
If the price never gets to 38% and instead raises passed 0% level, the pattern is broken, the order should be closed.

This is impossible to do in a strategy if you have several pending orders at the same time,
unless 0% value (price) can be saved in the position itself and I check this context in my strategy.

My workaround:
I explained it above.
I would like to avoid it because it is error prone, and consumes resources when testing.





Reason 2:
Suppose I have a scalping strategy and the price gets very close to the entry: Entry - Price = X

Image

Then the price retraces past what would have been the TP, point A

This is a close miss and the order should be cancelled.
Instead the order is filled in point B.
Point C does not reach TP any more. Result is a loss because of a close miss.

This could be avoided but one can't save X value if there are many pending orders leaving at the same time,
unless X is saved and updated together with its respective position.



Reason 3:
If these extra variables Position.Var1, Position.Var2, Position.Var3
are displayed in the final report from JForex, as it happens now with Position.Comment,
one could create "sensors" in the strategy to gather statistical data on each Position

to improve the strategy parameters.


Hope this makes sense.
I updated my phone number in my profile if you need a short call.

Regards,
mosu_d

Attachments:
Untitled2.png [4.52 KiB]
Downloaded 475 times
Fib.png [18.74 KiB]
Downloaded 481 times

Author:  Visual Support [ Mon 05 Oct, 2015, 17:39 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Hello mosu_d :)

Sure, what you are asking is possible to impelement in Visual JForex.
But we already have the project plan, and this feature cant be implemented in near future.
This feature, seems to me, quite specific and it takes some time to be implemented and tested.

It is possible to avoid this feature using with current possibilities, sure those posibilities will not be so full and so comfortable.
If you will still have some problems, I will try to help you.

For example, when You create any position Market or Pending, you can set the Comment: 'position number 1'
And simultaneously you create the custom Variable with name: 'positionNumber1' and you can set and get from this variable any value, what you need.
Creating the strategy, inside it you will be able to link the position behaviour with associated variable.

Best Regards, Sergey

Author:  mosu_d [ Tue 06 Oct, 2015, 05:22 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Thank you Sergey,

If this could be added, it would save me from a lot of mess.

I did something like you say.
I track only the closest position to the price and update variables only if the position is the one tracked.

But... it is not very ergonomic as you can imagine.
And I have so many workarounds, it is hard to understand the strategy any more :)

God speed,
mosu_d

Author:  mosu_d [ Thu 07 Jan, 2016, 22:55 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Hi there,

Any news for adding new variables to a Position?

Thank you,
mosu_d

Author:  amine_chourou [ Mon 11 Jan, 2016, 16:45 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Hi,

As communicated in Sergey's post above, this feature is very specific and a workaround was proposed to tackle the initial need.
Please let us know if you need any help

Cheers

Author:  mosu_d [ Tue 02 Feb, 2016, 00:40 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Hi,

I understand; adding some "place holders" (variables) in a Position may not be such a great idea. It makes sense just for Visual JForex, but not for normal trading.

But at least, I beg of you, add a setComment() method in the default API, as you have the getComment().

Image


This is what I can do currently by setting the Comment before the Position is created:

Image

As I explained, a comment can't be updated after a position has been created because this method (setComment() ) does not exist. A comment can be given only by using the Position constructor on Position (object) creation (instantiation).
If I have this method, I can collect more meaningful statistical data, as the price gets close to my Position.


Another benefit would be:
adding meaningful comments when using "Close and Cancel Position" block.


Thank you very much,
mosu_d

Attachments:
Untitled2.png [38.54 KiB]
Downloaded 530 times
Untitled.png [14.66 KiB]
Downloaded 538 times

Author:  Visual Support [ Wed 03 Feb, 2016, 11:30 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

mosu_d wrote:
Hi,

But at least, I beg of you, add a setComment() method in the default API, as you have the getComment().

mosu_d

Hello

Speaking about "setComment()" in default API, it is quite easy to create in java own data structure or collection. Like Collection<String OrderId, String myComment> or
<IOrder order, String myComment> - and to update it by onMessage. You can easily use it.

Best Regards

Author:  mosu_d [ Sat 06 Feb, 2016, 01:43 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Dear Support,

I agree I could create my own variable / collection in the java sorce.

on the other hand...
1. placing the data in the Position.Comment allows me to display the data in the report (very, very important) (screenshot attached before)
I am already updating the java code to populate the Position.Comment before the position is created like:
_tradeComment = "loopCounter= " + _loopCounter+"</TD><TD>"+ " tradingDistance= "+String.format("%.2f", _tradingDistance)+"</TD><TD>" + " trendChange= "+String.format("%.2f", _trendChange)
+"%</TD><TD>" + " rsi= "+String.format("%.2f", _rsi)+"</TD><TD>" + " bbandDif= "+String.format("%.1f", (_upperBand - _lowerBand)*10000);


2. if I have my data in my own collection I can't print it in the report because the Position.Comment does not have a Setter method (like setComment()).

3. If you add Position.setComment() to the API, this will also be available in the Visual JForex, and I will not have to update the Java code on each small update I make in the Visual JForex.

4. I think you could agree that adding a Position.setComment() method would be a simple task
and the fact that is missing is... unexpected.

5. I have several scenarios in which I Close and Cancel a Position. It would be useful for me to have a way of placing a comment for the cancellation reason.


Hoping you would also see the benefits,
mosu_d

Author:  Visual Support [ Tue 09 Feb, 2016, 15:39 ]
Post subject:  Re: Enhancement request to add new variables to a Position.

Unfortunately, we have quite long list of next features and changes and most of them has more priority than "Comment Edit". So if it will be released, it will not be soon.

Best Regards, VJF Team

  Page 1 of 1