Please help. Conditions met on my EA but no buy signal is given

 

Hello all,

I am new to coding so please bare with me. I have my code compiled with no errors, but when I backtest it, no trades are bought or sold even though there are many instances where conditions are met during the test timframe.

// Execute trade based on crossovers and RSI conditions
    if (long_above_short && rsiValue < RSI_Oversold_Level)
    {
        // Buy signal detected
        BuySignal();
    }
    else if (short_above_long && rsiValue > RSI_Overbought_Level)
    {
        // Sell signal detected
        SellSignal();
    }
}


(market data where conditions are met)

USDSEK,M1   
Date    2023.03.29
Time    20:57
Open    10.40310
High    10.40311
Low    10.39871
Close    10.39921
Tick Volume    47
Spread    358
MA(3)    10.402046
MA(30)    10.408405
MA(5)    10.403470
MA(35)    10.408937
MA(7)    10.404365
MA(40)    10.409406
MA(9)    10.405014
MA(45)    10.409813
MA(11)    10.405528
MA(50)    10.410163
MA(13)    10.405958
MA(55)    10.410458
Indicator window 1   
RSI(14)    20.76

ANALYSIS BELOW:

  1. RSI Condition:
  • RSI value (14-period) is 20.22.
  • RSI_Oversold_Level is 30.

Since the RSI value (20.22) is less than the RSI_Oversold_Level (30), the RSI condition for a buy signal is met.

  1. EMA Conditions:
  • The short-term EMAs are: MA(3): 10.400428, MA(5): 10.401916, MA(8): 10.402976, MA(10): 10.403773, MA(12): 10.404937, MA(18): 10.410042.
  • The long-term EMAs are: MA(30): 10.407786, MA(35): 10.408374, MA(40): 10.408889, MA(45): 10.409335, MA(50): 10.409717, MA(60): 10.410042.

Since all the short-term EMAs are above the long-term EMAs, the long_above_short condition is true, and the short_above_long condition is false.

  1. Combined Conditions:
  • The long_above_short condition is true.
  • The short_above_long condition is false.
  • The RSI condition for a buy signal is met.

Based on my analysis, the market data meets the conditions for a buy signal in the code. Therefore, the code should generate a buy signal for the given market data.


Any ideas on where I go from here??

 
Try checking line 1001
 
Roberto Jacobs #:
Try checking line 1001
My code stops at line 106. I did test it with my paper account last night and it did open and close positions successfully, but just won't work on backtesting.