Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Distance from 50EMA Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
spdudek
Posted : Wednesday, January 19, 2011 3:28:30 PM
Registered User
Joined: 2/18/2008
Posts: 20
Can you provide me with the real code to add an indicator that plots below my price chart? What I want to plot is a price bar's distance from the 50EMA as a percentage of the 50 EMA. So if the price is above the 50 EMA, I want: (low of the current bar minus the current 50 EMA value)/50EMA * 100. If the price is below the 50 EMA I want: (50 EMA - high of the current bar)/50EMA *100. Thanks!
Bruce_L
Posted : Wednesday, January 19, 2011 3:45:07 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
If you Drag and Drop the Moving Average from the Chart into the Code tab of the RealCode Editor, it should create something similar to the first line of the RealCode Indicator:

RealCode for Real People: Indicators

'# MA = chart.MovingAverage
If Price.Low > MA.Value Then
    Plot = (Price.Low - MA.Value) / MA.Value * 100
Else If Price.High < MA.Value Then
    Plot = (MA.Value - Price.High) / MA.Value * 100
Else
    Plot = 0
End If

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
spdudek
Posted : Wednesday, January 19, 2011 4:14:34 PM
Registered User
Joined: 2/18/2008
Posts: 20
Perfect! Thank you again.
Bruce_L
Posted : Wednesday, January 19, 2011 4:15:20 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
spdudek
Posted : Wednesday, January 19, 2011 7:06:50 PM
Registered User
Joined: 2/18/2008
Posts: 20
Can you tell me how to add a paint scheme that will change the price bars from green to red where this indicator is greater than a certain value? For example, I'd like a red price bar when this indicator is greater than 1.0. Thanks again.
Bruce_L
Posted : Thursday, January 20, 2011 9:17:56 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Right-click on the RealCode Indicator and select Create Condition | Greater Than: 1.0 and adjust the color of the Condition to Red.

Creating Conditions

Then Drag and Drop the Condition to Price History and select Add to Paint Scheme.

Paint Schemes

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.