Order Entry, Target, Trailing Stop, and Exit - EasyLanguage Programming | futures io social day trading
futures io futures trading


Order Entry, Target, Trailing Stop, and Exit
Updated: Views / Replies:2,987 / 18
Created: by DrRon 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 100,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
 

Order Entry, Target, Trailing Stop, and Exit

  #11 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,781 since Apr 2013
Thanks: 284 given, 1,067 received

DrRon,

you should study how the reserved words for SetProfitTarget and SetStopLoss work and should be used. Take a look at the build in Profit Target and Stop Loss signals.
They are still placed inside your conditions and this will most likely result in your entries being without stops and targets at some point.

Regards,
ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #12 (permalink)
Elite Member
Irvine CA
 
Futures Experience: Advanced
Platform: NinjaTrader, TadeStation, ThinkOrSwim, and StreetSmartEdge
Favorite Futures: CL
 
Posts: 9 since Aug 2015
Thanks: 11 given, 1 received


ABCTG View Post
DrRon,

you should study how the reserved words for SetProfitTarget and SetStopLoss work and should be used. Take a look at the build in Profit Target and Stop Loss signals.
They are still placed inside your conditions and this will most likely result in your entries being without stops and targets at some point.

Regards,
ABCTG

Thank you ABCTG! I've made considerable progress in the coding of my order execution strategy. However, I've noticed that not every new bar is getting me in the trade. Also, it appears that every trade I'm getting in is getting me in at the opening of the new bar- NOT the high/low of the previous bar, as ordered. Any input would be greatly appreciated.

 
Code
[IntrabarOrderGeneration = True]

Inputs:
Numb_Shares(10), //[DisplayName="Number of Shares",ToolTip="Enter the number of shares per trade."],
Min_Range(.01), //[DisplayName="Minimum Range",ToolTip="Minimum range to trade."],
Max_Range(100), //[DisplayName="Maximum Range",ToolTip="Maximum range to trade."],
Bullish(1), //[DisplayName="Bullish Trades",ToolTip="Do you want to take bullish trades?(0=No/1=Yes)"],
Bearish(1), //[DisplayName="Bearish Trades",ToolTip="Do you want to take bearish trades?(0=No/1=Yes)"],
BlTgt_Thres(.2), //[DisplayName="Bull Target Threshold",ToolTip="What target threshold do wish to trade with?"],
BlStp_Thres(.8), //[DisplayName="Bull Stop Threshold",ToolTip="What stop threshold do wish to trade with?"],
BrTgt_Thres(.4), //[DisplayName="Bear Target Threshold",ToolTip="What target threshold do wish to trade with?"],
BrStp_Thres(1); //[DisplayName="Bear Stop Threshold",ToolTip="What stop threshold do wish to trade with?"];

Variables:
Bull(False),
Bear(False),
BuyTarget(0),
SellTarget(0),
BuyStop(0),
SellStop(0);

If BarStatus(1)=2 And Range>=Min_Range And Range<=Max_Range Then
Begin
	Bull=Open<Close;
	Bear=Open>Close;
	Print(File("c:\testOrderExe.txt"),Date,Time,Close);
	If MarketPosition(0)=0 Then
	Begin
		If Bullish=1 And Bull
		Then
		Begin
			BuyTarget=Range*BlTgt_Thres;
			BuyStop=Range*BlStp_Thres;
			Print(File("c:\testOrderExe.txt"),Date,Time,Close," Bullish ",High,(High+BuyTarget),(High-BuyStop));
			Buy Numb_Shares Shares Next Bar At High Stop;
		End
		Else
		If Bearish=1 And Bear
		Then
		Begin
			SellTarget=Range*BrTgt_Thres;
			SellStop=Range*BrStp_Thres;
			Print(File("c:\testOrderExe.txt"),Date,Time,Close," Bearish ",Low,(Low-SellTarget),(Low+SellStop));
			SellShort Numb_Shares Shares Next Bar At Low Stop;
		End;
	End;	
End;
If MarketPosition(0)=1 Then
Begin
	Print(File("c:\testOrderExe.txt"),Date,Time,Close," Bullxxh ",High,(High+BuyTarget),(High-BuyStop));
	SetStopShare;
	SetProfitTarget(BuyTarget);
	SetStopLoss(BuyStop);
