Eazy Language Indicator and Signal

Questions about MultiCharts and user contributed studies.
pschriber2
Posts: 36
Joined: 24 Apr 2012
Has thanked: 6 times
Been thanked: 2 times

Eazy Language Indicator and Signal

Postby pschriber2 » 28 May 2012

I'm programming a signal that utilizes two Simple Moving Averages for different time frames to determine the buy/sell decision. I am taking both short and long positions and for some reason I am getting a short signal without any crossover on the shorter time horizon SMA. I was wondering if this issue can be related to using two different time horizons for a signal. Has anyone else had a similar issue? Any help would be appreciated. Here is the sample code that I am using:

Code: Select all

var0 = AverageFC( Price, FastLength ) ;
var1 = AverageFC( Price, SlowLength ) ;
var2 = AverageFC( Close of Data2, FastLength2 ) ;
var3 = AverageFC( Close of Data2, SlowLength2 ) ;

condition2 = CurrentBar > 1 and var0 crosses under var1 ; //min short
condition4 = CurrentBar > 1 and var2 < var3 ; // day short


if condition2 and condition4 then // min sell, daily
Sell Short ( "Short" ) next bar at market ;
Thanks

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Eazy Language Indicator and Signal

Postby TJ » 28 May 2012

I'm programming a signal that utilizes two Simple Moving Averages for different time frames to determine the buy/sell decision. I am taking both short and long positions and for some reason I am getting a short signal without any crossover on the shorter time horizon SMA. I was wondering if this issue can be related to using two different time horizons for a signal. Has anyone else had a similar issue? Any help would be appreciated. Here is the sample code that I am using:


var0 = AverageFC( Price, FastLength ) ;
var1 = AverageFC( Price, SlowLength ) ;
var2 = AverageFC( Close of Data2, FastLength2 ) ;
var3 = AverageFC( Close of Data2, SlowLength2 ) ;

condition2 = CurrentBar > 1 and var0 crosses under var1 ; //min short
condition4 = CurrentBar > 1 and var2 < var3 ; // day short


if condition2 and condition4 then // min sell, daily
Sell Short ( "Short" ) next bar at market ;

Thanks
Have you used a PLOT to verify your logic before you jump into coding your strategy?




ps. please use code tag when posting codes. I have tagged them for you in your post.

pschriber2
Posts: 36
Joined: 24 Apr 2012
Has thanked: 6 times
Been thanked: 2 times

Re: Eazy Language Indicator and Signal

Postby pschriber2 » 28 May 2012

Hi yes I did. Some of the buy/exit signs lineup but others are off. For example the short signal is 2 or 3 ticks before the short indicator.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Eazy Language Indicator and Signal

Postby TJ » 28 May 2012

Hi yes I did. Some of the buy/exit signs lineup but others are off. For example the short signal is 2 or 3 ticks before the short indicator.
What are your chart resolutions? Which is data1 and which is data2?
What is the instrument?


Please post a chart.
Please use lines and arrows and notes on the chart to point out the logic problem.

pschriber2
Posts: 36
Joined: 24 Apr 2012
Has thanked: 6 times
Been thanked: 2 times

Re: Eazy Language Indicator and Signal

Postby pschriber2 » 29 May 2012

Hey TJ,

I was using resolutions of 60 minutes and 1 day. I was able to solve the problem. It had to do with me not explicitly stating which variables were associated with data2.

i.e. vars: price1(0,data1),
var0(0,data1);
var1(0,data1);
var2(0,data2);
var3(0,data2);

var0= MVA(close of data2, length) data2;

Thanks for your help though.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Eazy Language Indicator and Signal

Postby TJ » 29 May 2012

Hey TJ,

I was using resolutions of 60 minutes and 1 day. I was able to solve the problem. It had to do with me not explicitly stating which variables were associated with data2.

i.e. vars: price1(0,data1),
var0(0,data1);
var1(0,data1);
var2(0,data2);
var3(0,data2);

var0= MVA(close of data2, length) data2;

Thanks for your help though.
One suggestion:

Avoid using generic variable names, ie var0, var1, var2, etc.,

Always use a meaningful name. eg. Open.data1, Open.data2, etc.,
This will help you to debug when your code grows in complexity.

pschriber2
Posts: 36
Joined: 24 Apr 2012
Has thanked: 6 times
Been thanked: 2 times

Re: Eazy Language Indicator and Signal

Postby pschriber2 » 29 May 2012

Okay, I will keep that in mind. There still seems to be a issue with the timing of the entry/exit points for the indicators and signals. All of the indicator points seem to be correct now but a few of the signal ones seem to be off. I have attached a labeled screen capture.
Attachments
Untitled.jpg
(180.24 KiB) Downloaded 478 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Eazy Language Indicator and Signal

Postby TJ » 29 May 2012

Okay, I will keep that in mind. There still seems to be a issue with the timing of the entry/exit points for the indicators and signals. All of the indicator points seem to be correct now but a few of the signal ones seem to be off. I have attached a labeled screen capture.
need more description on the logic, what you are expecting, and what is wrong with the chart.


see post #5
viewtopic.php?f=16&t=6929

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Eazy Language Indicator and Signal

Postby TJ » 29 May 2012

ps. you should make an indicator first, before jumping into coding a strategy.

in place of BUY or SELL,

Use a PLOT to make a "dot" on the chart to show that your logic is working as expected.

pschriber2
Posts: 36
Joined: 24 Apr 2012
Has thanked: 6 times
Been thanked: 2 times

Re: Eazy Language Indicator and Signal

Postby pschriber2 » 30 May 2012

The entry/exit is supposed to be given by using the crossover/crossunder on the first chart, and confirming it by checking if the bottom chart (data2) confirms this trend. The top chart uses a higher resolution. If both confirm that the faster moving average is above the slower moving average, then enter a long position. On the other hand, if both confirm slower is above the faster, then short the instrument.

I did make the indicator first, and it works for all of the points. I am trying to make the signal now. The indicator is just there to confirm the entry/exit points.


Return to “MultiCharts”