I am having a problem setting a trailing stop in a strategy could you take a look at the attached code and give any pointers as to where the problem lies.What i am trying to achieve is as follows; upon entry an initial stop is placed 1 tick below the last bar this part seems ok.When price has moved 5 ticks past the entry point i want to move the stop to breakeven + 4 ticks.If the trade is still alive at the close of this bar and the following one the stop loss is then moved 1 tick below the low of this bar and each successive bar after.Sorry if my explanation is not clear i have attached a screenshot with notations that should help.Also attached is the code any help you can give would be much appreciated Thanks
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
TrailStop
Collapse
X
-
TrailStop
Hi
I am having a problem setting a trailing stop in a strategy could you take a look at the attached code and give any pointers as to where the problem lies.What i am trying to achieve is as follows; upon entry an initial stop is placed 1 tick below the last bar this part seems ok.When price has moved 5 ticks past the entry point i want to move the stop to breakeven + 4 ticks.If the trade is still alive at the close of this bar and the following one the stop loss is then moved 1 tick below the low of this bar and each successive bar after.Sorry if my explanation is not clear i have attached a screenshot with notations that should help.Also attached is the code any help you can give would be much appreciated ThanksTags: None
-
ohjob, unfortunately we could not debug this code for you, but generally your visual approach is good as it simplifies the debug work needed. I would ensure to print every bars info along with the current stop price and also incluce prints from which code section the stop price modification was triggered from - you can then review what event sequence leads to the unexpected stop price defined.BertrandNinjaTrader Customer Service
-
Trail stop
Hi Bertrand, Thank you for your quick reply, is it possible to directly send you the complete strategy with indicators. I have added print statements in the relevant positions throughout the strategy, but i am still not clear as to why the strategy is not working. I am reasonably new to C# NT and trading, but i have worked as a programmer for some years.
Regards
ohjob
Comment
-
ohjob, if you'd like me to give the strategy a run here please contact me directly at support at ninjatrader dot com to my Attn.
I'm not sure if you're already familiar with it, but TraceOrders is a very helpful tool available to you as well to better understand your strategy's behavior seen :
BertrandNinjaTrader Customer Service
Comment
-
Originally posted by ohjob View PostHi
I am having a problem setting a trailing stop in a strategy could you take a look at the attached code and give any pointers as to where the problem lies.What i am trying to achieve is as follows; upon entry an initial stop is placed 1 tick below the last bar this part seems ok.When price has moved 5 ticks past the entry point i want to move the stop to breakeven + 4 ticks.If the trade is still alive at the close of this bar and the following one the stop loss is then moved 1 tick below the low of this bar and each successive bar after.Sorry if my explanation is not clear i have attached a screenshot with notations that should help.Also attached is the code any help you can give would be much appreciated Thanks
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by dniezby, Today, 04:50 PM
|
0 responses
4 views
0 likes
|
Last Post
by dniezby
Today, 04:50 PM
|
||
Started by dbennett3, Today, 04:21 PM
|
0 responses
2 views
0 likes
|
Last Post
by dbennett3
Today, 04:21 PM
|
||
Started by GKonheiser, 09-23-2014, 08:25 AM
|
2 responses
1,500 views
0 likes
|
Last Post
by PaulMohn
Today, 04:12 PM
|
||
Started by MiCe1999, Yesterday, 10:41 AM
|
8 responses
21 views
0 likes
|
Last Post
by MiCe1999
Today, 03:45 PM
|
||
Started by EB Worx, 03-07-2023, 05:05 AM
|
6 responses
114 views
1 like
|
Last Post
by cls71
Today, 03:43 PM
|
Comment