Redeclaring a dataseries to use as a trailing stop
I am trying to create a trailing stop logic (I don't want to use the trailstop method as I don't want my trailing stop to be entered when I initially enter the market, I only want it to kick in when a certain condition becomes true).
But I am finding that once I declare a dataseries, Ninjatrader 7 seems to not allow me to redeclare the dataseries value:.
For example, here is the code I'm looking at:
The output for this does not behave as expected xTest is revalued both higher and lower, always according to the original declared value (current close minus 5 ticks):
My first guess as to why it isn't performing as you expect is because of the way NT handles MTF.
I suggest making a new strategy, just make it single time frame only, and test your code there. Then you'll see the differences.
Another way is to put a debug Print() statement right above each of the .Set() for DataSeries so you can see when it is being called and why. Be sure the print includes which BarsInProgress you are currently looping through and the CurrentBar.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
here's an idea:
- initialize a secondary bar series as 1-tick
- when you enter your stop, make sure you have a pointer to it
- then you can check Close inside (BarsInProgress == 1) to see if it has moved up 1-tick in your direction; if so, then adjust your stop accordingly
note: you'll need to code up a stop-threshold and stop-value to use inside that second if() statement ... and you can get as complex as you like -- initial fixed stop that converts to a trailing stop after x ticks in profit, etc.