I have a script that executes trades, however after the first order it stops executing trades... what am I missing?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Trading stops
Collapse
X
-
Trading stops
I am brand new at automated trading with Scripts.
I have a script that executes trades, however after the first order it stops executing trades... what am I missing?Tags: None
-
Here's my code...
Code:if (Input[0] > MACDBB(12, 26, 9).Avg[0] && Above == false) { Retrace = false; Above = true; Below = false; Print("Cross Above"); } // Condition set 2 if (Input[0] < MACDBB(12, 26, 9).Avg[0] && Below == false) { Retrace = false; Above = false; Below = true; Print("Cross Below"); } if (FirstTickOfBar && Above == true && LongOrder == false) { PriorBarRetrace = Round2Tick(((High[1]-Low[1])*.382)+ Low[1])-TickSize; Print("Retrace target = " + PriorBarRetrace); } if (FirstTickOfBar && Below == true && ShortOrder == false) { PriorBarRetrace = Round2Tick(((High[1]-Low[1])*.618)+ Low[1])+TickSize; Print("Retrace target = " + PriorBarRetrace); } if (Input[0] <= PriorBarRetrace && Above == true && LongOrder == false) { Retrace = true; LongOrder = true; ShortOrder = false; ExitShort("MACDfollowShort"); EnterLong("MACDfollowLong"); Print("ExitShort, EnterLong"); } if (Input[0] >= PriorBarRetrace && Below == true && ShortOrder == false) { Retrace = true; ExitLong("MACDfollowLong"); LongOrder = false; ShortOrder = true; EnterShort("MACDfollowShort"); Print("ExitLong, EnterShort"); }
Comment
-
Hello,
The first thing I see is that this looks like an "always in" strategy, meaing you have an order in the market at all times. When doing this, don't use Exits, just place an order in the opposite direction and it will cancel the order you just had. See the SamleMACrossOver. That should eliminate some of your flags and simplify the code. Try than and see if you can sort out the issue.DenNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by mishhh, 05-25-2010, 08:54 AM
|
19 responses
6,189 views
0 likes
|
Last Post
by rene69851
Today, 09:29 AM
|
||
Started by gwenael, Today, 09:29 AM
|
0 responses
3 views
0 likes
|
Last Post
by gwenael
Today, 09:29 AM
|
||
Started by Karado58, 11-26-2012, 02:57 PM
|
8 responses
14,829 views
0 likes
|
Last Post Today, 09:09 AM | ||
Started by Option Whisperer, Today, 09:05 AM
|
0 responses
2 views
0 likes
|
Last Post Today, 09:05 AM | ||
Started by cre8able, Yesterday, 01:16 PM
|
3 responses
11 views
0 likes
|
Last Post
by cre8able
Today, 08:28 AM
|
Comment