Click here to Login

                                                   Retrieving or storing previous indicator result.


2011-10-03 18:28:22

I need a way to compare the results from a custom indicator for the present close against the previous close as part of the indicator processing.
The indicator itself gets a result over a specified period but it is not clear how to store it so it can be used as part of the next close.
I have tried using Global.GetVariable\SetVariable, but it does not appear to be storing the information when run as part of the indicator script.
Is there something I am missing? Is there a straight forward way to compile the indicator for the current and previous close in one shot?

Thanks in advance.

2011-10-04 17:35:15


What do you mean by the "next close". Next bar?

I am not sure I understand exactly what you are trying to do.

2011-10-04 23:38:12


Sure next bar. I want to store the indicator result for the previous bar's value so I can compare it to the indicator result of the current bar. This needs to happen for every bar. I want to be able to flag a change in the result and disregard subsequent results that are equal assuming the indicator returns 1 or 0. Flag 0->1 or 1->0; discard 1->1 or 0->0.

2011-10-05 06:06:56


Can you please send your indicator to

2011-10-12 19:02:19


I was able to figure this out and I got the indicator working.

Using the "Create Functions" to develop the indicator, it seems only one result can be returned at a time. I need to run my indicator multiple times to get results for differnt modes. I can change it to one iteration if I can return more that one result array per indicator invocation. Is there a way to return more that one result array per indicator call?
If not, what about storing the numeric array for each result that I need globally and then retrieve them by calling a separate helper scripts. Will the stored arrays persistent in memory after the first indicator complete so that other scripts can retrieve the information?

Lastly, the indicator does not run automatically when I start up the quantshare. Some times I have to edit the and save the indicator code before it starts working again. How do I fix that?

2011-10-13 04:29:36


Yes, only one result can be returned at a time.

You can however add a parameter and then change the return value depending on this parameter.
This way you can return different results depending on the value of the parameter you provide.

You can also use "Global" variable to save data globally. Data is kept in memory after the indicator calculation is completed.

Regarding your indicator:
Which version of QuantShare are you using?
What happens when it does not run automatically?

2011-10-19 15:11:32


I was able to use "Global" variable to retrieve multiple results. Thanks.

However, I am still having the problem with my indicators run with I start up Quantshare. The version I am using is Premium 2.4.4. I have it the final set of indicators called as a formula under "Trading Rule". So at the very least I would need to double click for the calulation to begin and the resulting data applied to the chart. But this does not happen. No matter how many time I click it on the formula, the indicators do not run. I actually have to go to each indicator and force it to recompile during the current session before formula with custom indicators work. Is the "Trading Rules" correct place for the custom indicator?

Note there is an entry for the my formula under the "Update Formular Dynamically" drop down at quantshare startup but it does not run even after I double click on it. It just taking a lot of time to get things working which I would like to avoid. Any ideas how to resolve this?

2011-10-21 05:45:44


Can you please send the last trace files to

You can find the "Trace" directory under "QuantShare" directory

Vangelis M.
2011-10-30 19:55:50


I am having the same problem (QS 2.5.2)
It seems Global cannot be created from the Indicator Formula. (works fine in C# editor)

I am basically trying to set and retrieve a Global Var from the Indicator Formula so I can plot it.

I created two Functions :
SetMember(string1,string2,VectorD1) --->Global.SetVariable( string1[0] + string2[0] , value );
GetMember(string1,string2) --->result.Assign((VectorD)Global.GetVariable(string1[0]+string2[0]));

Now when i write in the Indicator formula:
z=SetMember("a","b",rsi(14)) ;
plot(GetMember("a","b") ,"",colorBlack);

It works the first time. If I quit QS and reopen, it does not work. If I go and edit the function in "Create Functions" tool and then "Save", then it works again.


2011-10-31 07:26:29


I was able to reproduce this issue. Thank you for reporting it. It will be fixed in the next release.

Vangelis M.
2011-12-02 09:15:21


As far as I can tell, this issue (see previous post) was fixed in QS 2.5.3. as promised .
Thank you QS.


2011-12-02 10:53:45


Best Answer
Yes, fixed in this new version

2011-12-02 20:49:02


I noticed that it is fixed as well. Thanks for resolved the issue so quickly.

No more messages


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"


Trading Items
Buy Indicator
Triple Period Indicator
Swing Trading Indicator (STI)
Traders Dynamic Index - TDI Indicator
MSR Support-Resistance Trading Indicator

How-to Lessons
How to optimize an indicator in your trading system
How to dynamically update the settings of an indicator
How to create a moving average of an indicator
How to add a trading indicator to a chart
How to install the previous version of QuantShare

Related Forum Threads
Previous day value for indicator in Screener?
Previous day OHLC
cycles indicator
Indicator in a report
Keltner Channel Indicator

Blog Posts
Detect chart patterns using the auto support/resistance indicator
How to Select the Best Market Indicator for your Trading System
Backtesting chart patterns using the auto support and resistance ...
Create a stock index or a trading indicator using the composite t...
How to create the advance/decline market breadth indicator

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2024
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
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.