![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Member
Join Date: Nov 2008
Posts: 72
Thanks: 9
Thanked 0 times in 0 posts
|
I am running the following logic that is trying to say:
if the volume of the entrybar +1 > the entrybar then exit. else exit after entrybar +3 seems to compile but doesnt work in practice.... the strategy is calconbarclose = false. Stopoffset is a myinput() value. Any ideas? Regards if (Volume[BarsSinceEntry()+1] > Volume[BarsSinceEntry()+0]) { ExitLong("", ""); ExitShort("", ""); } else if (BarsSinceEntry() > stopOffset) { ExitLong("", ""); ExitShort("", ""); } |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Any errors shown in Control Center logs during runtime?
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Nov 2008
Posts: 72
Thanks: 9
Thanked 0 times in 0 posts
|
no errors on the log..... the point is to enter the trade... then compare after barsincentry =1 has elapsed... and compare it to the volume of the
bar that the position was opened in.... |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Then what aspect of this does not work? What behavior do you see as is?
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Nov 2008
Posts: 72
Thanks: 9
Thanked 0 times in 0 posts
|
tends to enter multiple trades and stop them immediately.... is there a simpler way tp code ět ? or is it not possible to extract the volume of a bar in which a trade opened after time has elapsed.. ?
|
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
It is possible, but you have to do it at the correct time. I.e. after you have entered the trade.
You should add some checks like if (Position.MarketPosition == MarketPosition.Long) or something like that.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| BarsSinceEntry | stephenszpak | Strategy Development | 3 | 06-23-2009 06:32 AM |
| BarsSinceEntry | mballagan | Strategy Development | 5 | 05-06-2009 03:36 PM |
| BarsSinceEntry | heyligerb | Strategy Analyzer | 7 | 02-18-2009 11:43 AM |
| BarsSinceEntry() | Phyre | Strategy Development | 9 | 02-11-2009 04:10 AM |
| BarsSinceEntry() | spinalwiz | General Programming | 4 | 12-04-2008 07:00 AM |