READ-ONLY

The forum is now a read-only archive.

For bug reports & platform questions → [email protected]

Our community lives on Discord and YouTube — come join us!

What’s does Functions Indicator Angle mean?

3 replies

Truong Cao Xuan

Customer, bbp_participant, community, 9 replies.

Visit profile

6 years ago #250800

Can someone explain me what Functions Indicator Angle mean?

Example, When i set

Indicator: Simple Moving Average

Period: 3
Coefficient: 0.00005

What Value that function will return?

 

 

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

6 years ago #254717

Hello,

when you place a moving average on a chart for example you can see with an uptrend it raises up under a certain angle. This is the value this indicator “tries” to return. Please keep in mind it is tricky. Angle depends on the zoom of your chart, it is not absolute value only relative. But you can experiment with certain input values and report back your experience with this function

Attachments:
You must be logged in to view attached files.

0

Truong Cao Xuan

Customer, bbp_participant, community, 9 replies.

Visit profile

6 years ago #254913

Thanks you,

I will try some input value…

0

Jacky quan

Subscriber, bbp_participant, sq-ultimate, 1 replies.

Visit profile

8 months ago #292387

hi,

I want to use EMA slope as regime filter, the MT5 code logic as below, but I create the sqx block code, it seems not work. Cloud you give me some advice?

***********************************************

MT5 CORE CODE:

bool GetEMAAngle_PriceNorm(int shift, int lookback, double &angle)
{
double now, prev;
if(!GetBufferValue(emaHandle, shift, now)) return false;
if(!GetBufferValue(emaHandle, shift + lookback, prev)) return false;
if(prev <= 0.0) return false;

double slope = (now – prev) / (lookback * prev);
angle = MathArctan(slope) * 180.0 *1000 / M_PI;
return true;
}
***********************************************

SQX codeEditor

package SQ.Blocks.Indicators.FilterTrend;
import com.strategyquant.lib.*;
import com.strategyquant.datalib.*;
import com.strategyquant.tradinglib.*;
import SQ.Internal.IndicatorBlock;
import SQ.Blocks.Indicators.MovingAverage.EMA;
@BuildingBlock(
        name=”(XXX) EMA_PriceNormAngle”,
        display=”EMA_PriceNormAngle(#EMA_Period#,#Lookback#)”,
        returnType = ReturnTypes.Number
)
@Help(“EMA price-normalized angle = atan((EMA_now – EMA_prev)/(Lookback * EMA_prev)) in degrees”)
public class FilterTrend extends IndicatorBlock {
    // === INPUT PRICE ===
    @Parameter
    public DataSeries Input;   // Close price
    // === PARAMETERS ===
    @Parameter(defaultValue=”120″, isPeriod=true, minValue=2, maxValue=1000, step=1)
    public int EMA_Period;
    @Parameter(defaultValue=”5″, minValue=1, maxValue=100, step=1)
    public int Lookback;
    // === OUTPUT ===
    @Output
    public DataSeries Value;
    // === INDICATOR ===
    private EMA ema;
    @Override
    protected void OnInit() throws TradingException {
        ema = Indicators.EMA(Input, EMA_Period);
    }
    @Override
    protected void OnBarUpdate() throws TradingException {
        if (CurrentBar < EMA_Period + Lookback) {
            Value.set(0, 0);
            return;
        }
        double ema_now  = ema.Value.get(0);
        double ema_prev = ema.Value.get(Lookback);
        double angle = 0;
        if (ema_prev != 0) {
            double slope = (ema_now – ema_prev) / (Lookback * ema_prev);
            angle = 1000 * Math.toDegrees(Math.atan(slope));
        }
        Value.set(0, angle);
    }
}

0

Viewing 3 replies - 1 through 3 (of 3 total)