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:1,787 / 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 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
 

Order Entry, Target, Trailing Stop, and Exit

  #11 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 854 received
Forum Reputation: Legendary

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)
Trading Apprentice
Irvine CA
 
Futures Experience: Advanced
Platform: NinjaTrader, TadeStation, ThinkOrSwim, and StreetSmartEdge
Favorite Futures: CL
 
Posts: 8 since Aug 2015
Thanks: 11 given, 0 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)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 854 received
Forum Reputation: Legendary


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)
Trading Apprentice
Irvine CA
 
Futures Experience: Advanced
Platform: NinjaTrader, TadeStation, ThinkOrSwim, and StreetSmartEdge
Favorite Futures: CL
 
Posts: 8 since Aug 2015
Thanks: 11 given, 0 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)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 854 received
Forum Reputation: Legendary

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)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 854 received
Forum Reputation: Legendary

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)
Trading Apprentice
Irvine CA
 
Futures Experience: Advanced
Platform: NinjaTrader, TadeStation, ThinkOrSwim, and StreetSmartEdge
Favorite Futures: CL
 
Posts: 8 since Aug 2015
Thanks: 11 given, 0 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)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 854 received
Forum Reputation: Legendary

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)
Trading Apprentice
Irvine CA
 
Futures Experience: Advanced
Platform: NinjaTrader, TadeStation, ThinkOrSwim, and StreetSmartEdge
Favorite Futures: CL
 
Posts: 8 since Aug 2015
Thanks: 11 given, 0 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

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

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 03:34 PM
Exit using Entry price plus/minus profit target Bodil Elite EasyLanguage Automated Trading 2 November 30th, 2013 07:21 PM
profit target turns into trailing stop loss peaceNlove NinjaTrader Programming 3 August 22nd, 2013 01:07 PM
Exit at close for trailing stop strategy skorpyo ThinkOrSwim Programming 0 July 27th, 2013 05:56 AM
Trailing stop and Target on Idicator Help bdd069 Elite Automated Trading 4 February 10th, 2013 08:38 PM


All times are GMT -4. The time now is 07:00 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-14 in 0.13 seconds with 19 queries on phoenix via your IP 54.226.227.175