![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: May 2009
Location: Cologne
Posts: 83
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
I'm asking myself if using the SetStopLoss(..) method is working, when using multi timeframes during backtesting my strategies. First of all I had only a M10 and using CalculateOnBarClose = True. Then after placing an order a stoploss was set and during backtesting tested after every M10-Bar, thats ok ... Now, I want to test the stop after every minute, so I add a M1 timeframe to the strategy. I'm entering the trade in M10 and then the stoploss is set. After that ten M1-bars running with the close-price through the strategy. Does NT test the stoploss for every M1-bar or only for the higher M10 timeframe? Thx, DT |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
Where is your SetStoploss located in your code? It will work for the timeframe you have submitted it. If you did not specify, then it will be on the 0 bar in progress. This link may help: http://www.ninjatrader-support.com/H...BarSeries.html
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: May 2009
Location: Cologne
Posts: 83
Thanks: 0
Thanked 0 times in 0 posts
|
It is located in the Initialize-Method. So, if I understand you right, I need to move it to the
Code:
if (BarsInProgress == 1) {
...
SetStopLoss (this.Name, CalculationMode.Ticks, stopLossTicks, false);
...
}
The stoploss in initialize (actual code) is only checked in M8 on every close of the primary bar? DT
Last edited by DarthTraderson; 11-02-2009 at 12:01 AM.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
Correct DT, you would need to move the code to the relevant sections in the OnBarUpdate, or work with the Exit() methods that offer a BIP paramter directly - http://www.ninjatrader-support.com/H...tLongStop.html
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: May 2009
Location: Cologne
Posts: 83
Thanks: 0
Thanked 0 times in 0 posts
|
Ok, thanks for the response ... I have to test it ...
In my yesterday evaluations I had a M8 as primary and M1 as secondary timeframe. I still set SetStopLoss(..) in the initialize-method() and the trades where entered and exit in secondary timeframe. Entered with EnterLongLimit(1, ....) and exit worked, I thought, wit setStopLoss ... because I see the trade enter and exit time in the trade overview panel .... very strange ... that doesn't fit with you explanations .... DT |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
DT, are you linking entries and exits together with signal naming?
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: May 2009
Location: Cologne
Posts: 83
Thanks: 0
Thanked 0 times in 0 posts
|
Yes I do.
In Initialize-Method ... Code:
SetStopLoss("MyEntry", CalcutationMode.Ticks, stopLossTicks, false);
Code:
EntryLongLimit (1, false, quantity, Lows[0][0], "MyEntry"); DT
Last edited by DarthTraderson; 11-02-2009 at 06:12 AM.
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
Yes, this would 'link' them together, so you stop loss is submitted as soon as the BIP 1 entry fills.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Member
Join Date: May 2009
Location: Cologne
Posts: 83
Thanks: 0
Thanked 0 times in 0 posts
|
Sorry, Betrand ... what is the meaning of BIP ...
So, to sum it up ... my code works as expected and I did not need to move the SetStopLoss() - statement? DT |
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
I'm sorry DT, BIP = Bars In Progess, you should be good with this code for intrabar backtesting as you already submit entries and by entry signal naming linked exits on a finer granularity than you primary chart.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Member
Join Date: May 2010
Posts: 40
Thanks: 8
Thanked 3 times in 2 posts
|
Can anyone confirm if this can be done or not???
Because of the NT backtest deficiency, we have to go the extra miles to add 1min timeframe for order execution. Now you're telling me, oh by the way, set stoploss does not work and I will have to write my own stoploss code? And this is claimed to be the best auto-trading platform?? I asked this to support: >>> If I have two timeframes, say 10m is primary and 2min is added. If I do EntryLongLimit (1, false, quantity, Lows[0][0], "MyEntry"); in BIP ==0, can do SetStopLoss(price) at the 2min (BIP is 1) to make it effective? During backtest, the stop will be eval every 2min's cycle, or every 10min bar? Also, how can I tell if the order is stop-out? Thanks. >>> i got answer like >>> Hello, Thanks for writing in. The SetStopLoss function will only set the stop for the primary data series. For other data series you will want to place a ExitLong/ExitShort order at the proper prices. Below is a link to the help guide on the usage of SetStopLoss. http://www.ninjatrader.com/support/h...etstoploss.htm >>> |
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
balancenv, your understanding is unfortunately correct - the Set's would be evaluated on the primary series only. As they also do not expose IOrder access, checking for their states would need to be done via the approach offered in this sample - http://www.ninjatrader.com/support/f...ead.php?t=5790
We're are also looking into enhancing this area and backtest handling for our next major platform update.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to strategy test against multi timeframes ? | wcredle | Strategy Analyzer | 1 | 03-13-2009 03:37 PM |
| get bars of other timeframes | junkone | Strategy Development | 1 | 01-20-2009 10:24 AM |
| dual timeframes | starrynight | Automated Trading | 5 | 12-15-2008 05:18 AM |
| Two timeframes | jriverac | Strategy Development | 5 | 05-26-2008 07:23 PM |
| Two timeframes | jriverac | Strategy Development | 6 | 04-08-2008 03:02 PM |