stop loss & profit target order settings with the unamanaged approach? - NinjaTrader | futures io social day trading
futures io futures trading


stop loss & profit target order settings with the unamanaged approach?
Updated: Views / Replies:1,186 / 5
Created: by stevien 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
 

stop loss & profit target order settings with the unamanaged approach?

  #1 (permalink)
Trading Apprentice
Paris France
 
Futures Experience: None
Platform: NinjaTrader
Favorite Futures: index futures
 
Posts: 2 since Nov 2015
Thanks: 1 given, 0 received

stop loss & profit target order settings with the unamanaged approach?

Hello,

I am developing a new strategy with the unmanaged approach. When I enter a long/short position, I don't know how to exit this position, then set a stop loss order and a profit target order because everytime I run my script below, NinjaTrader doesn't respond.
Here is the script :

public class SStrategy : Strategy
{
#region Variables
// User defined variables (add any user defined variables below)
private int quantity = 1;
private int target = 30;

private IOrder longOrder = null;
private IOrder shortOrder = null;
private IOrder stopLossOrder = null;
private IOrder profitTargetOrder = null;
#endregion

/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;

Unmanaged = true;

// TraceOrders = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Buying condition
if (Close[0] < Bollinger(2, 14).Lower[0])
{
longOrder = SubmitOrder(0,OrderAction.Buy,OrderType.Market,quantity,0,0,"","ELong");
// SubmitOrder(0,OrderAction.Sell,OrderType.StopLimit,quantity,0,0,"","XLong");
}

// Shorting condition
else if (Close[0] > Bollinger(2, 14).Upper[0])
{
shortOrder = SubmitOrder(0,OrderAction.SellShort,OrderType.Market,quantity,0,0,"","EShort");
// SubmitOrder(0,OrderAction.Buy,OrderType.StopLimit,quantity,0,0,"","XShort");
}
}

protected override void OnExecution(IExecution execution)
{
if (longOrder != null && longOrder == execution.Order)
{
if (execution.MarketPosition == MarketPosition.Long)
{
if (shortOrder != null)
CancelOrder(shortOrder);
shortOrder = null;

if (Close[0] > Low[0])
{
stopLossOrder = SubmitOrder(0,OrderAction.Sell,OrderType.Stop,quantity,0,MIN(Low,2)[0] - 1*TickSize,"","LongSL");
}

profitTargetOrder = SubmitOrder(0,OrderAction.Sell,OrderType.Limit,quantity,target,0,"","LongPT");
}
}
else if (shortOrder != null && shortOrder == execution.Order)
{
if (execution.MarketPosition == MarketPosition.Short)
{
if (longOrder != null)
CancelOrder(longOrder);
longOrder = null;

if (Close[0] < High[0])
{
stopLossOrder = SubmitOrder(0,OrderAction.BuyToCover,OrderType.Stop,quantity,0,MAX(High,3)[0] + 1*TickSize,"","ShortSL");
}

profitTargetOrder = SubmitOrder(0,OrderAction.BuyToCover,OrderType.Limit,quantity,target,0,"","ShortPT");
}
}

// Resets the longOrder and shortOrder objects to null after the order has been filled
// if (execution.Order.OrderState != OrderState.PartFilled)
// {
// longOrder = null;
// shortOrder = null;
// }

// Reset our stop order and target orders' IOrder objects after our position is closed.
if ((stopLossOrder != null && stopLossOrder == execution.Order) || (profitTargetOrder != null && profitTargetOrder == execution.Order))
{
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled)
{
stopLossOrder = null;
profitTargetOrder = null;
}
}
}

#region Properties
[Description("Quantity of the underlying asset")]
[GridCategory("Parameters")]
public int Quantity
{
get { return quantity; }
set { quantity = Math.Max(1, value); }
}

[Description("Target of this position")]
[GridCategory("Parameters")]
public int Target
{
get { return target; }
set { target = Math.Max(1, value); }
}

#endregion
}


Could anyone help me, please?

Thank you!

PS: Excuse my English.

Reply With Quote
 
  #2 (permalink)
Market Wizard
London UK
 
Futures Experience: Beginner
Platform: CQG
Favorite Futures: Futures
 
xplorer's Avatar
 
Posts: 3,057 since Sep 2015
Thanks: 6,580 given, 4,834 received
Forum Reputation: Legendary

Have you tried...

Hi stevien - sorry I'm not familiar enough with NT to answer your specific question, but I would have thought that the platform must allow for some sort or bracket order where you automatically set a stop loss and a target?

Reply With Quote
 
  #3 (permalink)
Elite Member
Seattle, WA
 
Futures Experience: Intermediate
Platform: NinjaTrader 8
Broker/Data: AMP/CQG
Favorite Futures: Indices
 
stoicbuddha's Avatar
 
Posts: 79 since Feb 2012
Thanks: 282 given, 62 received

ChangeOrder


I may be wrong but shouldn't use to be using ChangeOrder() instead of SubmitOrder() when trying to set the stop loss/breakeven in the Unmanaged approach as mentioned here?

Reply With Quote
 
  #4 (permalink)
Elite Member
San Jose, CA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader, RCG/Continuum
Favorite Futures: GC,CL
 
Posts: 89 since Dec 2013
Thanks: 14 given, 89 received


happyrenko View Post
I may be wrong but shouldn't use to be using ChangeOrder() instead of SubmitOrder() when trying to set the stop loss/breakeven in the Unmanaged approach as mentioned here?

Uh, no.

Regardless of OrderType, you always use SubmitOrder() at least one time. You
always want to save the reference to the IOrder object returned by SubmitOrder.

Then, if you need to update the order later (aka, move the stop, to achieve either
a BreakEven or Trailing effect) you then call ChangeOrder() and pass the saved
reference from SubmitOrder() as the first argument.

So, when entering the stop loss order, you first use SubmitOrder. You save that IOrder
reference returned by SubmitOrder, and use it with ChangeOrder later ... if you need to.

In other words, you would not call ChangeOrder unless you first had an IOrder reference
returned to you from SubmitOrder.

Reply With Quote
 
  #5 (permalink)
Elite Member
Seattle, WA
 
Futures Experience: Intermediate
Platform: NinjaTrader 8
Broker/Data: AMP/CQG
Favorite Futures: Indices
 
stoicbuddha's Avatar
 
Posts: 79 since Feb 2012
Thanks: 282 given, 62 received


bltdavid View Post
Uh, no.

Regardless of OrderType, you always use SubmitOrder() at least one time. You
always want to save the reference to the IOrder object returned by SubmitOrder.

Then, if you need to update the order later (aka, move the stop, to achieve either
a BreakEven or Trailing effect) you then call ChangeOrder() and pass the saved
reference from SubmitOrder() as the first argument.

So, when entering the stop loss order, you first use SubmitOrder. You save that IOrder
reference returned by SubmitOrder, and use it with ChangeOrder later ... if you need to.

In other words, you would not call ChangeOrder unless you first had an IOrder reference
returned to you from SubmitOrder.

Yes, I meant use SubmitOrder() initially and ChangeOrder() later to fix the ability to change the Stop Loss later.

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
Chicago, IL
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: IQFeed
 
Posts: 4 since Jun 2009
Thanks: 1 given, 0 received

Hey Stevien I'm having the EXACT same issue. I'm assuming you now know how to close an open order using Unmanaged, SubmitOrder. How did you go about closing open orders?

Thanks in advance.

Reply With Quote

Reply



futures io > > > > stop loss & profit target order settings with the unamanaged approach?

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
Move stop loss after profit target is reached tbird NinjaTrader 3 August 28th, 2015 04:45 PM
stop loss and profit target should be fixed or variable? tripanasoma Psychology and Money Management 14 January 10th, 2015 09:31 PM
Different Profit Target and Stop Loss Order xoxo2013 ThinkOrSwim 2 January 24th, 2014 01:42 PM
profit target turns into trailing stop loss peaceNlove NinjaTrader Programming 3 August 22nd, 2013 01:07 PM
tracking each contract's profit target and stop loss sunsun MultiCharts 1 May 6th, 2013 09:10 AM


All times are GMT -4. The time now is 04:19 AM.

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-17 in 0.11 seconds with 31 queries on phoenix via your IP 54.227.51.103