All you've given us is a code fragment for a routine that returns maybe 1 or 2, and then told us that you want ANOTHER part of your EA to IGNORE its value!
What can we say?
All you've given us is a code fragment for a routine that returns maybe 1 or 2, and then told us that you want ANOTHER part of your EA to IGNORE its value!
What can we say?
Like I said I don't really know how to code, so I thought thats
enough. Also English isn't my first language, so it's hard to explain
what I want. Sorry about that.
Well, I don't want it to ignore the value, I want it to recognize the
last value and act accordingly. Now the EA would only take trades when
the EMA_Angle is yellow or green. But I want it to take, for example,
sell trades even if it is red at the moment, but the last signal was
yellow.
I looked over the code, but don't really know what you'd need.
This is basically all I've got (besides MM Options, etc)
extern int MA_Period=34; extern string m = "--Mov SMA"; extern string m1 = " 1 = EMA"; extern string m2 = " 2 = SMMA"; extern string m3 = " 3 = LWMA"; extern string m4 = " 4 = LSMA"; extern int MA_Type = 1; extern string p = "--Applied Price Types--"; extern string p0 = " 0 = close"; extern string p1 = " 1 = open"; extern string p2 = " 2 = high"; extern string p3 = " 3 = low"; extern string p4 = " 4 = median(high+low)/2"; extern string p5 = " 5 = typical(high+low+close)/3"; extern string p6 = " 6 = weighted(high+low+close+close)/4"; extern int MA_AppliedPrice = 4; extern double EntryAngle_Threshold=0.5; // What size angle to trigger a trade extern int PrevMAShift=2; extern int CurMAShift=0; double Get_mFactor() { string Sym; double Factor; int ShiftDif; Factor = 100000.0; Sym = StringSubstr(Symbol(),3,3); if (Sym == "JPY") Factor = 1000.0; ShiftDif = PrevMAShift-CurMAShift; Factor /= ShiftDif; return (Factor); } void GetMAs (int TrendMethod, int MAPeriod, int Prev, int Cur) { switch (TrendMethod) { case LSMA : MACurrent=fLSMA(MAPeriod,MA_AppliedPrice,Cur); MAPrevious=fLSMA(MAPeriod,MA_AppliedPrice,Prev); break; default : MACurrent=iMA(NULL,0,MAPeriod,0,MA_Type,MA_AppliedPrice,Cur); MAPrevious=iMA(NULL,0,MAPeriod,0,MA_Type,MA_AppliedPrice,Prev); } } int ema() { double maAngle; GetMAs(MA_Type, MA_Period , PrevMAShift, CurMAShift); maAngle = mFactor * (MACurrent - MAPrevious)/2.0; if (maAngle > EntryAngle_Threshold)return(1); if (maAngle < -EntryAngle_Threshold)return(2); } int GetSignal() { int emaAngle; emaAngle=ema(); double stochm = iStochastic(NULL, 0, 8, 3, 3, 0, 0, 0, 0); double stochmp = iStochastic(NULL, 0, 8, 3, 3, 0, 0, 0, 1); double stoch = iStochastic(NULL, 0, 8, 3, 3, 0, 0, 1, 0); double stochp = iStochastic(NULL, 0, 8, 3, 3, 0, 0, 1, 1); if (emaAngle == 1 && stochmp < 50 && stochm > 50) return(LONG); if (emaAngle == 2 && stochmp > 50 && stochm < 50) return(SHORT); return(FLAT); }
I've also attached the EMA_Angle Indi.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi all,
i'm trying to learn how to code, but i faced a problem now.
I tried to incorporate the EMA_Angle indicator into an EA as a filter. My code below works when I just go long if maAngle > EntryAngle_Threshold and short when maAngle < -EntryAngle_Threshold.
However, I want the EA to take only long entrys even if maAngle IS NOT > EntryAngle_Threshold but the last signal from the Indicator was long. I can't really explain any better what I mean, since i don't speak English very well.
For that reason I've attached a picture, which hopefully makes it clear.
Between line 1 and 2, I want the EA to only take short entrys and between 2 and 3 to only take long entrys.
I hope somebody can help me with this