NexusFi: Find Your Edge


Home Menu

 





Controlling Order Entry in a strategy


Discussion in EasyLanguage Programming

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




 
Search this Thread

Controlling Order Entry in a strategy

  #1 (permalink)
 bmtrading9 
Atlanta, GA, USA
Market Wizard
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
Posts: 1,833 since Mar 2013
Thanks Given: 3,001
Thanks Received: 2,159

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 NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


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
Thanked by:
  #4 (permalink)
 bmtrading9 
Atlanta, GA, USA
Market Wizard
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
Posts: 1,833 since Mar 2013
Thanks Given: 3,001
Thanks Received: 2,159


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 NexusFi Trade Journal Started this thread Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

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
Thanked by:
  #6 (permalink)
 bmtrading9 
Atlanta, GA, USA
Market Wizard
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
Posts: 1,833 since Mar 2013
Thanks Given: 3,001
Thanks Received: 2,159

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 NexusFi Trade Journal Started this thread Reply With Quote
  #7 (permalink)
 bmtrading9 
Atlanta, GA, USA
Market Wizard
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
Posts: 1,833 since Mar 2013
Thanks Given: 3,001
Thanks Received: 2,159


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 NexusFi Trade Journal Started this thread Reply With Quote
  #8 (permalink)
 bmtrading9 
Atlanta, GA, USA
Market Wizard
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
Posts: 1,833 since Mar 2013
Thanks Given: 3,001
Thanks Received: 2,159


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 NexusFi Trade Journal Started this thread Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

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
Thanked by:
  #10 (permalink)
 bmtrading9 
Atlanta, GA, USA
Market Wizard
 
Experience: Advanced
Platform: MC and Jigsaw
Trading: ES, MES
Posts: 1,833 since Mar 2013
Thanks Given: 3,001
Thanks Received: 2,159



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 NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on September 27, 2016


© 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