Click here to Login





                                                   Creating indicators

  0

0 1 - Next
allan nathan
2012-01-21 23:29:40


Hi,
I am trying to code up Historical Volatility.

This is the formula from another program I use.

Its a bit confusing as to where I code a simple indicator in QS using QS language.

Create functions,vs indicators,vs formulas??

If you could guide me to where i would program the code below,that would be great.Is there a lesson on coding a simple indicator?Maybe I missed it

Days= Param( "Days", 12, 2, 252 );
logchange=log(C/Ref(C,-1));
sdlogchange=StDev(logchange,Days );
HisVol=sdlogchange*100*sqrt(252);
Plot(HisVol,"HVol",colorBlue,styleLine);




allan nathan
2012-01-22 23:52:06

  0

Best Answer
It appears that one creates an indicator by selecting tools>create function.

Where it is a bit confusing is how I proceed from there.It appears your method of coding an indicator in QS is a bit more complex than Amibroker.Hopefully I am wrong.

Here are instructions you gave


1- Select "Tools" then "Create functions".
2- Click "Add" and type in your indicator name
3- Select the indicator in the left panel

- Type in the following code:
4 result = cFunctions.CompileFormula("a = rule;").GetVectorDouble("a");
5- Replace "rule" by your own rule
6- Click on "Save".

I dont understand rule 4.what is cfunctions.compileformula????

Do I need that to code a simple formula??

I have spent hours trying to fugure this out

thank you,

Allan












QuantShare
2012-01-23 05:17:41

  0

You can type the following formula by right clicking on a pane then selecting "Update Formula":

logchange=log(close/Ref(close,1));
sdlogchange=stddev(logchange,12);
HisVol=sdlogchange*100*sqrt(252);
Plot(HisVol,"HVol",colorBlue,ChartLine);

Or you can create a custom indicator and then use the historical volatility as follows:

Example:

HisVol=HisVolIndicator();
Plot(HisVol,"HVol",colorBlue,ChartLine);

Please read this:

http://www.quantshare.com/sa-369-the-custom-trading-indicators-tool-explained
http://www.quantshare.com/sa-372-custom-indicator-moving-average-spread
http://www.quantshare.com/sa-376-custom-indicator-relative-strength
http://www.quantshare.com/sa-381-custom-indicator-accumulation-distribution-line



allan nathan
2012-01-23 08:43:01

  0

Thanks ...I did read thru all the examples of custom indicators,but I dont believe there are any examples of coding a simple indicator and how to easily code it with Quant share.

When I right click on a pane,there is no "Update Formula" option.There is an Update Formula Dynamically,but that does not appear to do the trick.

Where is this Update Formula option?????
Do you mean Edit Formula??????


When I right click on a pane,there is also a selection "Indicators">Add Indicator. That is the logical place to add an indicator.

You have a great product that makes some very difficult tasks relatively easy,but some of your labeling of things can be very confusing.

Perhaps you can blog on creating a simple formula using QS,and do it step by step including variable parameters.My apologies if you have done so already.

Thank you

Allan








QuantShare
2012-01-23 09:42:14

  1

Sorry, it is "Edit Formula".

"Indicators->Add Indicator" adds an indicator implemented using QuantShare language

"Tools-Create Functions" creates advanced indicators using C#



allan nathan
2012-01-23 09:51:51

  1

Now that makes life alot easier!!!!

Perhaps you should create another "How To" lesson that summarises the methods of creating indicators.

When you say Edit,its a bit confusing.To me Edit is much different than CreateTo be consistent,I would use the word Create or Create/Edit QS..








allan nathan
2012-01-23 10:14:17

  0

Just to be sure..After creating the indicator,when I go to save it,which folder do I save it to? I assume "Indicators"??

How does one add parameters to a formula.Is it as simple as

Days= Param( "Days", 12, 2, 252 );

Thanks,

Allan



QuantShare
2012-01-24 04:54:26

  0

Save it under "Formulas" folder (in "Indicators" or any other sub-folder) so that you can find it in "View -> Formulas/Indicators"

Here is how to add a parameter:
Days = Param("Days", 12, 12);

// No need to specify a max and min values



clonex
2012-01-24 18:44:12

  0

yes i agree. We all appreciate more "how to lessons" about programming . Thanks


allan nathan
2012-02-05 00:52:12

  0

Hi,
I am really lost. Is there a simple way of coding an indicator using QS language without coding in C#???

I understand you can add a pane>edit formula and type in a formula.That appears to go into the Formula list,unless I am mistaken.If I click on the + (add a function)in a pane,my indicator will not appear.

How does one SIMPLY code using QS language so their indicator will show up when one clicks on +(add a function)
It appears there is no way,and one must use C#.Am I correct?

If I am correct,when I create a formula(add pane>edit formula) can that formula be accessed in screens and backtests??It doesnt look like it.Other than graph that formula,what can I do with it?

thanks,

Allan






QuantShare
2012-02-05 04:08:51

  0

Right, you must use C# to create indicators.

You can reference QS Language in C# and here is how:
result = cFunctions.CompileFormula("a = rsi(14);").GetVectorDouble("a");

---------------

When you save a formula from QS code, you can easily load this formula in screener, watchlist or simulator because they all share the same formula editor.

Click on the button next to "Add Indicator" then select "Load Formula".



allan nathan
2012-02-05 23:51:23

  0

Hi,
I am afraid that using C# at this point is above my head.I could probably figure it out if I was using fields like Rsi(14).Where I am getting very confused is attempting to create a custom indicator from the code above.I did create a formula(edit function) of HisVol


logchange=log(close/Ref(close,1));
sdlogchange=stddev(logchange,12);
HisVol=sdlogchange*100*sqrt(252);
Plot(HisVol,"HVol",colorBlue,ChartLine);

I dont quite understand formula vs custom indicator.It doesnt appear I can reference a custom formula when creating a custom indicator.Would you be kind enough to show me how one creates a custom indicator for the formula above?I did try using

VectorD a = TA.HisVoli(period);
result = a;

(I substituted Ta.HisVol for Rsi(14) in the example)

Also,the button you instructed to click on is next to Add method,not Add Indicator.








QuantShare
2012-02-06 05:56:24

  0

There are 2 ways to create a custom indicator from your formula:

result = cFunctions.CompileFormula("logchange=log(close/Ref(close,1));sdlogchange=stddev(logchange,12); HisVol=sdlogchange*100*sqrt(252);").GetVectorDouble("HisVol");

OR

VectorD close = cFunctions.Close;
VectorD logchange = TA.Log(close/TA.Ref(close,1));
VectorD sdlogchange = TA.Stddev(logchange,12);
VectorD HisVol = sdlogchange*100*TA.Sqrt(252);
result = HisVol;


Also, the button you instructed to click on is next to Add method,not Add Indicator.

It depends on the control (It is next to "Add Indicator" when you right click on a chart and select "Edit Formula")




allan nathan
2012-02-06 09:59:04

  0

Hi,
That is extremely helpful.
Is one example J script and the other C#??They are both fairly easy to work with
I am downloading custom indicators and going over different examples.

When I am coding a system and select "Load Formula"( the HisVol formula I created in formulas),it deletes any code I have written.Does that have something to do with the Lock/Unlock button?

Am I correct that if one wants to code custom formula/indicator without c# or jscript,one may do so by using "Edit Formula".The only way to do that is by adding a pane and "Edit Formula".I dont see this explained in any of the documentation.Did I overlook it?


Thanks for all the help.Its starting to make sense!

Allan



QuantShare
2012-02-06 10:42:22

  0

Both examples are implemented in C#. They perform the same thing but in different manner.

By selecting "Load Formula", you are replacing the existing formula with a new one.

Right, to save a QuantShare formula, you have to right click on a chart then select "Edit Formula". We will add a "Save Formula" option next to "Load Formula".



allan nathan
2012-02-06 14:48:38

  0

Hi,
I find "Load Fprmula" to be very confusing if it REPLACES the existing formula. "Load" a formula,should not delete everything one has coded..FYI the same thing happened in screener.Having a "Save Formula" is nice,but you really arent adressing the issue.Load does not equal replace.Keep it simple.

Also,when I click on the shortcut button and select Indicators,it brings up" Formulas".If they arent indicators and are Formulas,why dont you label the button Formula?????? Its way too confusing,but I finally am understanding the interface.

Allan







QuantShare
2012-02-07 07:40:17

  0

Hi,

There is a dialog box that warns you that loading a formula will update the current one.

"Load Formula" = Load it from a file

"Also,when I click on the shortcut button and select Indicators"

Which shortcut button are you referring to?



umair
2013-02-18 03:55:34

  0

Hi, i'm not going to create a newer thread b/c I think this one contains lots of valuable info.

1) QS language is easy to learn... why not allow QS to make indicators using QS language?? why does it have to be in C# (even though we can use TA.)

2) i created two indicators (indicatorA and indicatorB). both of these indicators give me a "1" value when the logic in them is true. When i plot them on the chart.. they both work fine.

Now i'm trying to create a third indicator by combing the first two indicators.

VectorD a = indicatorA + indicatorB;
result = a >1;

I get a error '' indicatorA is not initialzed"

or if I try:

VectorD a = indicatorA(open,close) + indicatorB(high,close);
result = a >1;

open,close,high,close are parameters

i get an error ''indicatora is a variable but is used like a method. indicator b is a variable but is used like a method.''



umair
2013-02-18 06:47:08

  0

Finally got it to work.. ended up creating all three indicators in one indicator.

Now the problem i'm facing is using this custom made indicator during simulation/backtesting

The indicator works fine when added to the chart.

buy rule = indicatora > .50

for some reason i'm not getting any trades.

only thing i can think of is that my indicator used "ref(close,1)" etc rather than histoprice.... and since ref.. refers to EOD data... and my backtest is intraday.. that could be the reason why i'm not getting any hits??



umair
2013-02-18 06:52:46

  0

and why is it that when i load my indicator in my backtest scripting screen... it appears to have all the ''parameters'' that I used in scripting the indicator in create function tool?

indicatora(OPEN,CLOSE,HIGH)



No more messages
0 1 - Next




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
Technical indicators time series
Plot Economic Indicators on a Chart
Trading Rules using Trend Indicators
Crossover/Convergence of Several Trading indicators
Job Creation Index

How-to Lessons
How to drag & drop indicators in charts
How to add a trading indicator to a chart
Difference between the watchlist and the screener tools
How to import trading items from other accounts
How to filter stocks in a market composite

Related Forum Threads
Making available indicators read-only
How to trade one symbol based on indicators of another?
caption / labeling of indicators etc.
Time cycle indicators
trading indicators

Blog Posts
Composite Indicators
Learn How to Create Your Own Technical Analysis Indicators
Correlation of market indicators
How to create your own technical analysis indicators
How to create market indicators using the composite function - Pa...









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 2014 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.