NinjaTrader ATM in EasyLanguage - EasyLanguage Programming | futures io social day trading
futures io futures trading


NinjaTrader ATM in EasyLanguage
Updated: Views / Replies:4,043 / 32
Created: by Arich Attachments:0

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
 

NinjaTrader ATM in EasyLanguage

  #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

NinjaTrader ATM in EasyLanguage

Hello,

I am very new to EasyLanguage and even coding in general, so please bear with me.

I have an ATM strategy in NT that I would like to backtest/automate in MC. I have just started researching how to do this, but I figured if anyone here has some advice, I'd really appreciate it. Allow me to present the facts first and then ask my questions last.

Facts:
Basically the ATM consists of three targets, a stoploss, a breakeven, and finally a trailing stop.
I use MACD as my signal generator. When the fast crosses the slow I enter a trade. The direction of the trade is determined by whether the cross happens above or below the zero line.

Questions:
I don't really know where to start with coding this... Does anyone know of any good resources or threads (I searched futures.io (formerly BMT) but didn't really find anything related to this) that I could use? I'm here to learn, not to leech.

In NT, backtesting this strategy was way beyond my skill level and even some skilled coders I spoke to said this was difficult to code in NT due to the trailing stoploss and breakeven since they need to be triggered intra bar. This is possible to do in MC, right? From what I've read it seems possible...

Is there someplace I can go to learn some basic EasyLanguage coding fundamentals and logic?

Any help you can provide will be much appreciated!

Happy Trading,
ARich

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 am very new to EasyLanguage and even coding in general, so please bear with me.

I have an ATM strategy in NT that I would like to backtest/automate in MC. I have just started researching how to do this, but I figured if anyone here has some advice, I'd really appreciate it. Allow me to present the facts first and then ask my questions last.

Facts:
Basically the ATM consists of three targets, a stoploss, a breakeven, and finally a trailing stop.
I use MACD as my signal generator. When the fast crosses the slow I enter a trade. The direction of the trade is determined by whether the cross happens above or below the zero line.

Questions:
I don't really know where to start with coding this... Does anyone know of any good resources or threads (I searched futures.io (formerly BMT) but didn't really find anything related to this) that I could use? I'm here to learn, not to leech.

In NT, backtesting this strategy was way beyond my skill level and even some skilled coders I spoke to said this was difficult to code in NT due to the trailing stoploss and breakeven since they need to be triggered intra bar. This is possible to do in MC, right? From what I've read it seems possible...

Is there someplace I can go to learn some basic EasyLanguage coding fundamentals and logic?

Any help you can provide will be much appreciated!

Happy Trading,
ARich

nothing is impossible, all it takes is little time.

Reply With Quote
 
  #4 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

@Arich,

This webinar by Big Mike exactly answers your question (3-stage exits) :
https://futures.io/multicharts/11278-video-tutorial-how-create-advanced-multicharts-easylanguage-strategy.html

Could be a basis.

Nicolas

Reply With Quote
The following user says Thank You to Nicolas11 for this post:
 
  #5 (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

Code Only Produces One Entry

Hello,

I finished my first set of code! There were some errors and such, but I finally got it to compile. The only problem is that when applied to a chart it only produced one entry (a "buy") when it should have produced at least 20-30 entries over that time frame. Here is my 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 > 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 < 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 = 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 = 1 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 = 2 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 = 3 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 = 1 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 = 2 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 = 3 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;

Can anyone see why it is only executing one trade? It only enters one position too (instead of three positions). Is there a simpler way to code this?

All help is highly appreciated!


Reply With Quote
 
  #6 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

Hi,

I have tried it: the first trade is never closed. The problem is probably linked to the exit.

In case of problem, you should simplify the code to identify the issue.
Just keep one side (long or short).
Just keep one lot (not the 3 lots).
And debug.
When the short code will work, add back the other features.

People here will be happy to help you.
But it would be easier with a "simple" but non-working code rather than with a 100-line code.
In other words: a SSCCE.

Nicolas


Last edited by Nicolas11; September 17th, 2012 at 06:28 AM.
Reply With Quote
The following 3 users say Thank You to Nicolas11 for this post:
 
  #7 (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


Nicolas11 View Post
Hi,

I have tried it: the first trade is never closed. The problem is probably linked to the exit.

In case of problem, you should simplify the code to identify the issue.
Just keep one side (long or short).
Just keep one lot (not the 3 lots).
And debug.
When the short code will work, add back the other features.

People here will be happy to help you.
But it would be easier with a "simple" but non-working code rather than with a 100-line code.
In other words: a SSCCE.

Nicolas

Thank you for the suggestion! A big question for me is why it didn't enter all three positions. That's a big part of the strategy, and I have no idea why it won't enter all three positions... If it entered one, why not the others? Should I write it as:

Buy ("Enter Long1") 3 100000 contracts next bar at market;

instead of:

Buy ("Enter Long1") 100000 contracts next bar at market;
Buy ("Enter Long2") 100000 contracts next bar at market;
Buy ("Enter Long3") 100000 contracts next bar at market;

???

Thanks for your help!
ARich


Last edited by Arich; September 17th, 2012 at 02:07 PM. Reason: Typos
Reply With Quote
 
  #8 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

Yes, it could help. But do not forget "*" : 3 * 100000.

Once more, please post a SSCCE.

Nicolas

Reply With Quote
The following user says Thank You to Nicolas11 for this post:
 
  #9 (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


Nicolas11 View Post
Yes, it could help. But do not forget "*" : 3 * 100000.

Once more, please post a SSCCE.

Nicolas

Ah, thank you for the URL; I didn't know what you were referring to earlier.

This is the shortened code:

// Open new Positions

if MarketPosition = 0 then begin

if MyMACD > MACDAvg and MyMACD <= 0 and MACDAvg <= 0 then begin
Buy ("Enter Long1") 300000 contracts next bar at market;
end;
end;

// Manage open orders

if MarketPosition = 1 then begin

st1 = EntryPrice - (StopSize * TickSize);

if CurrentContracts = 1 then begin
Sell ("Exit l1-c1 Target") 3 * 100000 contracts Next Bar at (EntryPrice + t1) Limit;
Sell ("Exit l1-c1 Stop") 3 * 100000 contracts Next Bar at st1 Stop;
end;
end;

That's as bare-bones as it gets I'm afraid. Is there anything that jumps out at you? I've tried changing the lot size too, but I can't get it to show anything other than "100,000" on the chart. I'm not sure how to troubleshoot the exit part of the code either... Thanks for your help!

Reply With Quote
 
  #10 (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


did you restrict the fill to one order per direction?

Reply With Quote

Reply



futures io > > > > > NinjaTrader ATM in EasyLanguage

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
ATM Template? dsraider NinjaTrader Programming 12 May 23rd, 2012 05:52 PM
Stable ATM Strategies? Baseheadz NinjaTrader Programming 1 August 21st, 2011 04:30 PM
ATM Strategy for Ninjatrader keepdchange NinjaTrader 6 October 6th, 2010 04:57 AM
ATM and Limit Orders spinnybobo NinjaTrader Programming 6 June 12th, 2010 09:06 PM
ATM Strategies - NinjaTrader zeller4 NinjaTrader 1 June 19th, 2009 06:10 PM


All times are GMT -4. The time now is 08:46 PM.

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-10 in 0.19 seconds with 19 queries on phoenix via your IP 54.83.122.227