Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
dOES ANYONE HAVE ANY CODE THAT I CAN ADD TO MY THREE EXP AVERAGE STATEGEY TO NOT INITIATE A TRADE UNLESS IT IS ABOVE OR BELOW THE 50 EMA?. THIS IS FOR MY AUTOTRADING STATEGY ALSO HOW TO ADD A TIMEFRAME IT CAN TRADE.
Can you help answer these questions from other members on NexusFi?
Condition1 = Price < var0 and var0 < var1 and var1 < var2 ;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;
if condition2
then
Sell Short ( "MA3CrsSE" ) next bar at market
I assumed that your `SlowLength` input is manually set to 50 since I couldn't find an EMA 50. Here I just added the condition that compares the `Close` value against the `var2` variable, which holds the EMA of the `SlowLength` period:
You are right i manually plot the 50 ema on the screen however i would like it to leave those conditions the same accept add that it will not take a short trade it it is above the 50 ema and vice versa, where would i inserst 50 at
You are right i manually plot the 50 ema on the screen however i would like it to leave those conditions the same accept add that it will not take a short trade it it is above the 50 ema and vice versa, where would i inserst 50 at
Hm, I believe I already added that to the code (see my previous post + motivation).
Did I misunderstand you or doesn't it work for you?
Hm, I believe I already added that to the code (see my previous post + motivation).
Did I misunderstand you or doesn't it work for you?
It did not work, i used it and it did not make a difference, so i dont know if i explained myself. I need the three ema that i have to only fire a signal if it is above or below the 50 ema, so i would assume that i have to add that rule somehow to the code that i have, can you do that for me PLEASE. I really appreciate what you done for me so far.
You are right i manually plot the 50 ema on the screen however i would like it to leave those conditions the same accept add that it will not take a short trade it it is above the 50 ema and vice versa, where would i inserst 50 at
gfdaniels
It did not work, i used it and it did not make a difference, so i dont know if i explained myself. I need the three ema that i have to only fire a signal if it is above or below the 50 ema, so i would assume that i have to add that rule somehow to the code that i have
Ah I see, I misunderstood you; I thought you configured the signal to an EMA 50 but now I understand that you plotted the EMA50 on the chart (so an indicator).
I've updated your code to include a 50-period EMA now. The input for it is named `SlowerLength`. Try to see if this works for you:
Inputs:
Price(Close),
FastLength(4),
MedLength(5),
SlowLength(8),
SlowerLength(50);
Variables:
emaQuick(0), emaMed(0), emaSlow(0), emaSlower(0);
emaQuick = XAverage(Price, FastLength);
emaMed = XAverage(Price, MedLength);
emaSlow = XAverage(Price, SlowLength);
emaSlower = XAverage(Price, SlowerLength);
Condition1 = Price < emaQuick and emaQuick < emaMed and emaMed < emaSlow;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;
if (condition2 and Close < emaSlower) then
Sell Short ( "MA3CrsSE" ) next bar at market;
Condition1 = Price > emaQuick and emaQuick > emaMed and emaMed > emaSlow;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;
if (condition2 and Close > emaSlower) then
Buy ( "MA3CrsLE" ) next bar at market ;
Ah I see, I misunderstood you; I thought you configured the signal to an EMA 50 but now I understand that you plotted the EMA50 on the chart (so an indicator).
I've updated your code to include a 50-period EMA now. The input for it is named `SlowerLength`. Try to see if this works for you:
Inputs:
Price(Close),
FastLength(4),
MedLength(5),
SlowLength(8),
SlowerLength(50);
Variables:
emaQuick(0), emaMed(0), emaSlow(0), emaSlower(0);
emaQuick = XAverage(Price, FastLength);
emaMed = XAverage(Price, MedLength);
emaSlow = XAverage(Price, SlowLength);
emaSlower = XAverage(Price, SlowerLength);
Condition1 = Price < emaQuick and emaQuick < emaMed and emaMed < emaSlow;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;
if (condition2 and Close < emaSlower) then
Sell Short ( "MA3CrsSE" ) next bar at market;
Condition1 = Price > emaQuick and emaQuick > emaMed and emaMed > emaSlow;
condition2 = CurrentBar > 1 and Condition1 and Condition1[1] = false;
if (condition2 and Close > emaSlower) then
Buy ( "MA3CrsLE" ) next bar at market ;