Tradecision Talks
May 25, 2013, 03:51:53 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Strategy: 20 EMA & 50 EMA  (Read 9325 times)
hunter
Sr. Member
****
Posts: 10


« on: August 14, 2008, 07:51:08 AM »

Hello Support,

I would appreciate your help in building a strategy that I have tried to explain in the best possible way.

Strategy: 20 EMA & 50 EMA

Entry Long:      20 EMA crosses 200 EMA up from below,
50 EMA crosses 200 EMA up from below…         
Then, 20 EMA goes below 50 EMA and comes back above 50 EMA, you enter long

Exit Long:        2 closes below 20 EMA

What we are trying to do is longs are not entered the first time when 20 EMA & 50 EMA crosses above 200 EMA but when 20 EMA crosses below 50 EMA and then goes back above it, it should trigger a buy.

Thanks in advance.
Logged
Tradecision Support Team
Hero Member
*****
Posts: 336


« Reply #1 on: August 15, 2008, 12:01:03 AM »

Dear hunter,

Here is the following code:

Entry Long:
========
var
    res:=false;
    ema20:=EMA(C,20);
    ema50:=EMA(C,50);
    ema200:=EMA(C,200);
    cross_20_200:=0;
    cross_50_200:=0;
    cross_20_50:=0;
end_var

cross_20_200:=BarsSince(CrossAbove(ema20,ema200));
cross_50_200:=BarsSince(CrossAbove(ema50,ema200));
cross_20_50:=BarsSince(CrossBelow(ema20,ema50));

if cross_20_200=-1 or cross_50_200=-1 or cross_20_50=-1 then
   return false;

if CrossAbove(ema20,ema50) and
   cross_20_50>0 and
   cross_20_50<cross_20_200 and
   cross_20_50<cross_50_200
then
    res:=true;

return res;

Exit Long:
========
var
ema20:=EMA(c,20);
end_var

return Close<ema20 and Close\1\<ema20;
========

Besides, for the successful work of this strategy, it will be necessary to copy the attached BarsSince.tfn file to Alyuda Tradecision\Funct catalogue.


Sincerely,
Tradecision Support Team

Hello Support,

I would appreciate your help in building a strategy that I have tried to explain in the best possible way.

Strategy: 20 EMA & 50 EMA

Entry Long:      20 EMA crosses 200 EMA up from below,
50 EMA crosses 200 EMA up from below…         
Then, 20 EMA goes below 50 EMA and comes back above 50 EMA, you enter long

Exit Long:        2 closes below 20 EMA

What we are trying to do is longs are not entered the first time when 20 EMA & 50 EMA crosses above 200 EMA but when 20 EMA crosses below 50 EMA and then goes back above it, it should trigger a buy.

Thanks in advance.
Logged
hunter
Sr. Member
****
Posts: 10


« Reply #2 on: August 18, 2008, 12:07:59 AM »

Thank you for sending me the code; I copied the code into the strategy builder and when I click button to check formula, it shows errors as per the attached file.
Please advice how to rectify this?
Logged
Tradecision Support Team
Hero Member
*****
Posts: 336


« Reply #3 on: August 19, 2008, 12:24:27 AM »

Dear hunter,

Just remove the “return” word from the start of the program’s text.
Hope this will help.

Sincerely,
Tradecision Support Team

Thank you for sending me the code; I copied the code into the strategy builder and when I click button to check formula, it shows errors as per the attached file.
Please advice how to rectify this?
Logged
hunter
Sr. Member
****
Posts: 10


« Reply #4 on: August 19, 2008, 03:48:47 AM »

Thank you. It works now.
Logged
hunter
Sr. Member
****
Posts: 10


« Reply #5 on: August 29, 2008, 02:26:16 AM »

Dear Support,

I would appreciate it if you could help me code the same for short positions as well.

Your help is much appreciated.
Logged
Tradecision Support Team
Hero Member
*****
Posts: 336


« Reply #6 on: September 01, 2008, 03:52:25 AM »

Dear hunter,

Please let us now what finally, the rule for Short Position should be?

Sincerely,
Tradecision Support Team


Dear Support,

I would appreciate it if you could help me code the same for short positions as well.

Your help is much appreciated.

Logged
hunter
Sr. Member
****
Posts: 10


« Reply #7 on: September 02, 2008, 12:37:17 AM »

Entry Short:      20 EMA crosses 200 EMA down from above,
50 EMA crosses 200 EMA down from above,
Then, 20 EMA goes above 50 EMA and comes back below 50 EMA, you enter short

Exit Short:        2 closes above 20 EMA

What we are trying to do is shorts are not entered the first time when 20 EMA & 50 EMA crosses below 200 EMA but when 20 EMA crosses above 50 EMA and then goes back below it (while remaining below 200), it should trigger a sell.
Logged
Tradecision Support Team
Hero Member
*****
Posts: 336


« Reply #8 on: September 04, 2008, 12:59:38 AM »

Dear hunter,

Here is the following code:

Entry Short:
=========
var
    res:=false;
    ema20:=EMA(C,20);
    ema50:=EMA(C,50);
    ema200:=EMA(C,200);
    cross_20_200:=0;
    cross_50_200:=0;
    cross_20_50:=0;
end_var

cross_20_200:=BarsSince(CrossBelow(ema20,ema200));
cross_50_200:=BarsSince(CrossBelow(ema50,ema200));
cross_20_50:=BarsSince(CrossAbove(ema20,ema50));

if cross_20_200=-1 or cross_50_200=-1 or cross_20_50=-1 then
   return false;

if CrossBelow(ema20,ema50) and
   cross_20_50>0 and
   cross_20_50<cross_20_200 and
   cross_20_50<cross_50_200
then
    res:=true;

return res;

Sincerely,
Tradecision Support Team


Entry Short:      20 EMA crosses 200 EMA down from above,
50 EMA crosses 200 EMA down from above,
Then, 20 EMA goes above 50 EMA and comes back below 50 EMA, you enter short

Exit Short:        2 closes above 20 EMA

What we are trying to do is shorts are not entered the first time when 20 EMA & 50 EMA crosses below 200 EMA but when 20 EMA crosses above 50 EMA and then goes back below it (while remaining below 200), it should trigger a sell.

Logged
hunter
Sr. Member
****
Posts: 10


« Reply #9 on: September 05, 2008, 12:33:23 AM »

Worked great!
Thank you.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!