End;
If MarketPosition(0)=-1 Then
Begin
	Print(File("c:\testOrderExe.txt"),Date,Time,Close," Bearxxh ",Low,(Low-SellTarget),(Low+SellStop));
	SetStopShare;
	SetProfitTarget(SellTarget);
	SetStopLoss(SellStop);
End;

Reply With Quote
 
  #13 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,781 since Apr 2013
Thanks: 284 given, 1,067 received


DrRon,

you might want to add print statements to check your conditions on the bars that don't get you in a trade. So you can check what happens there. If you are already inside a position, this might just be caused by your pyramiding settings that block new trades.
Using your code I don't see any situation on a chart where the trade entry is not at the high or low of the previous bar (or higher/lower due to the stop order). What chart symbol and time frame did you use. Can you post an example of a specific situation?

On a side note, with intrabar order generation you should use the look inside bar backtesting feature if you don't already.

Regards,

ABCTG


DrRon View Post
Thank you ABCTG! I've made considerable progress in the coding of my order execution strategy. However, I've noticed that not every new bar is getting me in the trade. Also, it appears that every trade I'm getting in is getting me in at the opening of the new bar- NOT the high/low of the previous bar, as ordered. Any input would be greatly appreciated.

 
Code
[IntrabarOrderGeneration = True]

Inputs:
Numb_Shares(10), //[DisplayName="Number of Shares",ToolTip="Enter the number of shares per trade."],
Min_Range(.01), //[DisplayName="Minimum Range",ToolTip="Minimum range to trade."],
Max_Range(100), //[DisplayName="Maximum Range",ToolTip="Maximum range to trade."],
Bullish(1), //[DisplayName="Bullish Trades",ToolTip="Do you want to take bullish trades?(0=No/1=Yes)"],
Bearish(1), //[DisplayName="Bearish Trades",ToolTip="Do you want to take bearish trades?(0=No/1=Yes)"],
BlTgt_Thres(.2), //[DisplayName="Bull Target Threshold",ToolTip="What target threshold do wish to trade with?"],
BlStp_Thres(.8), //[DisplayName="Bull Stop Threshold",ToolTip="What stop threshold do wish to trade with?"],
BrTgt_Thres(.4), //[DisplayName="Bear Target Threshold",ToolTip="What target threshold do wish to trade with?"],
BrStp_Thres(1); //[DisplayName="Bear Stop Threshold",ToolTip="What stop threshold do wish to trade with?"];

Variables:
Bull(False),
Bear(False),
BuyTarget(0),
SellTarget(0),
BuyStop(0),
SellStop(0);

If BarStatus(1)=2 And Range>=Min_Range And Range<=Max_Range Then
Begin
	Bull=Open<Close;
	Bear=Open>Close;
	Print(File("c:\testOrderExe.txt"),Date,Time,Close);
	If MarketPosition(0)=0 Then
	Begin
		If Bullish=1 And Bull
		Then
		Begin
			BuyTarget=Range*BlTgt_Thres;
			BuyStop=Range*BlStp_Thres;
			Print(File("c:\testOrderExe.txt"),Date,Time,Close," Bullish ",High,(High+BuyTarget),(High-BuyStop));
			Buy Numb_Shares Shares Next Bar At High Stop;
		End
		Else
		If Bearish=1 And Bear
		Then
		Begin
			SellTarget=Range*BrTgt_Thres;
			SellStop=Range*BrStp_Thres;
			Print(File("c:\testOrderExe.txt"),Date,Time,Close," Bearish ",Low,(Low-SellTarget),(Low+SellStop));
			SellShort Numb_Shares Shares Next Bar At Low Stop;
		End;
	End;	
End;
If MarketPosition(0)=1 Then
Begin
	Print(File("c:\testOrderExe.txt"),Date,Time,Close," Bullxxh ",High,(High+BuyTarget),(High-BuyStop));
	SetStopShare;
	SetProfitTarget(BuyTarget);
	SetStopLoss(BuyStop);
End;
If MarketPosition(0)=-1 Then
Begin
	Print(File("c:\testOrderExe.txt"),Date,Time,Close," Bearxxh ",Low,(Low-SellTarget),(Low+SellStop));
	SetStopShare;
	SetProfitTarget(SellTarget);
	SetStopLoss(SellStop);
End;


Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #14 (permalink)
Elite Member
Irvine CA
 
Futures Experience: Advanced
Platform: NinjaTrader, TadeStation, ThinkOrSwim, and StreetSmartEdge
Favorite Futures: CL
 
