MACD Cross_Above/Cross_Below in EL - EasyLanguage Programming | futures io social day trading
futures io futures trading


MACD Cross_Above/Cross_Below in EL
Updated: Views / Replies:3,490 / 5
Created: by Arich Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

MACD Cross_Above/Cross_Below in EL

  #1 (permalink)
Elite Member
Springfield, Missouri
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Interactive Brokers
Favorite Futures: EUR/USD
 
Posts: 28 since Sep 2012
Thanks: 29 given, 5 received

MACD Cross_Above/Cross_Below in EL

Hello,

I'm trying to figure out how to code a crosses_above and crosses_below using a MACD in EasyLanguage.

When I try "if MyMACD crosses_above MACDAvg" I get the syntax error code 'expecting bars.' I tried just coding it as "if MyMACD > MACDAvg" and it compiles, but that doesn't have the affect that I'm shooting for. I've looked for a couple of hours for examples of how to code this but can't find any. Any help is appreciated!

p.s. This code won't compile because of this one issue.

 
Code
inputs: 
	SlowLength (26),
	FastLength (12),
	MACDLength (3),
	Target1 (40),
	Target2 (20),
	Target3 (40),
	StopSize (40),
	BE2 (0), // 0=false 1=true
	BE3 (0); // 0=false 1=true
	
vars:
	ticksize (MinMove/PriceScale),
	MyMACD (0),
	MACDAvg (0),
	MACDDiff (0),
	t1 (Target1 * ticksize),
	t2 (Target1 + Target2 *ticksize),
	t3 (Target1 + Target2 + Target3 * ticksize),
	st1 (0),
	st2 (0),
	st3 (0);

MyMACD = MACD(Close, FastLength, SlowLength);
MACDAvg = XAverage(MyMACD, MACDLength);
MACDDiff = MyMACD - MACDAvg;

// Open new Positions

if MarketPosition = 0 then begin

	if MyMACD crosses_above MACDAvg and MyMACD <= 0 and MACDAvg <= 0 then begin
		Buy ("Enter Long1") 100000 contract next bar at market;
		Buy ("Enter Long2") 100000 contract next bar at market;
		Buy ("Enter Long3") 100000 contract next bar at market;
	end;
	
	if MyMACD crosses_below MACDAvg and MyMACD >= 0 and MACDAvg >= 0 then begin
		Sell ("Enter Short1") 100000 contract next bar at market;
		Sell ("Enter Short2") 100000 contract next bar at market;
		Sell ("Enter Short3") 100000 contract next bar at market; 
	end;
		
end; 

// Manage open orders

if MarketPosition = 0 then begin

	st1 = EntryPrice - (StopSize * ticksize);
	st2 = iff(BE2 = 1, EntryPrice, EntryPrice - (StopSize * ticksize));
	st3 = iff(BE3 = 1, EntryPrice, EntryPrice - (StopSize * ticksize));

	if CurrentContracts = 100000 then begin
		Sell ("Exit l3-c1 Target") 100000 Contract Next Bar at (EntryPrice + t3) Limit;
		Sell ("Exit l3-c1 Stop") 100000 Contract Next Bar at st3 Stop;
	end;
	
	if CurrentContracts = 200000 then begin
		Sell ("Exit l2-c2 Target") 100000 Contract Next Bar at (EntryPrice + t2) Limit;
		Sell ("Exit l2-c2 Stop") 100000 Contract Next Bar at st2 Stop;
		Sell ("Exit l3-c2 Target") 100000 Contract Next Bar at (EntryPrice + t3) Limit;
		Sell ("Exit l3-c2 Stop") 100000 Contract Next Bar at st3 Stop;
	end;
	
	if CurrentContracts = 300000 then begin
		Sell ("Exit l1-c3 Target") 100000 Contract Next Bar at (EntryPrice + t2) Limit;
		Sell ("Exit l1-c3 Stop") 100000 Contract Next Bar at st1 Stop;
		Sell ("Exit l2-c3 Target") 100000 Contract Next Bar at (EntryPrice + t2) Limit;
		Sell ("Exit l2-c3 Stop") 100000 Contract Next Bar at st2 Stop;
		Sell ("Exit l3-c3 Target") 100000 Contract Next Bar at (EntryPrice + t3) Limit;
		Sell ("Exit l3-c3 Stop") 100000 Contract Next Bar at st3 Stop;	
	end;
