Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using variables

    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("", "");
    } 
    How can I use the variable "Inday", set in the first condition, also in the second condition?
    Thanks a lot!
    Last edited by eswap0; 06-07-2008, 12:28 PM.

    #2
    Initialize the variable outside of the if statement in the Variables section. Then you should be able to access it throughout your code.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by Josh View Post
      Initialize the variable outside of the if statement in the Variables section. Then you should be able to access it throughout your code.
      Thank you very much: it worked!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Franck Z, Today, 09:49 AM
      0 responses
      5 views
      0 likes
      Last Post Franck Z  
      Started by pvtrader, Today, 08:02 AM
      2 responses
      7 views
      0 likes
      Last Post pvtrader  
      Started by Natoc, Today, 03:04 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by Rudy2323, Today, 02:56 AM
      2 responses
      28 views
      0 likes
      Last Post Rudy2323  
      Started by tonynt, Yesterday, 02:07 PM
      1 response
      37 views
      0 likes
      Last Post NinjaTrader_Jason  
      Working...
      X