Go Back   Traders Laboratory > Trading Resources > Trading Indicators > Coding Forum

Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Bookmarks
del.icio.us StumbleUpon Google Digg Facebook Furl Reddit Netscape

 
LinkBack (1) Thread Tools Display Modes Language
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 10-14-2007, 09:16 AM
jjthetrader's Avatar
jjthetrader jjthetrader is offline
VSA Trader

 
Join Date: Aug 2007
Location: Canada
Posts: 328
Thanks: 97
Thanked 56 Times in 34 Posts
Some EasyLanguage Help Please

Hi, I was hoping someone could help me with the code for this.

I would like to know if a certain condition has been true for the last 10 bars.
Lets say one moving average has been less than the other for at least 10 bars and has crossed over on this bar.

When I try coding it it just returns that the condidtion was true 10 bars ago instead of for the last 10 bars.

Could someone please help me?
thanks
JJ

Reply With Quote
  #2 (permalink)  
Old 10-14-2007, 06:56 PM
thrunner thrunner is offline
Registered Trader

 
Join Date: Feb 2007
Posts: 154
Thanks: 50
Thanked 34 Times in 17 Posts
Re: Some EasyLanguage Help Please

I am no EL expert here, but I think you should try the CountIf function:
example based on builit in MACD LE strategy of TS with added CountIf; you may need to play with Value1 and Condition1 test length to get the logic right.
Also search for this function in TS help and TS forum.
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ; variables: MyMACD( 0 ), MACDAvg( 0 ), MACDDiff( 0 ) ; MyMACD = MACD( Close, FastLength, SlowLength ) ; MACDAvg = XAverage( MyMACD, MACDLength ) ; MACDDiff = MyMACD - MACDAvg ; Condition1 = MACDDiff crosses below 0; Value1 = CountIF(Condition1, 10); // CountIF returns A numeric value containing the number of true test condition occurrences for the current bar. if Value1>0 and CurrentBar > 2 and MACDDiff crosses over 0 then { CB > 2 check used to avoid spurious cross confirmation at CB = 2 (at CB = 1, MyMACD and MACDAvg will be the same) } Buy ( "MacdLE" ) next bar at market ; { ** Copyright (c) 2005 TradeStation Technologies, Inc. All rights reserved. ** ** TradeStation reserves the right to modify or overwrite this strategy component with each release. ** }


Last edited by thrunner; 10-14-2007 at 07:28 PM. Reason: program logic
Reply With Quote
  #3 (permalink)  
Old 10-14-2007, 07:16 PM
jjthetrader's Avatar
jjthetrader jjthetrader is offline
VSA Trader

 
Join Date: Aug 2007
Location: Canada
Posts: 328
Thanks: 97
Thanked 56 Times in 34 Posts
Re: Some EasyLanguage Help Please

Thank you, that should do it. I wasn't aware of that function.
I'll give it a shot. I appreciate your time.
JJ

Reply With Quote
  #4 (permalink)  
Old 10-14-2007, 07:18 PM
Dogpile Dogpile is offline
Registered Trader

 
Join Date: May 2007
Posts: 577
Thanks: 0
Thanked 5 Times in 3 Posts
Re: Some EasyLanguage Help Please

surely my way isn't the most elegant but it works:

--------
value1=average(c,2);
value2=average(c,5);

value3=value1-value2;

value4=lowest(value3,10)[1];

condition1=value4>0 and value1<value2;

if condition1 then
plot1(1,"10 abv");
--------

I plotted it at the bottom as a histogram to show a blue bar (value of '1') if the 2 period MA was > 5 period MA for 10 bars then crossed below it last bar.
Attached Images
File Type: png EL Doc.png (14.6 KB, 17 views)

Reply With Quote
  #5 (permalink)  
Old 10-14-2007, 07:34 PM
jjthetrader's Avatar
jjthetrader jjthetrader is offline
VSA Trader

 
Join Date: Aug 2007
Location: Canada
Posts: 328
Thanks: 97
Thanked 56 Times in 34 Posts
Re: Some EasyLanguage Help Please

Thank you as well. I'm not worried about elegance. My way was so choppy and long I was looking for a way to refine it a bit.

Reply With Quote
Reply

LinkBacks (?)
LinkBack to this Thread: http://www.traderslaboratory.com/forums/f56/some-easylanguage-help-please-2635.html
Posted By For Type Date
Traders Laboratory - forumdisplay This thread Refback 10-14-2007 08:56 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Labels in EasyLanguage keymoo Coding Forum 7 03-24-2007 02:37 PM
Antonio: Please help me on MP for easylanguage nasdaq5048 Market ProfileŽ 12 10-31-2006 05:53 PM


All times are GMT -4. The time now is 07:21 PM.

 


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59