View Full Version : ProfitTarget
jriverac
05-06-2008, 01:06 PM
Hallo,
I need help with the use of SetProfitTarget for my strategy:
The basics are:
Buy one a unit
buy a second unit on a stop order
Buy a third unit on a stop order
Then, when I have three units, set a ProfitTarget.
This goes both for long and short. I am really having trouble.
Shall I use SetPrfotTarget under Initilize()??
If not, i have to reset the Target in a few places in the code and something is not working (see the pic attached)
Any help welcome!!
NinjaTrader_Ray
05-06-2008, 01:24 PM
Yes, you can use SetProfitTarget() in Initialize()
jriverac
05-06-2008, 01:43 PM
Any ideas what does it happens with the picture? Why does it close only two contracts and leave a third open?
jriverac
05-06-2008, 01:45 PM
Also,
If I set the ProfitTarget in the Initialize() method, how do I do it?
Letīs say I want a 5% profit over the price of the FIRST contract I buy, regardless of the price i get for the 2nd and 3rd.
How do I state that?
NinjaTrader_Ray
05-06-2008, 02:03 PM
Post #3 - No idea, you would have to debug and simplify your strategy to get an idea what may be happening
Post #4 - SetProfitTarget(CalculationMode.Percent, 0.05);
See here for more information - http://www.ninjatrader-support.com/HelpGuideV6/SetProfitTarget.html
I believe 0.05 is 5%...you will have to verify.
jriverac
05-06-2008, 02:29 PM
POst #4:
But that does not seem to work well when adding more contracts...
It should use the entry price of the first contract but it does not seem so... actually there are no exits named ProfitTarget..
jriverac
05-06-2008, 02:33 PM
Oh, now I see it!
Sorry! It does work, BUT...
I add up to three contracts and I want all 3 to exit on the same price (5% over the FIRST contract entry price). I mean:
First at 600. Target: 5% (30 points). Exit price 630
Second at 610: Exit price still at 630
Third at 620. Exit price at 630.
How I do that?
Thanks for the help!!
NinjaTrader_Ray
05-06-2008, 04:08 PM
Do not provide any signal names for your entries. That should work.
NinjaTrader_Ray
05-06-2008, 04:10 PM
If that does not work or you or already doing this, then there is no easy option apart from coding something more elaborate where you capture the first execution price via OnExecution() and then calculate the target and submit targets via ExitLongLimit() for example in the OnExecution() method. We will be posting a reference sample on this shortly.