Click here to Login

                                                   Using getseries to calculate ema


2019-08-29 21:49:47


I'm trying to use a filter rule that gets the series for the SPY ETF and calculates an EMA to see if the SPY is closing above it's 75 average.

spy = getseries("SPY", close);
rule1 = spy > ema(spy,75);

Is this the correct way to express it ?

Also, if I want to see this formula expressed in a pane, is this the correct way of doing it ?

symbol = "SPY";
close1 = GetSeries(symbol, close);
open1 = GetSeries(symbol, open);
high1 = GetSeries(symbol, high);
low1 = GetSeries(symbol, low);

PlotCandleStick1(open1, high1, low1, close1, symbol, colorBlack, StyleOwnScale);
PrintChart(symbol, "", BottomLeft, colorBlack, colorTransparent, colorTransparent, 255);

symbol = "SPY";
close1 = GetSeries(symbol, close);
a = Ema(close1, 75);
Plot(a, "EMA", colorBlue, chartLine, StyleWidth2);


2019-09-02 21:41:08


Yes, it is correct. You can check that by plotting it on a chart.

2019-09-03 17:56:45


When using the pane as described above, I notice that if I zoom in/out using de number of bars slider, the EMA changes position. Is there a way to avoid this behaviour?


2019-09-12 10:59:54


Best Answer
Yes, you need to replace "StyleOwnScale" style in the formula with something like "StyleSymbolNone" to force the plot to use the default scale.

2019-09-12 16:50:45


Thanks ! That worked.

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
Trading rules using the VIX Index
Double / Triple Smoothened EMA with Flexible Alpha
Investing in stocks using the Kelly criterion money management st...
Market Volatility - Composite Indicator using Stocks Standard Dev...
Stock Ranking using Rate of Change and SMA Volume

How-to Lessons
How to calculate the average of a time series using the money man...
How to plot a stock using different periods in the same chart
How to optimize a neural network using a genetic algorithm
How to get stocks for a particular index using the global script
How to debug a trading system using the money management tool

Related Forum Threads
Calculate total volatility of portfolio
Finding horizontal Support/Resistence lines using AutoSR
Ranking using Pivot Tables
Best practices for using a Global Variable
Problem drawing trend line using version 2.91

Blog Posts
Technical Analysis Using Multiple Timeframes
Forecast volatility using trading rules and neural networks
Detect chart patterns using the auto support/resistance indicator
Create indicators, composites and trading systems using QL and CS...
Basic trading system implemented using the money management tool

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

Copyright 2019
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.