![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Member
Join Date: Jan 2008
Posts: 96
Thanks: 0
Thanked 0 times in 0 posts
|
Hi I have a strategy that I am testing that is always in the market. Now I have added some stop loss and profit targets conditions and I have realized that the number of trades changes based on them. How can this be possible? Assume that if it’s flat the enter condition is the same that if it is on market and it is changing the direction. Thanks
Last edited by ssierra; 06-10-2008 at 04:08 PM.
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Your strategy does what you tell it to do...You will have to debug to understand how the changes you have made impact your strategy.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jan 2008
Posts: 96
Thanks: 0
Thanked 0 times in 0 posts
|
Ok but I don’t see any problem. As example I took your SampleMACrossOver strategy and added a stop and a target. As it is it works fine, whatever the stop and targets are the number of trades is the same. But if I want to have a crossover with a the MA delayed is where I get problems.
The code is as follows: { if (CrossAbove(SMA(Fast), SMA(Fast)[2], 1)) EnterLong(); elseif (CrossBelow(SMA(Fast), SMA(Fast)[2], 1)) EnterShort(); } And the original is: { if (CrossAbove(SMA(Fast), SMA(Slow), 1)) EnterLong(); elseif (CrossBelow(SMA(Fast), SMA(Slow), 1)) EnterShort(); } What is wrong for changing the number of trades? Edited with message 4.
Last edited by ssierra; 06-11-2008 at 01:38 AM.
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
The code you modified it to will definitely produce different results. The original code makes little sense in logical terms because you are asking for when the SMA(Fast) crosses over itself. In your modified code you are asking when the SMA(Fast) crosses the SMA(Fast) of 2 bars ago. This makes more sense and it will behave accordingly.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Jan 2008
Posts: 96
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Johs,
sorry the original code is this one: { if (CrossAbove(SMA(Fast), SMA(Slow), 1)) EnterLong(); elseif (CrossBelow(SMA(Fast), SMA(Slow), 1)) EnterShort(); That is as it is in the example and gives the same number of trades whatever the stop is. What is giving me problemes is the one that crossover a delayed media and based on your comment it is fine. Thanks, |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
How are you determining what you are seeing is abnormal? You cannot compare the two situations since they are not equivalent. They will definitely produce different trades.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Member
Join Date: Jan 2008
Posts: 96
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
Using the original code if I optimize the stops and targets whatever the parameters are the numbers of trades are always the same, as expected. The problem is that with the new code optimizing the stops and targets gives different number of trades that doesn’t make sense. I am not comparing the number of trades with the original code I am comparing the number of trades of the same strategy using different stops and targets. Many thanks for the help |
|
|
|
|
|
|
#8 |
|
Junior Member
|
I wonder if something's wrong wiht this commands or if have another commands that I can close all open orders ...
if (CrossBelow(Momentum(momentumPeriod), 0, 1)) ExitShortStop(Position.MarketPosition, "", ""); the goal is when the period line crossesover the 0 line close all orders... Thank you. |
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
Welcome to our forums here marcos_vitorino, your command would issue a Stop Market order, if you just want to exit the quickest way possible on your condition just call ExitShort() for a straight market order.
http://www.ninjatrader.com/support/h.../exitshort.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Strategy: Monitoring Stop-Loss and Profit Target Orders | NinjaTrader_Josh | Reference Samples | 0 | 02-23-2008 11:15 PM |
| Profit Target and Stop Loss not honored | pjwinner | Strategy Analyzer | 6 | 11-30-2007 09:45 AM |
| Stop Loss - profit target settings | deanldavis475 | Miscellaneous Support | 1 | 11-26-2007 07:31 AM |
| Default stop loss and profit target as GTC | equitydealer | General Programming | 4 | 06-18-2007 11:31 PM |
| Stop Loss Orders activated by number of trades past stop level | DoveforUsAll | Suggestions And Feedback | 1 | 02-08-2006 01:19 AM |