Price difference from a moving average


0
0

Is there a way on Sierra to calculate the distance (Price) from the trailing ema without having to do it manually?  How far is the top of the current bar in relationship to the ema if price is going up and if price is going down the price relationship from the low of the bar to the ema.

Marked as spam
Posted by (Questions: 4, Answers: 8)
Asked on June 4, 2018 6:28 pm
504 views
0

You want to plot this in a lower subgraph? How to measure “if price it going up” and “if price is going down”? You see that? When you say, how far is the high below the ema, This automatically declares that prices are going down, not up. So you have a bit of a contradiction here until you explain things further. Why did you neglect to provide a screenshot with your quest??? This could have explained all the details missing from your very brief specification.

( at June 4, 2018 6:59 pm)
0

Reminder, still waiting for Wayne Popham to provide additional details as requested.

( at June 10, 2018 8:38 am)
0

I got the idea for the question from PAT’s trading on Youtube. They use only trend lines and a 21 ema. the Question was intended to assume that the market that one is looking out was in a trend if up higher highs and lower lows and a down trend lower lows and lower highs. We all know that markets are never trending at all times.and the markets consolidate or chop whatever one might want to call it. In an up trend the further the top of the price gets from the 21 ema, when it does this the market is closer to a retractment

( at June 10, 2018 10:11 am)
0

Or in a down trend the lower the price the further it get from the 21 ema. I don’t care if the distance is shown on the main price graph or lower in an indicator section.

( at June 10, 2018 10:18 am)
0
Private answer

Ok, thanks for the clarifications Wayne. The solution is presented here in the following three screenshots. As I have explained in a previous post, exactly how the plots of the chart as well as other studies are referenced using formulas.

The chart data O, H ,L , C, V is referenced using the base element of ID0. Each item within the chart data is referenced by it’s subgraph element. So that ID0.SG1 is equivalent to the Open price of each bar on the chart.

When you add a new study to the chart, it gets assigned a unique ID# based on the order in which it was added to the chart. In my example the first study I added was a simple moving average. To reference the value of this study we use the following: ID1.SG1

Once you get the hang of this it will really open up a lot of doors. We use the study named “Spreadsheet Formula” to contain and plot the formula that subtracts the value of each bar’s close from the value of each bar’s simple moving average:

ID0.SG4-ID1.SG1

Important Note: I used a simple moving average here whereas Wayne requested an exponential moving average. You can use whatever moving average you like, just make sure it is the very first study you add to the chart!

I added the study named “Line” to act as the zero line, since the output of the formula oscillates across the zero line.

If you know anything about the MACD study, you could have very easily accomplished the same thing just by changing the settings. Anyone that wants to take a shot at this, be sure to post your solution as a new answer to this topic.

You may want to express this value as a percent, to make this scaleable across a wide variety of instruments. The following formula will plot the percentage difference between close and simple moving average:

100 * (ID1.SG1 / ID0.SG4 - 1)

 

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on June 10, 2018 11:26 am
0

Thank you Pete for the answer. I didn’t even know that spreadsheet formula was on Sierra. the indicator is working well. Thanks again!!
Wayne

( at June 15, 2018 2:28 pm)
0
Pete I tweeted the solution you gave me. I made two 21 ema’s one using the high, the other using the low and attached 2 spreadsheet formulas one scaled independent of each one and both on the 2nd level. I look for the two be either both positive values for an up move or both to be negative for a down move.now I was trying to write a color background based on price alert. but its not working. I tried AND(ID3.SG1>-1,ID4.SG1>-1) ID3 AND ID4 being the speadsheet ID’s. can you help me out again? This is for the positive values for an up move. Thanks. Wayne
( at July 9, 2018 4:59 pm)
0

For an alert that changes background, the formula must evaluate to true/false value.

AND(ID3.SG1>-1,ID4.SG1-1)

This does not evaluate to true/false value. Did you mean to type: AND(ID3.SG1 > -1,ID4.SG1 > -1)

This would mean that both ID3 and ID4 subgraphs must be greater than -1. But seems to me you are looking for positive value and should be using greater than zero instead of greater than minus one???

( at July 9, 2018 5:14 pm)
0
Pete I edited my the question. I consider 0 as a positive value for the up move and 0 a negative value for the down moves. I tried AND(ID3.SG1>-1,ID4.SG1>-1) for an up move. AND(ID3.SG1<1,ID4.SG1<1) for the down
( at July 9, 2018 5:35 pm)
0

Have checked this post to see how we change the candle color? https://www.hahn-tech.com/sierra-chart-solutions/

Otherwise you will need to post a new question for this. Include screenshots so we can clearly see and replicate your chart layout.

( at July 9, 2018 6:00 pm)