Someday I may actually use this code you just posted!As someone who codes in NinjaTrader, their NinjaScript is just c#. It may seem intimidating for nonprogrammers, but it is actually quite easy once you take a little time to familiarize yourself with templates. It also helps that NinjaTrader has a very active support forum, that can actually help solve your programming problems as long as you ask very specific questions.
For example for identifying the current account and existing orders:
NinjaTrader.Gui.Tools.AccountSelector chartTraderAccountSelector = Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector;
account = chartTraderAccountSelector.SelectedAccount;
if (account.Orders.Name.StartsWith("Stop1") && (account.Orders.OrderState == OrderState.Accepted || account.Orders.OrderState == OrderState.Working))
//move stop lossesYou wouldn't need to know how to write the this from scratch. And once you have this, then you can easily move the stop loss based on your own logic. For example, trail the stop loss by 1 tick above / below the previous bar, and skip the trial on inside bars:
//Get order for profit target and move it based on logic here
if (CurrentBar > 2){
if (Low[1] >= Low[2])
{
Values[1][0] = High[2] + .25;
}
else
{
Values[1][0] = High[1] + .25;
}
if (High[1] <= High[2])
{
Values[0][0] = Low[2] - .25;
}
else
{
Values[0][0] = Low[1] - .25;
}
}
Bloodhound is nice because it makes it more approachable. But personally I prefer the complete customization approach of doing it myself in NinjaTrader. After all, since NinjaTrader uses c#, you have the complete power of .Net framework available to you to make your code as simple or complicated as you need.
I kind of get your point, that I could piece together copies of other codes to make a code. Still seems a little intimidating, but I'm gonna give it a try!
Thanks for sharing!
Last edited: