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

Can't update the Position.Comment after the position has been created.
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=146&t=52847
Page 1 of 1

Author:  mosu_d [ Tue 23 Jun, 2015, 21:52 ]
Post subject:  Can't update the Position.Comment after the position has been created.

Hi,

I want to store some run-time variable in the Position.Comment.
but can't after the position has been created.

If I attempt to do this with an Assign block I get
"you can't put here read only variables"

This would be very helpful because I get the comment in the report.

Regards,
mosu_d

Author:  amine_chourou [ Thu 25 Jun, 2015, 09:48 ]
Post subject:  Re: Can't update the Position.Comment after the position has been created.

Hi,

The run-time parameters information is available at the end of every test in both VJF and Jforex historical tester, here below the VJF one:

Image

If you need to include these information as a comment in your trading command, you can still write this in a dedicated variable with the type string and insert it.

Else; please advice


Cheers

Attachments:
RunTimeParam.JPG [23.58 KiB]
Downloaded 342 times

Author:  mosu_d [ Mon 29 Jun, 2015, 21:02 ]
Post subject:  Re: Can't update the Position.Comment after the position has been created.

Hi,

I am not referring to the strategy input parameters.

I want to save computed values into the Position.Comment,
not with the constructor (when the position is opened), but afterwards, when the position is still pending.
Image

This would help me to make some statistical analysis if I manage to gather the data.
If you allow me to extend the topic, the generic question would be:
Is there a way I can generate logging output to some console? Like print variable X to console if some condition is met.

Regards,
mosu_d

Attachments:
UpdatePositionComment.png [53.7 KiB]
Downloaded 317 times

Author:  amine_chourou [ Thu 02 Jul, 2015, 12:42 ]
Post subject:  Re: Can't update the Position.Comment after the position has been created.

Hi,

I see what you meant.
Unfortunately the option to "print" a message is not available but it is under discussion for future implementation. There is no plan communicated as it is still under feasibility study.

The variable comment (when used) is attached as it is to the order command when triggered. If you need to assign a comment based on a specific event you can still create a custom variable and assign a different comment:


Image

If you're using read-only variables, it is not possible to overwrite a value as you may noticed.
So basically you need to assign a comment to a pending order (Limit /Stop /MIT) after being sent to the market and before getting executed ? is this correct ?

details details details are more than welcome !

Author:  mosu_d [ Fri 03 Jul, 2015, 22:30 ]
Post subject:  Re: Can't update the Position.Comment after the position has been created.

Hi Amine,

Following the advice from your reply I have updated my strategy and it works (very surprising for me !!!).
But thank you.

What I did:

1. Create sting variable positionText with Initial Value = Initial Text

2. Added this to the Position definition
Image

3. Updated the variable positionText when the price was ~ close to my position
Image

4. Exported strategy and run it in Historical Tester on jForex. See report at the end:
Image

But this is not very useful yet.
Now going further, I wanted to assign in the Trade.Comment a Double variable. As you can imagine, a similar error was raised. Which is a shame. Java has automatic casting.

5. Find my text in the .java strategy
Image

6. And update "comsa"
Image

7. Exported strategy and run it in Historical Tester on jForex. See report at the end:
Image

This is useful now....
But it all can be avoided if you would create a setter method to the Trade.Comment as it has for SL and TP.

Attachments:
5.png [7.56 KiB]
Downloaded 315 times
6.png [39.97 KiB]
Downloaded 276 times
5.png [7.56 KiB]
Downloaded 189 times
4.png [7.3 KiB]
Downloaded 292 times
3.png [19.93 KiB]
Downloaded 299 times
2.png [35 KiB]
Downloaded 290 times
1.png [17.87 KiB]
Downloaded 324 times

Author:  mosu_d [ Fri 03 Jul, 2015, 22:37 ]
Post subject:  Re: Can't update the Position.Comment after the position has been created.

.... Ran out of space to attach pictures ;/


This is useful now....
But it all can be avoided if you would create a setter method to the Trade.Comment as it has for SL and TP.
Image


As a conclusion, this is a workaround for console printing. Ugly and inefficient...

But now I see there is a setLabel which (I guess) prints it directly on the chart. This would be interesting.

Cheers,
mosu_d.

Attachments:
7.png [16.06 KiB]
Downloaded 331 times

  Page 1 of 1