[FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (cvalue>avg+increment[/SIZE][/FONT][FONT=Courier New][SIZE=2])
{
Print([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Short"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (mp1 > -[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])
{
Entry=EnterShortLimit([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Contracts,Close[/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Entry"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);
}
}
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (cvalue<avg-increment[/SIZE][/FONT][FONT=Courier New][SIZE=2])
{
Print([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Long"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (mp1<[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])
{
Entry=EnterLongLimit([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Contracts,Close[/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Entry"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);
}
}
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]else
[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]{
Print([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Cancel"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (Entry!= [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])
CancelOrder(Entry);
}
[/SIZE][/FONT]
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy Stops Trading
Collapse
X
-
Strategy Stops Trading
I am using the following code to execute orders. The strategy enters a position, then stops trading.
Code:Tags: None
-
I need to cancel the order as soon as the conditions are not met. This works properly up until the time when I enter a position. After that, no more orders are sent.
Comment
-
-
This is the message it gives me when trying to reverse.
8/21/2008 11:22:22 AM Entered internal PlaceOrder() method at 8/21/2008 11:22:22 AM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1.8757 StopPrice=0 SignalName='Entry'FromEntrySignal=''
8/21/2008 11:22:22 AM Ignored PlaceOrder() method at 8/21/2008 11:22:22 AM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=1.8757 StopPrice=0 SignalName='Entry'FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
Comment
-
-
I still get the same message ignoring the order. Below is the new code.
Code:[COLOR=#0000ff]if[/COLOR][FONT=Courier New][SIZE=2] (cvalue>avg+increment[/SIZE][/FONT][FONT=Courier New][SIZE=2]) { Print([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Short"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (mp1 > -[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) { ShortEntry=EnterShortLimit([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Contracts,Close[/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"SEntry"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); } } [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (cvalue<avg-increment[/SIZE][/FONT][FONT=Courier New][SIZE=2]) { Print([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Long"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (mp1<[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) { LongEntry=EnterLongLimit([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Contracts,Close[/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"LEntry"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); } } [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]else [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]{ Print([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Cancel"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (LongEntry!= [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) CancelOrder(LongEntry);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][FONT=Courier New][SIZE=2] (ShortEntry!= [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) CancelOrder(ShortEntry);[/SIZE][/FONT] } [/SIZE][/FONT]
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
559 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
546 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment