Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Modifying syntax logic for NT

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

    Modifying syntax logic for NT

    HI I am trying to write a logic to go long when last consecutive bars are bullish and about the same size.

    ChatGPT throws sample code but its not good for NT. Can someone help to convert the logic?




    double[] barSizes = new double[5];
    bool[] bullishBars = new bool[5];

    // Loop through the last 5 bars
    for (int i = 0; i < 5; i++)
    {
    // Calculate the size of each bar
    barSizes[i] = Math.Abs(Opens[i] - Closes[i]);

    // Determine if the bar is bullish
    bullishBars[i] = Closes[i] > Opens[i];
    }

    // Calculate the average size of the bars
    double averageSize = (barSizes[0] + barSizes[1] + barSizes[2] + barSizes[3] + barSizes[4]) / 5;

    // Define a tolerance for variation in bar sizes
    double tolerance = 0.01; // Adjust this value as needed

    // Check if all bar sizes are within the tolerance of the average size
    bool similarSizes = true;
    foreach (double size in barSizes)
    {
    if (Math.Abs(size - averageSize) > tolerance)
    {
    similarSizes = false;
    break;
    }
    }

    // Check if all bars are bullish
    bool allBullish = true;
    foreach (bool isBullish in bullishBars)
    {
    if (!isBullish)
    {
    allBullish = false;
    break;
    }
    }

    // If the last 5 bars were all bullish and of similar size, go long
    if (allBullish && similarSizes)
    {
    EnterLong();
    }
    }
    }
    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by Mindset, 04-21-2026, 06:46 AM
0 responses
88 views
0 likes
Last Post Mindset
by Mindset
 
Started by M4ndoo, 04-20-2026, 05:21 PM
0 responses
134 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by M4ndoo, 04-19-2026, 05:54 PM
0 responses
68 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by cmoran13, 04-16-2026, 01:02 PM
0 responses
119 views
0 likes
Last Post cmoran13  
Started by PaulMohn, 04-10-2026, 11:11 AM
0 responses
67 views
0 likes
Last Post PaulMohn  
Working...
X