end;

if MarketPosition = -1 then begin

	st1 = EntryPrice + (StopSize * ticksize);
	st2 = iff(BE2 = 1, EntryPrice, EntryPrice + (StopSize * ticksize));
	st3 = iff(BE3 = 1, EntryPrice, EntryPrice + (StopSize * ticksize));

	if CurrentContracts = -100000 then begin
		BuyToCover ("Exit s3-c1 Target") 100000 Contract Next Bar at (EntryPrice - t3) Limit;
		BuyToCover ("Exit s3-c1 Stop") 100000 Contract Next Bar at st3 Stop;
	end;
	
	if CurrentContracts = -200000 then begin
		BuyToCover ("Exit s2-c2 Target") 100000 Contract Next Bar at (EntryPrice - t2) Limit;
		BuyToCover ("Exit s2-c2 Stop") 100000 Contract Next Bar at st2 Stop;
		BuyToCover ("Exit s3-c2 Target") 100000 Contract Next Bar at (EntryPrice - t3) Limit;
		BuyToCover ("Exit s3-c2 Stop") 100000 Contract Next Bar at st3 Stop;
	end;
	
	if CurrentContracts = -300000 then begin
		BuyToCover ("Exit s1-c3 Target") 100000 Contract Next Bar at (EntryPrice - t2) Limit;
		BuyToCover ("Exit s1-c3 Stop") 100000 Contract Next Bar at st1 Stop;
		BuyToCover ("Exit s2-c3 Target") 100000 Contract Next Bar at (EntryPrice - t2) Limit;
		BuyToCover ("Exit s2-c3 Stop") 100000 Contract Next Bar at st2 Stop;
		BuyToCover ("Exit s3-c3 Target") 100000 Contract Next Bar at (EntryPrice - t3) Limit;
		BuyToCover ("Exit s3-c3 Stop") 100000 Contract Next Bar at st3 Stop;	
	end;
end;

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Trading for Fun
London
 
Futures Experience: None
Platform: mc, TS, ninja
Favorite Futures: es
 
Bimi's Avatar
 
Posts: 118 since Mar 2010
Thanks: 42 given, 58 received



Arich View Post
Hello,

I'm trying to figure out how to code a crosses_above and crosses_below using a MACD in EasyLanguage.

When I try "if MyMACD crosses_above MACDAvg" I get the syntax error code 'expecting bars.' I tried just coding it as "if MyMACD > MACDAvg" and it compiles, but that doesn't have the affect that I'm shooting for. I've looked for a couple of hours for examples of how to code this but can't find any. Any help is appreciated!

p.s. This code won't compile because of this one issue.


use this instead

 
Code
if MyMACD > MACDAvg
and MyMACD[1] < MACDAvg[1] 
...

Reply With Quote
The following user says Thank You to Bimi for this post:
 
  #4 (permalink)
 Vendor: sentimentrader.com 
Tulsa, OK
 
Futures Experience: Advanced
Platform: Tradestation, TOS, Python
Broker/Data: IQFeed, Tradestation, TOS
Favorite Futures: ES, SPY, Options
 
ericbrown's Avatar
 
Posts: 201 since Jan 2011
Thanks: 339 given, 234 received


Arich View Post
"if MyMACD crosses_above MACDAvg"

Why the "crosses_above"and "crosses_below" ? I've not seen this language/syntax in EL before.

Did you try "crosses over" (for crosses_above) and "crosses below" (for crosses_below)?

I just tried it out and the strat went long at a MACD Crossover. Not sure if this is the actual entry signal you wanted but it is compiling and entering. Screenshot attached.

The code I have is below.

 
Code
inputs: 
	SlowLength (26),
	FastLength (12),
	MACDLength (3),
	Target1 (40),
	Target2 (20),
	Target3 (40),
	StopSize (40),
	BE2 (0), // 0=false 1=true
	BE3 (0); // 0=false 1=true
	
vars:
	ticksize (MinMove/PriceScale),
	MyMACD (0),
	MACDAvg (0),
	MACDDiff (0),
	t1 (Target1 * ticksize),
	t2 (Target1 + Target2 *ticksize),
	t3 (Target1 + Target2 + Target3 * ticksize),
	st1 (0),
	st2 (0),
	st3 (0);

MyMACD = MACD(Close, FastLength, SlowLength);
MACDAvg = XAverage(MyMACD, MACDLength);
MACDDiff = MyMACD - MACDAvg;

// Open new Positions

if MarketPosition = 0 then begin

	if MyMACD crosses over MACDAvg and MyMACD <= 0 and MACDAvg <= 0 then begin
		Buy ("Enter Long1") 100000 contract next bar at market;
		Buy ("Enter Long2") 100000 contract next bar at market;
		Buy ("Enter Long3") 100000 contract next bar at market;
	end;
	
	if MyMACD crosses below MACDAvg and MyMACD >= 0 and MACDAvg >= 0 then begin
		Sell ("Enter Short1") 100000 contract next bar at market;
		Sell ("Enter Short2") 100000 contract next bar at market;
		Sell ("Enter Short3") 100000 contract next bar at market; 
	end;
		
end; 

// Manage open orders

if MarketPosition = 0 then begin

	st1 = EntryPrice - (StopSize * ticksize);
	st2 = iff(BE2 = 1, EntryPrice, EntryPrice - (StopSize * ticksize));
	st3 = iff(BE3 = 1, EntryPrice, EntryPrice - (StopSize * ticksize));

	if CurrentContracts = 100000 then begin
		Sell ("Exit l3-c1 Target") 100000 Contract Next Bar at (EntryPrice + t3) Limit;
		Sell ("Exit l3-c1 Stop") 100000 Contract Next Bar at st3 Stop;
	end;
	
	if CurrentContracts = 200000 then begin
		Sell ("Exit l2-c2 Target") 100000 Contract Next Bar at (EntryPrice + t2) Limit;
		Sell ("Exit l2-c2 Stop") 100000 Contract Next Bar at st2 Stop;
		Sell ("Exit l3-c2 Target") 100000 Contract Next Bar at (EntryPrice + t3) Limit;
		Sell ("Exit l3-c2 Stop") 100000 Contract Next Bar at st3 Stop;
	end;
	
	if CurrentContracts = 300000 then begin
		Sell ("Exit l1-c3 Target") 100000 Contract Next Bar at (EntryPrice + t2) Limit;
		Sell ("Exit l1-c3 Stop") 100000 Contract Next Bar at st1 Stop;
		Sell ("Exit l2-c3 Target") 100000 Contract Next Bar at (EntryPrice + t2) Limit;
		Sell ("Exit l2-c3 Stop") 100000 Contract Next Bar at st2 Stop;
		Sell ("Exit l3-c3 Target") 100000 Contract Next Bar at (EntryPrice + t3) Limit;
		Sell ("Exit l3-c3 Stop") 100000 Contract Next Bar at st3 Stop;	
	end;
end;

