Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Need help to make a strategy to create fibs, and place order if fib are hit NT8 (New)
Hello !
I'm trying to create a semi-automated strategy (not an atm strategy), but a strategy that will not make any decisions, but that can draw a fib extension, adjust the fib if the point where the fib has been drawn is broken, and, if a certain fib level is hit, start to create an atm order, to start to trail a trade opened with an atm strategy, and then adjust on the value of an simple indicator that i made, that has only one value, to trail a trade.
(by the way, i made this thread 3 days ago, but i just saw that there was a subdivision for ninjascript programming, so i'm re-making the thread )
This is the basic explanations of what i would like, so let me explain why :
I'm a long-term day-trader, and there is a lot of peoples that do the same thing as me, but long term, this mean that i can be in a trade for 6-8 hours. But after the entry is made, i actually don't take any decisions, and i'm only waiting for a fib level to get hit, and to create a stop market order, to trail a trade, then i attach this order to the value of an indicator.
But, i think we can all agree, having to spend 6-8 hours in front of a screen, to press 2 buttons, is really annoying, and also, you can't have your mind clear, if for example you walk away from the screen.
A strategy like the idea i have in mind, could help a lot of traders to make their life easier, and to reduce time lost in front of a screen to press a button, and reduce stress.
I have tried to build this, and i have been helped with the ninjatrader support team (i'm trying to build this on NT8), they are doing a great job, but really quickly, in more complex questions they only point me to documentation, that is not documented enough to do the job ! And i don't think third part developer is the way to go, because of the way of doing of many, to do the job quickly, to do a lot of it, but facturing a lot time, and we can also ended up with a code that we don't understand, and can't modify. So that's why i'm here !
Whit the ninjatrader support team, i didn't succeed building what i wanted, but i learn what is possible to do with NT8, and so i have created a detailled plan on how we could create this. So, if you want to help or contribute to create this strategy, to make gain a lot of time to a lot of peoples, it would really be appreciated !
So : the idea of the strategy, or script, is to keep the freedom of opening a trade with the dom, and a atm strategy, and having a atm strategy stop loss that don't move (created by the atm strategy, not by the automated strategy). And i have a target, based on one particular fib extension level, but this level is dynamic, and can change if the point where i placed it is broken, and my stop not hit, to avoid to have, for exemple an input with the target price in the strategy, but then, we have to stay in front of the charts to adjust the extension if needed, and so we are back to square one.
- With this in mind, the first thing that the strategy need to do, is to be enable to draw, or adjust a fib extension. But before this, here's the basics stuff that could be great for the strategy to have :
- the strategy can start working, only if we are short or long, in the instrument where she is applied, and on the account that we set before. To avoid, like to forgot to disable the strategy, and then she's going to take order to open a position, instead of taking order to leave a position.
- The strategy will detect if we are long or short, and then start to use the short, or long version of the strategy.
- if the strategy has an error, she will cancel all positions on the instruments, and delete all orders.
- the strategy will use the amounts of contracts that are in the actual trade, to set the amount of contracts she need to put in her order.
- the strategy cancel everything and every order 3060 seconds before the close of the instrument
- About the extension, the strategy should be enabled to draw or adjust a fib extension (we can either, choose the 3 points on the chart where she should draw the extension, or we can put the value of the 3 points in a input before we launch the strategy). Then, when the strategy has the 3 points, and has drawn the extension, she's going to take the value of the 85,4% fib level (with an offset of -5ticks if the account is long, and +5ticks if the account is short), so if the strategy see that the price has reach at any time (not close above the target price), the target price (and she take the offset, so 5 ticks below or above), she's going to start the trail stop that i'm going to explain after. But so, she use the 85,4% fib level with an offset (if the offset could be modified it would be great !) to set the target.
The first 2 point of the fib extension (in case of a long trade, the first low and high), will never move, so we don't worry about them (ps : the atm stop loss is placed manually by the atm strategy below the first point, but the strategy don't care about the stop loss created by the atm strategy. But so, if the first point where the extension is drawn is broken, we are going to get stop out anyway, and if the strategy see that the account became flat on the instrument, she will stop).
But the tricky thing, is that the third point can change. Let's say we have taken the input to had manually to set the points of the extension, and that i have taken the trade a long trade a little after the third point (the low), this low can be broken, without triggering the stop loss, but in this case, the fib extension, is not placed at the good low.
So my idea, is that the strategy take the third point value put by the user, and considerate this point as a low (or a high if the strategy see that the account is short), and if the strategy see that at any time this low is broken, she will considerate, that the new low since the low put by the user, is here new low. And she will delete and draw a new extension (or adjust), based on still the 2 first points, but she will by itself, take the new low has a third point to create the extension.
If this new low is broken again, she will do the same operation, and if we keep breaking low, until my stop loss is hit, the strategy will see that the account is flat, and will shutdown.
And, she will always take the new 85,4% fib level with the offset, as her target level. (i'm going to explain what is the target level)
- Now that we have our dynamic fib extension, we have one more thing to do, is that the strategy use the target level as a point to start to trail the trade. Since the strategy, just need to know, what is the side of the trade (long or short), to work, she don't care about the stop loss made by the atm strategy, or the entry price. All that the strategy will do, is constantly check, and wait, if the price has reach the price of the target with the offset. Then if the price do hit the target price, the strategy will create an atm order (so the user can see the order and adjust it if needed, but its managed by the strategy), an sell stop market order (or a buy if i'm short), then she will attach it to the value of an indicator that will just create a plot if the candle is green (close above open), (there is 2 versions that i build, the long version, that will be used if i'm a in a long trade, and the short version, used if i'm short, the long create dot on up candle, and short on down candle), (i posted the indicators in this post), (by the way, if the strategy need to create the order before it can be ajustes, it could be a idea to put a sell market stop on a -1 value, and a buy on a 9999999999 value, to be sure its not hit. Then, when the order is created, she adjust the order on the value of the good indicator depending on the direction of the open trade, she adjust with an offset of -1 if i'm long, and +1 if i'm short (so the order is one tick below the candle if long, and one above if short). And then, on a bar close base, she will see if the value of the indicator is different, and she will try to move the order to the new value of the indicator if its different.
Then, when the order is triggered and filled, obviously, the account become flat, and since the atm strategy is canceled when the account become flat, the stop loss will be deleted. Then the last goal of the strategy, is to check if there is any order, or position left on the instrument, if there is, she will canceled or close all this, then she will shutdown, and send a message to NT8 like : TrailStop finished, and all positions closed.
That's the plan, i try to make it as detailed as possible, so it would be easier for somebody who want to try to programme, or help programming this thing to understand the plan.
It would really help a lot of people if we can succeed on building this, you can totally contact me on pm about this, or the best, is to speak trough this tread, so a maximum of peoples can get value out of this.
Have a great day !
PS : the two indicators that i posted, are for nt8
Can you help answer these questions from other members on NexusFi?
Yes !
Thanks for pointing it, i fully know that i have made two time the same thread, but i think the ninjatrader programming section it better for this thread.
I have posted has soon has i upload this thread, in a old thread a link to this one, and if a moderator was passing by that the old thread could be removed.
And, to have no confusion, on the start of this thread, i said that i posted it 2 time, and the name of this thread is New !