Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Need some Help with my Strategy
Collapse
X
-
Need some Help with my Strategy
I am trying to sequentially and automatically move my StopLoss to breakeven when my profit reaches 2X dollars( this is for each position), from then on, I want to increase it X dollars every time my profit goes up X dollars. I don't want a TrailingStop. Do you have a sample code that may help me do precisely this? -
Hello Yandychang,
Thank you for your post.
We do have a sample similar to this idea but not exact. You can view this sample at the following link: http://www.ninjatrader.com/support/f...ead.php?t=3222
Please let me know if I may be of further assistance.
-
Hello Patrick
I tried the following variation: I has no syntax error but although it makes sense on my mind, it does not do what I expect it to do:
#region *********** Money Management***********************
n = Math.Truncate( Math.Abs((Close[0]-Position.AvgPrice))/lossStop);
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss(CalculationMode.Price,Position.AvgPric e-lossStop);
}
if (Position.MarketPosition == MarketPosition.Long)
{ if (n>=1)
{
// Once the price is greater than entry price+n*lossStop , Increase StopLoss to Position.Avg+(n-1)lossStop;
if (Close[0] > Position.AvgPrice + n*lossStop)
{
SetStopLoss(CalculationMode.Price,Position.AvgPric e+(n-1)*lossStop);
}
} else
SetStopLoss(CalculationMode.Price,Position.AvgPric e-lossStop);
}
#endregion
one thing I have a hard time wrapping my head around is when I use SetStopLoss(x) I understood x meant the amount currency the price must drop before if sells. The example you directed me, seems to actually tell NT the price to sell it for(SetStopLoss(PositionAvg+x)) which one is right?
Comment
-
Hello Yandychang,
Thank you for your response.
When using the CalculationMode you can use a double value for the level of the Stop. Otherwise by default it uses currency within the parentheses. Please visit the following link for more information on the syntaxes that can be used: http://www.ninjatrader.com/support/h...etstoploss.htm
What are you attempting that is not occurring? Do you have a full or test script that I may test?
Comment
-
Hello Patrick
Now I know what i was doing wrong, I needed to convert my stoploss in currency to amount of ticks... Using Pointvalue and ticksize, I did this and seemed to have worked.
I do have another question, i have various different signal names. If i set up conditional stoplosses with those signal names, would the system use the signals corresponding money management when the signal is triggered?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Mestor, 03-10-2023, 01:50 AM
|
12 responses
307 views
0 likes
|
Last Post
by z.franck
Today, 04:29 AM
|
||
Started by AgriTrdr, 07-16-2023, 12:54 PM
|
32 responses
267 views
0 likes
|
Last Post
by f.saeidi
Yesterday, 06:49 AM
|
||
Started by Mestor, Today, 03:15 AM
|
0 responses
2 views
0 likes
|
Last Post
by Mestor
Today, 03:15 AM
|
||
Started by Padan, Today, 02:02 AM
|
0 responses
6 views
0 likes
|
Last Post
by Padan
Today, 02:02 AM
|
||
Started by bukowa, 11-09-2023, 06:07 PM
|
20 responses
409 views
0 likes
|
Last Post
by Adfra
Today, 01:36 AM
|
Comment