Posts: 9 since Aug 2015
Thanks: 11 given, 1 received

Entry, Target, Stop, and Exit

Thank you ABCTG. I have placed plenty of print statements inside conditions on the bars and am getting a very deep understanding of how orders are executed with EasyLanguage. I'm using AMZN-15M chart as a sample.

A problem I'm in the middle of, at the moment, is when MarketPosition becomes a 1, I push SetprofitTarget and SetStopLoss orders. When it is filled one way or another, what do I look for in order to know it has been filled?

Also, would you kindly provide a link for me to read about Intrabar "look inside bar" backtesting feature please?

Reply With Quote
 
  #15 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,781 since Apr 2013
Thanks: 284 given, 1,067 received

DrRon,

I would have to look it up in the Tradestation wiki, forum or helpfile, too. You should be able to find it in all three.
You can also use Google to find something.

Regards,

ABCTG


DrRon View Post
Also, would you kindly provide a link for me to read about Intrabar "look inside bar" backtesting feature please?


Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #16 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,781 since Apr 2013
Thanks: 284 given, 1,067 received

DrRon,

when your MarketPosition changes from 1 to 0 an exit took place. You can then check if the trade exited with a profit or loss and thus know if your target or stop was hit.
If you need more information you can obtain order names etc. via Object Oriented Easylanguage, but I would advise to only start using that once you have a solid EasyLanguage foundation to build onto.

Regards,

ABCTG


DrRon View Post
A problem I'm in the middle of, at the moment, is when MarketPosition becomes a 1, I push SetprofitTarget and SetStopLoss orders. When it is filled one way or another, what do I look for in order to know it has been filled?


Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #17 (permalink)
Elite Member
Irvine CA
 
Futures Experience: Advanced
Platform: NinjaTrader, TadeStation, ThinkOrSwim, and StreetSmartEdge
Favorite Futures: CL
 
Posts: 9 since Aug 2015
Thanks: 11 given, 1 received

Entry, Target, Stop, and Exit

[UPDATE] I created a flag that would indicate where we are in the process and after exhaustive troubleshooting I discovered that when I'm declaring this flag under variables, I must declare it as IntraBarPersist when IOG is true!

Reply With Quote
 
  #18 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,781 since Apr 2013
Thanks: 284 given, 1,067 received

DrRon,

this goes for all your variables that you want to update intrabar, otherwise they might not hold the correct values.

Regards,

ABCTG


DrRon View Post
[UPDATE] I created a flag that would indicate where we are in the process and after exhaustive troubleshooting I discovered that when I'm declaring this flag under variables, I must declare it as IntraBarPersist when IOG is true!


Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #19 (permalink)
Elite Member
Irvine CA
 
Futures Experience: Advanced
Platform: NinjaTrader, TadeStation, ThinkOrSwim, and StreetSmartEdge
Favorite Futures: CL
 
Posts: 9 since Aug 2015
Thanks: 11 given, 1 received

Entry, Target, Stop, and Exit

Thanks ABCTG! I wish someone had told me about this. After putting Print at every turn, I noticed that my flag was changing values (like it had a mind of its own). I dug deeper into declaring variables and discovered IntraBarPersist!

Reply With Quote

Reply



futures io > > > > > Order Entry, Target, Trailing Stop, and Exit




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

September Journal Challenge (sponsored by TopstepTrader)

September

Free Elite Membership: Twitter Tuesday and Facebook Friday!

Tue & Fri

TopstepTrader (TBD)

Sep 25

RandBots (TBD)

Sep 27

Anthony Drager (TBD)

Oct 4
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ninja trailing stop based upon R/R to the target Cristian NinjaTrader Programming 1 October 30th, 2014 02:34 PM
Exit using Entry price plus/minus profit target Bodil Elite EasyLanguage Automated Trading 2 November 30th, 2013 06:21 PM
profit target turns into trailing stop loss peaceNlove NinjaTrader Programming 3 August 22nd, 2013 12:07 PM
Exit at close for trailing stop strategy skorpyo ThinkOrSwim Programming 0 July 27th, 2013 04:56 AM
Trailing stop and Target on Idicator Help bdd069 Elite Automated Trading 4 February 10th, 2013 07:38 PM


All times are GMT -4. The time now is 10:05 AM. (this page content is cached, log in for real-time version)

Copyright © 2018 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 2018-09-22 in 0.17 seconds with 15 queries on phoenix