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 NullPointStrategies, Today, 05:17 AM
0 responses
51 views
0 likes
Last Post NullPointStrategies  
Started by argusthome, 03-08-2026, 10:06 AM
0 responses
127 views
0 likes
Last Post argusthome  
Started by NabilKhattabi, 03-06-2026, 11:18 AM
0 responses
69 views
0 likes
Last Post NabilKhattabi  
Started by Deep42, 03-06-2026, 12:28 AM
0 responses
42 views
0 likes
Last Post Deep42
by Deep42
 
Started by TheRealMorford, 03-05-2026, 06:15 PM
0 responses
46 views
0 likes
Last Post TheRealMorford  
Working...
X