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)
I'm new on this forum and this is my first message so hello everyone!
I am a newbie of the C# and the NinjaTrader scripting; I am from Italy so sorry for my poor english. Hope the theme that follows were not already studied and if it will be redundant, sorry again.
Coming to us: I am trying to set a stop loss on an open position when a determinated unrealized profit is reached.
Example: my enter price is 10000 and it grows to 10050; at this point my script set a new stop loss to 10040. Actually I am able to do that using this code:
// Dinamic stop loss: Set a new stop loss when a determinated unrealized profit is reached
It works well but I would need to set a new stop loss based not more on a prefixed ticks value but on a percent value of the enter price (the Position.AvgPrice).
Example: my enter price is 10000 and it grows of the 1% to 10100; at this point my script should set a new stop loss of the 0.8% to 10080.
I spent a lot of time and energies trying all possible solution without any result... it seems like any double value doesnt' work.
Where am I wrong?! Can anyone help me please?
Can you help answer these questions from other members on NexusFi?
Unfortunately that code doesnt' seem to work; I suppose that the matter is about the variable type so when the output is a double it doesnt' work; I am actually working on convert a double variable in a int variable... I hope I am not still wasting my time on the wrong assuption!
Unfortunately that code doesnt' seem to work; I suppose that the matter is about the variable type so when the output is a double it doesnt' work; I am actually working on convert a double variable in a int variable... I hope I am not still wasting my time on the wrong assuption!
Just another thought - maybe you need to use the Round2TickSize function as well?
When you say the code doesn't work do you mean it doesn't compile (compilation errors) or simply doesn't return proper value. If you have compilation errors post them here so it will be easier for someone to assist you.