if MarketPosition = -1 then begin

	st1 = EntryPrice + (StopSize * ticksize);
	st2 = iff(BE2 = 1, EntryPrice, EntryPrice + (StopSize * ticksize));
	st3 = iff(BE3 = 1, EntryPrice, EntryPrice + (StopSize * ticksize));

	if CurrentContracts = -100000 then begin
		BuyToCover ("Exit s3-c1 Target") 100000 Contract Next Bar at (EntryPrice - t3) Limit;
		BuyToCover ("Exit s3-c1 Stop") 100000 Contract Next Bar at st3 Stop;
	end;
	
	if CurrentContracts = -200000 then begin
		BuyToCover ("Exit s2-c2 Target") 100000 Contract Next Bar at (EntryPrice - t2) Limit;
		BuyToCover ("Exit s2-c2 Stop") 100000 Contract Next Bar at st2 Stop;
		BuyToCover ("Exit s3-c2 Target") 100000 Contract Next Bar at (EntryPrice - t3) Limit;
		BuyToCover ("Exit s3-c2 Stop") 100000 Contract Next Bar at st3 Stop;
	end;
	
	if CurrentContracts = -300000 then begin
		BuyToCover ("Exit s1-c3 Target") 100000 Contract Next Bar at (EntryPrice - t2) Limit;
		BuyToCover ("Exit s1-c3 Stop") 100000 Contract Next Bar at st1 Stop;
		BuyToCover ("Exit s2-c3 Target") 100000 Contract Next Bar at (EntryPrice - t2) Limit;
		BuyToCover ("Exit s2-c3 Stop") 100000 Contract Next Bar at st2 Stop;
		BuyToCover ("Exit s3-c3 Target") 100000 Contract Next Bar at (EntryPrice - t3) Limit;
		BuyToCover ("Exit s3-c3 Stop") 100000 Contract Next Bar at st3 Stop;	
	end;
end;

Attached Thumbnails
MACD Cross_Above/Cross_Below in EL-tradestation-9.1-laptop-comm_of_traders-chart-analysis-spy-daily-arcx-_2012-09-29_23-0.png  
Reply With Quote
The following user says Thank You to ericbrown for this post:
 
  #5 (permalink)
Trading for Fun
London
 
Futures Experience: None
Platform: mc, TS, ninja
Favorite Futures: es
 
Bimi's Avatar
 
Posts: 118 since Mar 2010
Thanks: 42 given, 58 received


ericbrown View Post
Why the "crosses_above"and "crosses_below" ? I've not seen this language/syntax in EL before.

Did you try "crosses over" (for crosses_above) and "crosses below" (for crosses_below)?

I just tried it out and the strat went long at a MACD Crossover. Not sure if this is the actual entry signal you wanted but it is compiling and entering. Screenshot attached.

The code I have is below.

In some manuals, they were printed as "crosses_above" and "crosses_below".

They should have read: "crosses above" and "crosses below",
ie. without the underscore in between the words.

Reply With Quote
The following 2 users say Thank You to Bimi for this post:
 
  #6 (permalink)
 Vendor: sentimentrader.com 
Tulsa, OK
 
Futures Experience: Advanced
Platform: Tradestation, TOS, Python
Broker/Data: IQFeed, Tradestation, TOS
Favorite Futures: ES, SPY, Options
 
ericbrown's Avatar
 
Posts: 201 since Jan 2011
Thanks: 339 given, 234 received


Bimi View Post
In some manuals, they were printed as "crosses_above" and "crosses_below".

They should have read: "crosses above" and "crosses below",
ie. without the underscore in between the words.

Gotcha..I didn't know that. Thanks!

Reply With Quote

Reply



futures io > > > > > MACD Cross_Above/Cross_Below in EL

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help converting old EL to MC olobay MultiCharts 4 July 7th, 2012 10:33 PM
Learning EL. Question Timot EasyLanguage Programming 13 May 12th, 2012 10:41 AM
help with bartype for strategy in EL JVentura EasyLanguage Programming 4 December 4th, 2010 12:57 PM
EL: How many periods since last low? arjfca EasyLanguage Programming 3 November 26th, 2010 08:02 AM
Looking for a simple MACD strategy. MACD Xover LONG, go LONG roshareid NinjaTrader Programming 2 April 11th, 2010 09:05 PM


All times are GMT -4. The time now is 05:55 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.18 seconds with 20 queries on phoenix via your IP 54.82.79.109