NexusFi: Find Your Edge


Home Menu

 





IOrders - ExitOrders problem


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one FILIP88 with 4 posts (0 thanks)
    2. looks_two stearno with 2 posts (0 thanks)
    3. looks_3 shodson with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 1,330 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 1 attachments




 
Search this Thread

IOrders - ExitOrders problem

  #1 (permalink)
 FILIP88 
Ostrava, Czech Republic
 
Experience: Beginner
Platform: Ninja trader
Trading: currency
Posts: 9 since Mar 2015
Thanks Given: 4
Thanks Received: 0

Hello everybody,

i would like to ask some experienced programmer for a help with IOrders.

I have programmed simple strategy that should set profit target and stop loss by ExitLongStop and Exit longLimit. After entering a position, TP should be set 50 ticks above entry and SL should be set 50ticks bellow entry. Unfortunately when I apply strategy in a chart and position is entered, sometimes, the strategy omit exit orders, please see chart bellow.



ENTRY
 
Code
entryOrderLong = EnterLongStop(0, false, 1, High[0] + 1 * TickSize, "LONG");
				
Print("LONG TRADE" + High[0] + 1 * TickSize );
IORDERS

 
Code
if (entryOrderLong != null && entryOrderLong == order)
		{
			if (order.OrderState == OrderState.Filled)
			{

				exitLimitLong = ExitLongLimit(0, true, 1, entryOrderLong.AvgFillPrice + 50 * TickSize, "PROFIT TARGET",entryOrderLong.FromEntrySignal);
				
				exitStopLong = ExitLongStop(0, true, 1, entryOrderLong.AvgFillPrice - 50 * TickSize, "STOP LOSS", entryOrderLong.FromEntrySignal); 	
			
			}
		}
LOG:

 
Code
24.3.2015 19:20:00 Entered internal PlaceOrder() method at 24.3.2015 19:20:00: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=953,00 SignalName='LONG' FromEntrySignal=''
LONG TRADE952,750,25
24.3.2015 19:20:00 Entered internal PlaceOrder() method at 24.3.2015 19:20:00: BarsInProgress=0 Action=Sell OrderType=Limit Quantity=1 LimitPrice=965,50 StopPrice=0 SignalName='PROFIT TARGET' FromEntrySignal=''
24.3.2015 19:20:00 Amended open order: Action=Sell OrderType=Limit Quantity=1 LimitPrice=965,50 StopPrice=0 SignalName=PROFIT TARGET' FromEntrySignal=''
24.3.2015 19:20:00 Entered internal PlaceOrder() method at 24.3.2015 19:20:00: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=940,50 SignalName='STOP LOSS' FromEntrySignal=''
24.3.2015 19:20:00 Amended open order: Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=940,50 SignalName=STOP LOSS' FromEntrySignal=''
25.3.2015 19:20:00 Cancelled pending exit order, since associated position is closed: Order='NT-00020/Sim101' Name='PROFIT TARGET' State=Working Instrument='ZS 11-15' Action=Sell Limit price=965,5 Stop price=0 Quantity=1 Strategy='StrategyThree' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='44966be7f6ce492689259716b66ab447' Gtd='1.12.2099 0:00:00'


I am quite confused, since sometimes it set stop orders correctly, sometimes it ommits... :s

Could please somebody tell me what is wrong with the code?

Thank you

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
60 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #3 (permalink)
 FILIP88 
Ostrava, Czech Republic
 
Experience: Beginner
Platform: Ninja trader
Trading: currency
Posts: 9 since Mar 2015
Thanks Given: 4
Thanks Received: 0


problem fixed

Started this thread Reply With Quote
  #4 (permalink)
 stearno 
Muscat, Oman
 
Experience: Intermediate
Platform: Ninja and MT4
Trading: Forex
Posts: 15 since Apr 2012
Thanks Given: 4
Thanks Received: 3

Can you share what you did to fix so we could learn as well?

Sent from my HUAWEI MT7-TL10 using Tapatalk

Reply With Quote
  #5 (permalink)
 FILIP88 
Ostrava, Czech Republic
 
Experience: Beginner
Platform: Ninja trader
Trading: currency
Posts: 9 since Mar 2015
Thanks Given: 4
Thanks Received: 0


stearno View Post
Can you share what you did to fix so we could learn as well?

Sent from my HUAWEI MT7-TL10 using Tapatalk

i had wrongly set exit orders and entryhandling

When i entered in the 1st trade, my exitorders were set according to ExitLimitLong and ExitLimitStops in block OnOrderUpdate. The problem was, when i entered in the 2nd trade and had still opened 1st position, i called again the same IOrders from OnOrderUpdates which have already set SL/TP for the 1st position, so that my exit orders were amended.
 
Code
24.3.2015 19:20:00 Entered internal PlaceOrder() method at 24.3.2015 19:20:00: BarsInProgress=0 Action=Sell OrderType=Limit Quantity=1 LimitPrice=965,50 StopPrice=0 SignalName='PROFIT TARGET' FromEntrySignal=''
24.3.2015 19:20:00 Amended open order: Action=Sell OrderType=Limit Quantity=1 LimitPrice=965,50 StopPrice=0 SignalName=PROFIT TARGET' FromEntrySignal=''
24.3.2015 19:20:00 Entered internal PlaceOrder() method at 24.3.2015 19:20:00: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=940,50 SignalName='STOP LOSS' FromEntrySignal=''
24.3.2015 19:20:00 Amended open order: Action=Sell OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=940,50 SignalName
Also my entryhandlig was set as 100entries per direction

 
Code
EntriesPerDirection = 100;
 EntryHandling = EntryHandling.AllEntries;

I changed entryhandling as i can be only in one trade in a time and then everything was ok.

Started this thread Reply With Quote
  #6 (permalink)
 stearno 
Muscat, Oman
 
Experience: Intermediate
Platform: Ninja and MT4
Trading: Forex
Posts: 15 since Apr 2012
Thanks Given: 4
Thanks Received: 3

Thank you. I don't know much on this system of order handling so it helps to read your words.

Sent from my HUAWEI MT7-TL10 using Tapatalk

Reply With Quote
  #7 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709

It'd be easier to just use SetProfitTarget() and SetStopLoss() at 50 ticks each.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 FILIP88 
Ostrava, Czech Republic
 
Experience: Beginner
Platform: Ninja trader
Trading: currency
Posts: 9 since Mar 2015
Thanks Given: 4
Thanks Received: 0


shodson View Post
It'd be easier to just use SetProfitTarget() and SetStopLoss() at 50 ticks each.

Yes, SetStopLoss and SetProfitTarget would be easier, but i used IOrders to be more flexible in my exit orders.

Started this thread Reply With Quote




Last Updated on September 21, 2015


© 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