NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 08-28-2009, 08:41 AM   #1
everington_f
Member
 
Join Date: Nov 2008
Posts: 72
Thanks: 9
Thanked 0 times in 0 posts
Default Volume[BarsSinceEntry()+1)

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(
"", "");
}
everington_f is offline  
Reply With Quote
Old 08-28-2009, 08:51 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Any errors shown in Control Center logs during runtime?
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-28-2009, 08:57 AM   #3
everington_f
Member
 
Join Date: Nov 2008
Posts: 72
Thanks: 9
Thanked 0 times in 0 posts
Default

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....
everington_f is offline  
Reply With Quote
Old 08-28-2009, 09:04 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Then what aspect of this does not work? What behavior do you see as is?
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-28-2009, 09:41 AM   #5
everington_f
Member
 
Join Date: Nov 2008
Posts: 72
Thanks: 9
Thanked 0 times in 0 posts
Default

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.. ?
everington_f is offline  
Reply With Quote
Old 08-28-2009, 09:48 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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.
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 09:29 AM.