![]() |
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 |
|
Senior Member
Join Date: May 2008
Posts: 126
Thanks: 0
Thanked 0 times in 0 posts
|
I am trying to check the days between two events.
If I buy, I set a variable with ToDay(Time[0]). My problem appears when I try to use this variabe in the next context. Please find below an extract of my code: Code:
// Condition set 1
if (Low[0] < MIN(Low, 20)[1]
{
int Inday = ToDay(Time[0]);
EnterLongStop();
}
// Condition set 2
if (Position.GetProfitLoss(Open[0], PerformanceUnit.Percent) > 0
&& ToDay(Time [0])> Inday)
{
ExitLong("", "");
}
Thanks a lot!
Last edited by eswap0; 06-07-2008 at 01:28 PM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Initialize the variable outside of the if statement in the Variables section. Then you should be able to access it throughout your code.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: May 2008
Posts: 126
Thanks: 0
Thanked 0 times in 0 posts
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Global variables | monpere | Strategy Development | 1 | 03-10-2008 07:06 PM |
| Limited use of variables | andy2001 | General Programming | 5 | 03-04-2008 03:47 PM |
| User variables | Bogan7 | Strategy Development | 1 | 01-06-2008 01:07 AM |
| importing variables from .txt | sandro | Indicator Development | 1 | 05-15-2007 06:59 AM |
| Plotting variables | MAX | Indicator Development | 2 | 10-30-2006 10:19 PM |