NexusFi: Find Your Edge


Home Menu

 





My First EasyLanguage Strategy - Need some help


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,639 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

My First EasyLanguage Strategy - Need some help

  #1 (permalink)
 bluefightingcat 
Espoo Finland
 
Experience: Intermediate
Platform: TradingBlox, Tradestation
Trading: Stocks
Posts: 41 since Sep 2015
Thanks Given: 2
Thanks Received: 10

Ok,

So I've recently taken a step to make my trading more reliable and hopefully more successful. I am trying out Multicharts and one of the features I wish to use is the backtesting feature. It seems, that to use this feature I have to learn "easylanguage" to write my strategy. So I did some reading on the internet and jumped right in the deep end and wrote my first easylanguage strategy. First the strategy:

Show Stocks where RSI(2) is below 5
and price is above 5.00
and average volume(21) is above 250000
and close reached a new 10 day low
and close less than MA(5)
and close less than MA(200)
and close has been decreasing for 5 days
and where ADX(10) is above 30

This is what I have so far:

 
Code
Inputs:

	MinPrice (10),  //Minimum stock price for stock to be considered
	Avg_Vol_Len (21), //The length used to calculate average volume
	Min_Avg_Vol (250000), //The minimum average volume required for stock to be considered
	RSI_Len (2), //Length of RSI
	ema_fast_len (10), //Speed of fast EMA
	ema_slow_len (200), //Speed of slow EMA
	rsi_oversold (5), //Threshold for when RSI is considered oversold.
	ADX_len (10); //The length of ADX
	
Variables:

	price (close),
	intrabarpersist ema_fast (0),
	intrabarpersist ema_slow (0),
	intrabarpersist rsi_val (0),
	intrabarpersist last_rsi_oversold_dt (0),
	intrabarpersist mp (0), 
	intrabarpersist ep (0),
	intrabarpersist exitbar (0),
	intrabarpersist rsi_xdown_bar (0),
	intrabarpersist ADX (0)
	;
	
mp = marketposition(0);
ep = entryprice(0);

ema_fast = xaverage( close, ema_fast_len); //Calculate the fast EMA
ema_slow = xaverage( close, ema_slow_len); //Calculate the slow EMA
rsi_val = rsi( close, rsi_len);	        //Get the latest RSI value    
Min_Avg_Vol = average(close, Avg_Vol_len); //Calculate the average volume for the specified length
ADX_val = ADX(close, adx_len); 		//Get the latest ADX value

if price > 10
and Min_Avg_Vol > 250000
and price < ema_fast
and price < ema_slow
and ADX_val > 25
then

if rsi_val crosses below 5 then
	rsi_xdown_bar = barnumber;

if mp = 0 then
begin
	buy 10 stocks next bar at Open;
	
end;

if mp = 1 then
end;
Now here are my questions:

1. How do I code this "and price reached a new 10 day low".
2. How do I code this "and price has been decreasing for 5 days."
3. I am having trouble with coding the position size and entries as well as the exits. But I will save that for another post.
4. Essentially when backtesting and maybe in future in automated trading, I want this strategy to pick 4-6 stocks (depending on my current positions and position size) from any of the stocks in the NYSE, NASDAQ or AMEX that fill the criteria. I want the strategy to constantly scan all these stocks and buy the ones that best fulfill my criteria.

So initially I just want to make sure that the strategy criteria are correct first and get some answers.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
22 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 clzppt 
Huntsville, AL
 
Experience: Intermediate
Platform: TradeStation
Broker: Tradestation
Trading: Index Futures
Posts: 10 since Jun 2014
Thanks Given: 1
Thanks Received: 0



Quoting 

Now here are my questions:

1. How do I code this "and price reached a new 10 day low".
2. How do I code this "and price has been decreasing for 5 days."
3. I am having trouble with coding the position size and entries as well as the exits. But I will save that for another post.
4. Essentially when backtesting and maybe in future in automated trading, I want this strategy to pick 4-6 stocks (depending on my current positions and position size) from any of the stocks in the NYSE, NASDAQ or AMEX that fill the criteria. I want the strategy to constantly scan all these stocks and buy the ones that best fulfill my criteria.

So initially I just want to make sure that the strategy criteria are correct first and get some answers.

I'm a TradeStation user but I believe the easylanguage code is the same across platforms so see if this helps:

*note: the code below assumes you're using daily bars. If you were not using daily bars then you can use LowD and CloseD to access the daily values on an intraday chart.

1) I would use the "Lowest" function:
 
Code
If L < Lowest(L, 10) then //your code

2) Probably at least two ways to do this and I'm not sure which method represents what you're after so you can decide:
Method 1: this will only check if the current close is lower than the close 5 periods ago
 
Code
    
if C < C[5] then //your code
Method 2: this will ensure the last five consecutive closes are each lower than the previous
 
Code
if C < C[1] and C[1] < C[2] and C[2] < C[3] and C[3] < C[4] and C[4] < C[5] then //your code
I can't help with answers for 3 or 4.

Reply With Quote
  #4 (permalink)
 bluefightingcat 
Espoo Finland
 
Experience: Intermediate
Platform: TradingBlox, Tradestation
Trading: Stocks
Posts: 41 since Sep 2015
Thanks Given: 2
Thanks Received: 10

Thanks. That provides a great solution to those 2 questions!

Started this thread Reply With Quote




Last Updated on September 16, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts