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 ntbone, Yesterday, 11:42 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by mr_trade, 11-26-2020, 05:01 PM
      5 responses
      59 views
      0 likes
      Last Post mr_trade  
      Started by evanp90, 01-14-2021, 07:03 PM
      4 responses
      33 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by fernlicht, Today, 04:01 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by Leeroy_Jenkins, Today, 03:51 AM
      1 response
      13 views
      0 likes
      Last Post Leeroy_Jenkins  
      Working...
      X