11/27/2012 6:00:00 AM Entered internal PlaceOrder() method at 11/27/2012 6:00:00 AM: BarsInProgress=1 Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1.2968 SignalName='' FromEntrySignal=''
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Help building strategy
Collapse
X
-
I actually double checked and the TraceOrder was already set to true. This is the Output message I get:Originally posted by koganam View Post
check the chart attached, according to me there is something wrong in my code, on this trade the stategy would clearly have done money, whilst NT is telling me I am stopped out11/27/2012 6:00:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=0 Currency=1.301 Simulated=False
11/27/2012 6:00:00 AM Entered internal PlaceOrder() method at 11/27/2012 6:00:00 AM: BarsInProgress=1 Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1.2968 SignalName='' FromEntrySignal=''
-
Check your code. That looks like your StopLoss was placed at Close[0] when the trade was entered.Originally posted by sburtt View PostI actually double checked and the TraceOrder was already set to true. This is the Output message I get:
check the chart attached, according to me there is something wrong in my code, on this trade the stategy would clearly have done money, whilst NT is telling me I am stopped out
If that is not the case, you may have a corrupt Database. Repair the Database, and restart NT, then try again. I presume that you are seeing this in Backtest? At least, that is what the picture suggests.Last edited by koganam; 02-26-2013, 02:28 PM.
Comment
-
Yes this is a backtrsting result. The code is the one you read below in the previous post, i've simply copied and pasted it. I've tried running it on a virtual machine, hence a separate database and the result is the same. What if i send you the cs file via message and you try running it on your machine? Would it be asking to much?
Comment
-
I can do that for you.Originally posted by sburtt View PostYes this is a backtrsting result. The code is the one you read below in the previous post, i've simply copied and pasted it. I've tried running it on a virtual machine, hence a separate database and the result is the same. What if i send you the cs file via message and you try running it on your machine? Would it be asking to much?
Comment
-
I have got it, and I do not see how your Strategy can run at all. I asked you what the error is in your log. After we resolve those questions, I will see about loading the Strategy onto my test system.Originally posted by sburtt View Postcheck your email inbox, let me know if haven't received it
Comment
-
I am not sure I know what your referring to, however if you are referring to the Log tab on the right side of the Control Center, I don't see any error. see the attached screenshotOriginally posted by koganam View PostI have got it, and I do not see how your Strategy can run at all. I asked you what the error is in your log. After we resolve those questions, I will see about loading the Strategy onto my test system.
Comment
-
Hello sburtt,
Viewing your your Output window and the place that you expected your stop loss to be set at, it appears that you would like to set the Stop Loss at an absolute price. If that is the case then you may try to change your stop loss to: SetStopLoss(CalculationMode.Price, High[0]+TickSize);JCNinjaTrader Customer Service
Comment
-
that made the trick, thanksOriginally posted by NinjaTrader_JC View PostHello sburtt,
Viewing your your Output window and the place that you expected your stop loss to be set at, it appears that you would like to set the Stop Loss at an absolute price. If that is the case then you may try to change your stop loss to: SetStopLoss(CalculationMode.Price, High[0]+TickSize);
Comment
-
Hey Koganam, the CalculationMode was what I was missing in SetStopLoss(CalculationMode.Price, High[0]+TickSize) to make it work properly. Anyhow I sent you the strategy, are you still interested in helping me out on how to code the trailing stop loss?Originally posted by koganam View PostI have got it, and I do not see how your Strategy can run at all. I asked you what the error is in your log. After we resolve those questions, I will see about loading the Strategy onto my test system.
Thanks guys
Comment
-
Hello sburtt,
The SetTrailingStop() would be setup a similar way but you would only be able to use a Calculation mode of Ticks or Percent since it will be automatically moved when the price moves in the direction of your trade.
You may also modify your SetStopLoss() when your specific conditions are met as well. For an example of this you may view the following thread.
JCNinjaTrader Customer Service
Comment
-
JC I'm trying to trail a stop that hasn't a fix % value (or tick value) for all trades, but rather changes each time based on the risk I am willing to take. Let's assume I define the risk (R) per each trade in the following way: R = High[0]-Low[0]. We could also define R in %terms in this way R = High[0] / Low[0] -1Originally posted by NinjaTrader_JC View PostHello sburtt,
The SetTrailingStop() would be setup a similar way but you would only be able to use a Calculation mode of Ticks or Percent since it will be automatically moved when the price moves in the direction of your trade.
You may also modify your SetStopLoss() when your specific conditions are met as well. For an example of this you may view the following thread.
http://www.ninjatrader.com/support/f...ead.php?t=3222
Given what you mention above how could I create a trailing stop that starts only after the close of 3rd candle based on R?
would something like this work:
Code:protected override void OnBarUpdate() { if (Position.MarketPosition == MarketPosition.Flat) { if (*condition*) { SetStopLoss(CalculationMode.Price,High[0]); EnterLong(); } } double R = (High[0] / Low[0] - 1); else if(Position.MarketPosition == MarketPosition.Long && BarsSinceEntry() >= 3 && Position.GetProfitLoss(Close[0], PerformanceUnit.Percent) > R) { SetTrailStop(CalculationMode.Percent, Position.AvgPrice + R); } }
Comment
-
I noted the CalculationMode matter. Unfortunately, I do not trade currencies, and so I do not have any historical data, nor could I manage to acquire any. I finally decided to test your strategy using data for IBM.Originally posted by sburtt View PostHey Koganam, the CalculationMode was what I was missing in SetStopLoss(CalculationMode.Price, High[0]+TickSize) to make it work properly. Anyhow I sent you the strategy, are you still interested in helping me out on how to code the trailing stop loss?
Thanks guys
Well, if you have managed to resolve the matter of handling the Stop, then I guess that does it for now.
Comment
-
What you are describing sounds more like you are manually trailing a Stop. In which case your construct should be:Originally posted by sburtt View PostJC I'm trying to trail a stop that hasn't a fix % value (or tick value) for all trades, but rather changes each time based on the risk I am willing to take. Let's assume I define the risk (R) per each trade in the following way: R = High[0]-Low[0]. We could also define R in %terms in this way R = High[0] / Low[0] -1
Given what you mention above how could I create a trailing stop that starts only after the close of 3rd candle based on R?
would something like this work:
Code:protected override void OnBarUpdate() { if (Position.MarketPosition == MarketPosition.Flat) { if (*condition*) { SetStopLoss(CalculationMode.Price,High[0]); EnterLong(); } } double R = (High[0] / Low[0] - 1); else if(Position.MarketPosition == MarketPosition.Long && BarsSinceEntry() >= 3 && Position.GetProfitLoss(Close[0], PerformanceUnit.Percent) > R) { SetTrailStop(CalculationMode.Percent, Position.AvgPrice + R); } }
i.e., you need to be moving your hard Stop, not resetting a TrailingStop. If you still prefer the double whammy of a manually trailed, trailing stop, you would still need to use only "R" as your percent value.Code:SetStopLoss(CalculationMode.Percent, R);
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
574 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment