[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 cmoran13, Yesterday, 01:02 PM
|
0 responses
30 views
0 likes
|
Last Post
by cmoran13
Yesterday, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
22 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|
||
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
160 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
95 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
148 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|

Comment