Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Profit Target is Ignored
Collapse
X
-
Profit Target is Ignored
In the attached code, you will see a dummy strategy (if EMA(5) > EMA(15), Buy, otherwise, Short). The purpose of this strategy is to illustrate the adjustment of Stop Targets. So if the price goes in the direction of the trade, I adjust the stop loss to be the entry price or a few ticks above or below the entry price depending if the order was a Long or Short. I am noticing that my Profit Target is being ignored for certain orders (see attached chart screen shot). In the chart, you can see I enter a Short, but I exit at my StopTarget. Clearly, I should have exited at my Profit Target at 4 ticks. I have attached the code and Strategy Analyzer inputs I used. Does anyone know why this behavior is occurring?2 PhotosTags: None
-
Hello lewisquake,
Thank you for your post.
Here's what I'm seeing in the Trace Orders for that date of a backtest:
7/30/2020 1:00:00 AM Strategy 'BreakEvenStop/-1': Entered internal SubmitOrderManaged() method at 7/30/2020 1:00:00 AM: BarsInProgress=0 Action=SellShort OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='MyEntry' FromEntrySignal=''
Bar: 539
Current Position: Flat
3221.5
We entered at 7/30/2020 1:00:00 AM
7/30/2020 1:00:00 AM Strategy 'BreakEvenStop/-1': Entered internal SubmitOrderManaged() method at 7/30/2020 1:00:00 AM: BarsInProgress=1 Action=BuyToCover OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=3226.50 SignalName='MyStop' FromEntrySignal='MyEntry'
7/30/2020 1:00:00 AM Strategy 'BreakEvenStop/-1': Entered internal SubmitOrderManaged() method at 7/30/2020 1:00:00 AM: BarsInProgress=1 Action=Sell OrderType=Limit Quantity=1 LimitPrice=3220.50 StopPrice=0 SignalName='MyTarget' FromEntrySignal='MyEntry'
7/30/2020 1:00:00 AM Strategy 'BreakEvenStop/-1': Ignored SubmitOrderManaged() method at 7/30/2020 1:00:00 AM: BarsInProgress=1 Action=Sell OrderType=Limit Quantity=1 LimitPrice=3220.50 StopPrice=0 SignalName='MyTarget' FromEntrySignal='MyEntry' Reason='This was an exit order but no position exists to exit'
Basically, the order is being ignored because you're using the incorrect exit order for the position type, you're using ExitLongLimit to try to place your profit target for a short order when you should be using ExitShortLimit:
Code:else if(Position.MarketPosition == MarketPosition.Short){ stopOrder = ExitShortStopMarket(1, true, execution.Order.Filled, execution.Order.AverageFillPrice + StopLossTicks * TickSize, "MyStop", "MyEntry"); targetOrder = [B]ExitLongLimit[/B](1, true, execution.Order.Filled, execution.Order.AverageFillPrice - ProfitTicks * TickSize, "MyTarget", "MyEntry"); entryprice = execution.Order.AverageFillPrice; }
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
31 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
2 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,281 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
||
Started by WHICKED, Today, 12:45 PM
|
2 responses
19 views
0 likes
|
Last Post
by WHICKED
Today, 03:36 PM
|
||
Started by Tim-c, Today, 02:10 PM
|
1 response
10 views
0 likes
|
Last Post Today, 02:52 PM |
Comment