Click here to Login





                                                   How to update the custom variables (var1,var2,...) in a position ?

  0

0
Ludwig Avonts
2016-11-27 06:11:33


I want to store some informatio in the var1 custom variable in the OnNewPosition event and to be able to retrieve it later (e.g. in the OnClosePosition event).
I this possible ? How to do this ?



QuantShare
2016-11-28 02:53:26

  0

Yes it is.

You can create a dictionary or hastable in the "Global" event. In the OnNewPosition you could store the symbol name and the variable to save.
Example:
dic.Add(NewPosition.Symbol, 10);

And in the OnClosePosition, something like this:
string symbol = Functions.GetPositionDetails().Symbol;
object var1 = dic[symbol];
dic.Remove(symbol);



Ludwig Avonts
2016-11-28 14:55:34

  0

Thanks. I was more referring to the predefined properties var1, var2, etc. of the class MMPosition.
Is it possible to update those fields in the OnNewPosition and retrieve the values in the OnEndPeriod or OnClosePosition event ?
Your solution is workable, but using the predefined custom variables seems easier (if it works...).



QuantShare
2016-11-28 15:29:58

  0

This is not possible. These variables are not available in the OnNewPosition event.
Thank you.



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
How far are the close prices from the support line
Update the Industry Name of your U.S. Stocks
Update the Stock Exchange Associated With U.S. Stocks - Market Fi...
Trading System Template: Position Sizing Techniques
Exit Position based on Profitability

How-to Lessons
How to dynamically update the settings of an indicator
How to plot a time-series that do not update the chart scale
How to plot the number of stock tweets per day
How to add a metric in the trading system simulation report
How to automate the data downloading process

Related Forum Threads
How do I find the close price for an entry matching a custom DB
How do I reduce a position size from within the Money Management
How do I get the date of the current bar in a custom function?
How do I use variables in Money Management Scripts?
How to update NSE/BSE symbols in QuantShare?

Blog Posts
How to combine long, short and custom portfolio strategies within...
How to measure market strength with the composite tool
Fundamental analysis: How to track economic indicators in the For...
How to Create a Custom Real-Time Table using QS Trading Software
Custom Shortcuts - Move a Chart to Display the Last Quotes/Data









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.