Trading Articles
Article Categories
Article Tools
IOrders - ExitOrders problem
Updated September 21, 2015
Top Posters
looks_one
FILIP88
with 4 posts (0 thanks)
looks_two
stearno
with 2 posts (0 thanks)
looks_3
Quick Summary
with 1 posts (0 thanks)
looks_4
shodson
with 1 posts (0 thanks)
trending_up
1,027 views
thumb_up
0 thanks given
group
3 followers
forum
7 posts
attach_file
1 attachments
Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
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
(If you already have an account, login at the top of the page)
IOrders - ExitOrders problem
(login for full post details)
#1 (permalink )
Ostrava, Czech Republic
Experience: Beginner
Platform: Ninja trader
Trading: currency
Posts: 9 since Mar 2015
Thanks: 4 given,
0
received
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
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#3 (permalink )
Ostrava, Czech Republic
Experience: Beginner
Platform: Ninja trader
Trading: currency
Posts: 9 since Mar 2015
Thanks: 4 given,
0
received
problem fixed
(login for full post details)
#4 (permalink )
Muscat, Oman
Experience: Intermediate
Platform: Ninja and MT4
Trading: Forex
Posts: 15 since Apr 2012
Thanks: 4 given,
3
received
Can you share what you did to fix so we could learn as well?
Sent from my HUAWEI MT7-TL10 using Tapatalk
(login for full post details)
#5 (permalink )
Ostrava, Czech Republic
Experience: Beginner
Platform: Ninja trader
Trading: currency
Posts: 9 since Mar 2015
Thanks: 4 given,
0
received
stearno
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.
(login for full post details)
#6 (permalink )
Muscat, Oman
Experience: Intermediate
Platform: Ninja and MT4
Trading: Forex
Posts: 15 since Apr 2012
Thanks: 4 given,
3
received
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
(login for full post details)
#7 (permalink )
OC, California, USA
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,958 since Jun 2009
Thanks: 528 given,
3,648
received
It'd be easier to just use SetProfitTarget() and SetStopLoss() at 50 ticks each.
(login for full post details)
#8 (permalink )
Ostrava, Czech Republic
Experience: Beginner
Platform: Ninja trader
Trading: currency
Posts: 9 since Mar 2015
Thanks: 4 given,
0
received
shodson
Yes, SetStopLoss and SetProfitTarget would be easier, but i used IOrders to be more flexible in my exit orders.
Last Updated on September 21, 2015
Right now
Ongoing
Coming soon
March
Register to Attend
Elite only
Register to Attend
Elite only
Right now
April