Controlling Order Entry in a strategy - futures io
futures io futures trading



Controlling Order Entry in a strategy


Discussion in EasyLanguage Programming

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

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

 
Search this Thread
 

Controlling Order Entry in a strategy

(login for full post details)
  #1 (permalink)
Atlanta, GA, USA
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
 
Posts: 1,834 since Mar 2013
Thanks: 3,000 given, 2,153 received

I am learning to code in EL and trying to generate a very simple strategy based on slope change but I would like to control the order entry using a flag as given in following code but orders are not getting generated, what am I doing wrong?

I want to control when to enter the market using LongTradeFlag and ShortTradeFlag but this simple thing I couldn't get it working. It compiles successfully but in real time on sim account orders are not generated.

Thanks in advance

 
Code
[IntrabarOrderGeneration = false]

Inputs: WMALength(89), Price(Close), posSize(1), StopTicks(40), BrokerFlag(false);//, LongTradeFlag(true), ShortTradeFlag(false);

variables:
	var0( 0 ),
	myStop(0);

Vars: LongTradeFlag(false), ShortTradeFlag(true);

var0 = WAverage( Price, WMALength ) ;

//condition1 = (Price >= var0) and (var0 > var0[1] and var0[1] < var0[2]) ;
//condition2 = (Price <= var0) and (var0 < var0[1] and var0[1] > var0[2]) ;

Condition1 = var0 > var0[1] and LongTradeFlag = true;
Condition2 = var0 < var0[1] and ShortTradeFlag = true;

Condition3 = date = currentdate and time > currenttime-1;



If condition1 then Begin

		
	if price >= var0 and marketposition <> 1 then begin
		Buy ("LE") posSize contracts next bar at Market;
		ShortTradeFlag = true;
		LongTradeFlag = false;
	end;
End;

If condition2 then Begin
	
	if price <= var0  and marketposition <> -1 then begin
		Sell short ("SE") posSize contracts next bar at Market;
		ShortTradeFlag = false;
		LongTradeFlag = true;

	end;
End;

Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
The following 2 users say Thank You to bmtrading9 for this post:

Can you help answer these questions
from other members on futures io?
Automatic pattern research with NT
Elite Algorithmic NinjaTrader Trading
Indicators for pair trading MES and M2K
Platforms and Indicators
Work with historical tcks data on MUltichart NET PowerLa …
MultiCharts
If ES tracks SPX, why do support/resistance, Level 2, vo …
Emini and Emicro Index
Reading A set of Trading Signals
EasyLanguage Programming
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Selling Options on Futures?
109 thanks
Battlestations: Show us your trading desks!
108 thanks
Rank your Futures vs Stocks trading priority
55 thanks
Want your NinjaTrader indicator created, free?
27 thanks
Whats this confusion with margins?
21 thanks
 
(login for full post details)
  #3 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received


bmtrading9,

I'd suggest to add print statements to your code, so you know what is going on internally. For example that your Condition1 and Condition2 can never become true and your system won't be able to enter trades.
Besides that as you start out, I'd suggest to get into the habit of using meaningful variable names and to comment your code as this will make your live so much easier down the road.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
(login for full post details)
  #4 (permalink)
Atlanta, GA, USA
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
 
Posts: 1,834 since Mar 2013
Thanks: 3,000 given, 2,153 received


ABCTG View Post
bmtrading9,

I'd suggest to add print statements to your code, so you know what is going on internally. For example that your Condition1 and Condition2 can never become true and your system won't be able to enter trades.
Besides that as you start out, I'd suggest to get into the habit of using meaningful variable names and to comment your code as this will make your live so much easier down the road.

Regards,

ABCTG

Thanks for your response, yes, I have to add print statements (I need to do some research on how to do it). I didn't get you point of Condition1 and Condition2 will never become true.

My thinking is when I turn on the strategy it should consider only SHORT TRADES as per the code isn't it? This is the main idea behind this exercise i.e control the entry in the strategy based on flag. If you have any better way to control the entries in a strategy please suggest.

Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

Sorry, my bad I overlooked that you initialized ShortTradeFlag with true on declaration. I loaded your code here and it's taking plenty of trades, so it might just be a settings issue. I used an @ES# 5 minute chart and 10 days back.

You can find information on how to utilize the print reserved word here.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
(login for full post details)
  #6 (permalink)
Atlanta, GA, USA
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
 
Posts: 1,834 since Mar 2013
Thanks: 3,000 given, 2,153 received

It doesn't take in real time, that's what puzzling me.

Sent from my SAMSUNG-SM-G900A using Tapatalk

Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #7 (permalink)
Atlanta, GA, USA
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
 
Posts: 1,834 since Mar 2013
Thanks: 3,000 given, 2,153 received


bmtrading9 View Post
It doesn't take in real time, that's what puzzling me.

Sent from my SAMSUNG-SM-G900A using Tapatalk

I guess the issue is these variables are getting assigned on every bar update so controlling that might help.

Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #8 (permalink)
Atlanta, GA, USA
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
 
Posts: 1,834 since Mar 2013
Thanks: 3,000 given, 2,153 received


ABCTG View Post
Sorry, my bad I overlooked that you initialized ShortTradeFlag with true on declaration. I loaded your code here and it's taking plenty of trades, so it might just be a settings issue. I used an @ES# 5 minute chart and 10 days back.

You can find information on how to utilize the print reserved word here.

Regards,

ABCTG

Those print statements helped in identifying what is happening so I thought...


Why can't I initialize the variables LongTradeFlag(true), ShortTradeFlag(false) from INPUT?

but I was getting following compiling error

"array, varable or refinput expected"

I guess if I can control this flag from INPUT, I should be able to solve this...

Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #9 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

Because variables and inputs are two different things. You can't use an input like a variable.

You would need two variables and two different inputs and then store one input's value in one variable and the second one in the other.

Regards,

ABCTG


bmtrading9 View Post
Why can't I initialize the variables LongTradeFlag(true), ShortTradeFlag(false) from INPUT?


Follow me on Twitter Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
(login for full post details)
  #10 (permalink)
Atlanta, GA, USA
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
 
Posts: 1,834 since Mar 2013
Thanks: 3,000 given, 2,153 received



ABCTG View Post
Because variables and inputs are two different things. You can't use an input like a variable.

You would need two variables and two different inputs and then store one input's value in one variable and the second one in the other.

Regards,

ABCTG

Thanks alot! That's perfect on the first run. I have to look deep into it.

Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Controlling Order Entry in a strategy


Last Updated on September 27, 2016


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 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