Click here to Login





                                                   Functions in Global Tab

  0

0
Vangelis M.
2014-05-28 21:29:50


Hello,

When I am working on various AMM scripts, I often use the same logic. So I place them in functions.

I usually place those functions under the "Global" Tab. Is that the best place to define a function? If yes, can I avoid passing Portfolio, Data, Orders and other objects to the function?

An example: I created a function that re-balances to target percent of equity. In the Globals Tab I had to pass all these objects:

public void orderTargetPercent(MMPortfolio Portfolio, MMData Data,MMOnEndPeriod Functions,MMOrders Orders, string symbol, double percent)
{...
}

Is this a good way to do this?

Thanks



QuantShare
2014-05-29 07:30:45

  0

Yes, it is better to place them under "Global" tab.

You should of course only pass variables that are needed by the function.

To avoid passing these variables to the function, you can do the following:

[GLOBAL]
MMPortfolio portfolio;

public void orderTargetPercent(MMPortfolio Portfolio, string symbol, double percent)
{
}

[OnEndPeriod]
portfolio = Portfolio;




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
Set Global Variable
Global Sector Rotation Strategy V1.0
Global Market Rotation Strategy V1.4
Global Market Rotation Strategy V1.1
Global Market Rotation Strategy V1.0

How-to Lessons
How to get stocks for a particular index using the global script
How to create a custom trading indicator
How to debug a trading system using the money management tool
How to plot the relative performance of several stocks/indices
How to automatically start a downloader every few minutes?

Related Forum Threads
Set Global variable and running calculation Functions in MM scrip...
Can you access custom functions from the downloader script events...
QS language functions color & font
Set Global Variable Between Strategy and AMM
Clear Symbol data stored in memory in global script

Blog Posts
QS Trading Software: Global Script
Charting & Scripts - Manage stock charts using the global script
Trading Indicators using the Rank and Percentile functions
New Ranking and Percentile Composite Functions
Display several stock market charts with one click









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.