![]() |
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: Oct 2007
Posts: 95
Thanks: 0
Thanked 0 times in 0 posts
|
Hi
I am trying to reset a variable after price pass above or below a certain point. For example if price crosses above or below yesterdays close reset this variable. I tried using the cross above/below function but I got errors. I tried this if (CrossBelow(High[0],PriorDayOHLC().PriorClose[0])) tradeCount = 0; But got a error message saying "No overload for method CrossBelow take 2 arguments. How can get this to work? Thanks |
|
|
|
|
|
#2 |
|
Member
Join Date: Oct 2007
Posts: 95
Thanks: 0
Thanked 0 times in 0 posts
|
What am I doing wrong? I am trying to get the program to only take one trade until price crosses the close of the previous day or a new trading session begins. Aften then it is allowed to take another trade.
private int tradeCounter = 0; if (tradeCounter == 1) return; if (Low[0]>=PriorDayOHLC().PriorClose[0]) tradeCounter = 0; if (High[0] >= PriorDayOHLC().PriorClose[0] ) tradeCounter = 0; if (Bars.FirstBarOfSession && FirstTickOfBar) tradeCounter = 0; if ( blah blah. ) EnterLong ; tradeCounter++; if (blah blah) EnterLong ; traderCounter++; |
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
If this is at the top of OnBarUpdate() then the rest of the code will never work if you have one trade open. You want the rest of the code to work all the time right?: if (tradeCounter == 1) return; Don't you want EnterLong and tradeCounter in brackets like this so the counter only counts when a trade is executed?: if ( blah blah. ) { EnterLong ; tradeCounter++; }
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Member
Join Date: Oct 2007
Posts: 95
Thanks: 0
Thanked 0 times in 0 posts
|
Ok thanks I got it. I have another problem. I am trying to reset the same variable after price pass above or below the previous day close. For example if price crosses above or below yesterdays close reset this variable. I tried using the cross above/below function with High[0]/Low[0] and priordayHOLC indicator but that did not work. I am now using cross above/below with priordayHOLC and a 1 period sma. That works but it does do the job fully. If the Low/High of a bar move below/above the prior days close the 1 period sma will not touch or cross the previous days closing price and the variable does not get reset. How can I program this ?
Thanks |
|
|
|
|
|
#5 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
trader413,
What have you tried originally? CrossAbove(High, PriorDayOHLC().PriorClose[0], 1)
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Member
Join Date: Oct 2007
Posts: 95
Thanks: 0
Thanked 0 times in 0 posts
|
I tried those two and got an error.
CrossAbove(High[0], PriorDayOHLC().PriorClose[0], 1) CrossBelow(Low[0], PriorDayOHLC().PriorClose[0], 1) |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 973 times in 956 posts
|
Which error exactly did you get trader413?
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Member
Join Date: Oct 2007
Posts: 95
Thanks: 0
Thanked 0 times in 0 posts
|
I am not on my trading computer right now but I think the error I got was
"Argument '2': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries" |
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Remove the [0] on the High and Low. You need to check DataSeries to double value not double value vs another double value.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| resetting indicators | dirtybrown | Indicator Development | 9 | 06-01-2009 02:06 PM |
| Resetting account performance ? | T2020 | Miscellaneous Support | 2 | 09-08-2008 07:25 AM |
| Data values resetting | Burga1 | Indicator Development | 5 | 05-23-2008 03:25 PM |
| Resetting SIM trades | gygraham | Strategy Analyzer | 1 | 04-14-2008 07:01 PM |
| chart resetting question | Lupus | Charting | 1 | 03-28-2006 08:50 AM |