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
No suitable method found to override...
Collapse
X
-
Hello
Firstly, I would like to thank you for your help
Secondly, the prints look a bit weird, as you can see below: the check for the entries was Ok, but when the condition became 0, it was only trying to cancel Short1, then the position was cancelled automatically at the end of bar, while the strategy was still trying to cancel Short1, then an entry for only one order was processed in the opposite direction, followed by an error that disabled the strategy.
R = 1
04/10/2019 18:39:48 Strategy 'BreakDraft/178974590': Entered internal SubmitOrderManaged() method at 04/10/2019 18:39:48: BarsInProgress=0 Action=SellShort OrderType=StopLimit Quantity=1 LimitPrice=52.42 StopPrice=52.42 SignalName='Short1' FromEntrySignal=''
Submitted
Checking entryShort2
R = 1
04/10/2019 18:39:48 Strategy 'BreakDraft/178974590': Entered internal SubmitOrderManaged() method at 04/10/2019 18:39:48: BarsInProgress=0 Action=SellShort OrderType=StopLimit Quantity=1 LimitPrice=52.42 StopPrice=52.42 SignalName='Short2' FromEntrySignal=''
Submitted
Checking entryShort3
R = 1
04/10/2019 18:39:48 Strategy 'BreakDraft/178974590': Entered internal SubmitOrderManaged() method at 04/10/2019 18:39:48: BarsInProgress=0 Action=SellShort OrderType=StopLimit Quantity=1 LimitPrice=52.42 StopPrice=52.42 SignalName='Short3' FromEntrySignal=''
.
.
.
R = 0
Trying to cancel entryShort1
04/10/2019 18:40:00 - Flat
R = 0
Trying to cancel entryShort1
04/10/2019 18:40:00 - Flat
R = 0
Trying to cancel entryShort1
04/10/2019 18:40:00 - Flat
R = 0
Trying to cancel entryShort1
04/10/2019 18:41:00 - Flat
04/10/2019 18:40:01 Strategy 'BreakDraft/178974590': Cancelled expired order: BarsInProgress=0, orderId='970a95aa69c648b3a5aeedda73998a37' account='Sim101' name='Short1' orderState=Accepted instrument='CL 11-19' orderAction=SellShort orderType='Stop Limit' limitPrice=52.42 stopPrice=52.42 quantity=1 tif=Day oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=10093 time='2019-10-04 18:39:48' gtd='2099-12-01' statementDate='2019-10-04'
04/10/2019 18:40:01 Strategy 'BreakDraft/178974590': Cancelled expired order: BarsInProgress=0, orderId='ad3291be1e994f98bfee8dd56d70c5f8' account='Sim101' name='Short2' orderState=Accepted instrument='CL 11-19' orderAction=SellShort orderType='Stop Limit' limitPrice=52.42 stopPrice=52.42 quantity=1 tif=Day oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=10094 time='2019-10-04 18:39:48' gtd='2099-12-01' statementDate='2019-10-04'
04/10/2019 18:40:01 Strategy 'BreakDraft/178974590': Cancelled expired order: BarsInProgress=0, orderId='82441f8c69744f92804e54b55a442f4d' account='Sim101' name='Short3' orderState=Accepted instrument='CL 11-19' orderAction=SellShort orderType='Stop Limit' limitPrice=52.42 stopPrice=52.42 quantity=1 tif=Day oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=10095 time='2019-10-04 18:39:48' gtd='2099-12-01' statementDate='2019-10-04'
R = 0
Trying to cancel entryShort1
04/10/2019 18:41:00 - Flat
R = 0
Trying to cancel entryShort1
04/10/2019 18:41:00 - Flat
R = 0
Trying to cancel entryShort1
04/10/2019 18:41:00 - Flat
.
.
.
04/10/2019 18:41:00 - Flat
04/10/2019 18:41:00 - Flat
04/10/2019 18:41:00 - Flat
Checking entryLong1
S = 0
04/10/2019 18:40:39 Strategy 'BreakDraft/178974590': Entered internal SubmitOrderManaged() method at 04/10/2019 18:40:39: BarsInProgress=0 Action=Buy OrderType=StopLimit Quantity=1 LimitPrice=52.64 StopPrice=52.64 SignalName='Long1' FromEntrySignal=''
Strategy 'BreakDraft': Error on calling 'OnBarUpdate' method on bar 6696: Object reference not set to an instance of an object.
Disabling NinjaScript strategy 'BreakDraft/178974590'
-
Hi itrader46, thanks for your reply.
First, you would want to Print these conditions to make sure the entry is working properly.
entryLong1 == null
&& entryLong2 == null
&& entryLong3 == null
&& (condition))
Then print out the data before the check for trigger pending:
Print("Checking entryLong1");
Print(entryLong1.OrderState);
Print(condition);
if (entryLong1.OrderState == OrderState.TriggerPending &&(condition))
{
Print("Trying to cancel entryLong1");
CancelOrder(entryLong1);
}
Leave a comment:
-
...I'm not sure how to code the print for reaching the cancellation code or checking the condition being true when expected
Leave a comment:
-
Hi itrader46,
Please turn on TraceOrders in your strategy, then run it so that the calculation should run. If the cancelation code is being hit but ignored for some reason, it will show up in the trace orders. Also, use Print statements to see if 1. the cancelation code is actually being reached and 2. The condition is true when expected.
Leave a comment:
-
The strategy works, but it doesn't cancel the pending Limit orders when the triggering condition becomes false. Any ideas?
Leave a comment:
-
Hi itrader46, thanks for your reply.
The second implementation looks fine. I'm not sure if this code is running in OnBarUpdate or in OnOrderUpdate, it should be in OnBarUpdate so that it is called on each tick of the market.
Please let me know if I can assist any further with the strategy, best regards.
Leave a comment:
-
Can you please tell me if the two variants below are equivalent? The second one looks tidier and it's shorter. Basically, I am trying to submit three Stop Limit orders on CalculateOnEachTick a few ticks off the last bid / ask, but cancel it if the condition becomes invalid before triggering, while the orders are in Pending state
- FIRST
if (
// Condition group 1
entryShort1 == null && (condition))
{
EnterShortStopLimit(Convert.ToInt32(Target1Cont), (GetCurrentBid(0) + (StopOffsetShort * TickSize)), (GetCurrentBid(0) + (StopOffsetShort * TickSize)) , @"Short1");
}
if (entryShort1.OrderState == OrderState.TriggerPending &&(condition))
{
CancelOrder(entryShort1);
}
if (entryShort2 == null && (condition))
{
EnterShortStopLimit(Convert.ToInt32(Target2Cont), (GetCurrentBid(0) + (StopOffsetShort * TickSize)), (GetCurrentBid(0) + (StopOffsetShort * TickSize)) , @"Short2");
}
if (entryShort2.OrderState == OrderState.TriggerPending &&(condition))
{
CancelOrder(entryShort2);
}
if (entryShort3 == null && (condition))
{
EnterShortStopLimit(Convert.ToInt32(Target3Cont), (GetCurrentBid(0) + (StopOffsetShort * TickSize)), (GetCurrentBid(0) + (StopOffsetShort * TickSize)) , @"Short3");
}
if (entryShort3.OrderState == OrderState.TriggerPending &&(condition)
{
CancelOrder(entryShort3);
}
- SECOND
" if (
// Condition group 2
entryLong1 == null
&& entryLong2 == null
&& entryLong3 == null
&& (condition))
{
EnterLongStopLimit(Convert.ToInt32(Target1Cont), (GetCurrentAsk(0) + (StopOffsetLong * TickSize)), (GetCurrentAsk(0) + (StopOffsetLong * TickSize)) , @"Long1");
EnterLongStopLimit(Convert.ToInt32(Target1Cont), (GetCurrentAsk(0) + (StopOffsetLong * TickSize)), (GetCurrentAsk(0) + (StopOffsetLong * TickSize)) , @"Long2");
EnterLongStopLimit(Convert.ToInt32(Target1Cont), (GetCurrentAsk(0) + (StopOffsetLong * TickSize)), (GetCurrentAsk(0) + (StopOffsetLong * TickSize)) , @"Long3");
}
if (entryLong1.OrderState == OrderState.TriggerPending &&(condition))
{
CancelOrder(entryLong1);
}
if (entryLong2.OrderState == OrderState.TriggerPending &&(condition))
{
CancelOrder(entryLong2);
}
if (entryLong3.OrderState == OrderState.TriggerPending &&(condition)
{
CancelOrder(entryLong3);
}
Leave a comment:
-
Right... so I don't have to enter something like this, which generates a lot of errors (see attachment) Errors.pdf
"protected override void OnOrderUpdate(Order order, (double)(GetCurrentAsk(0) + (StopOffsetLong * TickSize)), (double)(GetCurrentAsk(0) + (StopOffsetLong * TickSize)), Convert.ToInt32(Target1Cont), int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError) "
Leave a comment:
-
Hi itrader46,
If a stop or limit price is not applicable to an order type, then just enter 0 for that parameter.
Leave a comment:
-
Hello
How do I fill in the OnOrderUpdate if I don't have all the parameters? For instance a LongStopMarket order has no Limit
Thank you
Leave a comment:
-
Hi itrader46, thanks for your post.
It seems like this parameter is not evaluating as a double:
(GetCurrentBid(0) + (StopOffsetShort * TickSize))
Try casting it to a double and your entry should compile after that.
e.g.
(double)(GetCurrentBid(0) + (StopOffsetShort * TickSize))
If you have any further questions, please let me know.
Leave a comment:
-
No suitable method found to override...
Hello
I am trying to code a strategy that woks on Calculate.OnEachTick that submits Short/LongStopMarket orders a few ticks below/above the Stop price and I need to cancel the pending orders before they are executed, in case my condition for triggering the order gets invalidated before triggering the order.
I found that I have to 'Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.', but I must have left something out, coz I'm getting the error 'No suitable method found to override'.
I suspect it is because there is nothing in the () after OnOrderUpdate, but I don't quite understand how to fill in these parameters
(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
My code is like this:
private Order Short1 = null;
protected override void OnBarUpdate()
{
if (condition true)
{
EnterShortStopMarket(Convert.ToInt32(Target1Cont), (GetCurrentBid(0) + (StopOffsetShort * TickSize)) , @"Short1");
}
else if (
(condition false)
&& Order(Short1 = OrderState.TriggerPending))
{
CancelOrder(Short1);
}
}
....
protected override void OnOrderUpdate()
{
if (order.Name == Short1)
Short1 = order;
if (Short1 != null
&& Short1 == order)
if (Short1Order.OrderState == OrderState.Cancelled)
{
Short1 = null;
}
}Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by WHICKED, 03-27-2024, 12:33 PM
|
4 responses
43 views
0 likes
|
Last Post Today, 12:28 AM | ||
Started by f.saeidi, Today, 12:12 AM
|
0 responses
3 views
0 likes
|
Last Post
by f.saeidi
Today, 12:12 AM
|
||
Started by Conall, Today, 12:06 AM
|
0 responses
5 views
0 likes
|
Last Post
by Conall
Today, 12:06 AM
|
||
Started by proptradingshop, 03-21-2024, 09:50 AM
|
6 responses
27 views
0 likes
|
Last Post Today, 12:02 AM | ||
Started by mly916, Yesterday, 09:48 PM
|
1 response
14 views
0 likes
|
Last Post Yesterday, 11:54 PM |
Leave a comment: