Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Programming Conditions

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

    Programming Conditions

    I have a question I'm hoping someone can help me with regards to programming conditions into my code.

    I am used to the Tradestation method of programming in which you can quickly identify say Condition1 = (insert condition), Condition2 = (insert condition) and so on and then in the end have an if statement.

    if condition1 and condition 2 then do something

    or

    if condition 1 or condition 2 then do something.

    I am currently trying to code an indicator that will indetify my setups with an up arrow or down arrow.

    I have several condition that need to be meet in order to satisfy a trade setup or not.

    What is the best way to code this?

    Is it possible to use Bool statements for each condition with if statements, for example

    bool condition1 = false;
    bool condition2 = false;

    if (high[0] > high[2]) {
    condition1 = true}

    if(low[3] < low[9]){
    condition2 = true}

    then have a statement at the end that checks for each condition to be true to run my code

    if (condition1 && condition2){
    drawarrowup}

    Any other ideas?

    Thanks

    #2
    Hello,


    Yes, this is one way of doing it. If you do it this way be sure you have a reset for your bools to set them back to false.

    Another way would be to just have one large if statement like this:

    if(high[0] > high[2] && low[3] < low[9])
    {

    DrawArrowUp("myArrowTag", true, Low[0], Color.Red);

    }
    DenNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DJ888, Today, 10:57 PM
    0 responses
    1 view
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    158 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Today, 09:29 PM
    0 responses
    7 views
    0 likes
    Last Post Belfortbucks  
    Started by zstheorist, Today, 07:52 PM
    0 responses
    7 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    151 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Working...
    X