Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Logic in strategy issue

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

    Logic in strategy issue

    HI i got this code and the problem is that strategy opens long with condition conditionMetL as false. I am having several conditions with each bools...
    My prints just before entering long
    conditionMetLFalse
    useRSIFilterTrue
    UseFirstHTFTrue
    MatchTrendDirectionTrue
    closeTrendlineTrue​

    Code:
    if (TLBreakoutSignal)
                {
                    bool conditionMetL = false;
                    Print("conditionMetL"+conditionMetL);
                    Print("useRSIFilter"+useRSIFilter);
                    Print("UseFirstHTF"+UseFirstHTF);
                    Print("MatchTrendDirection"+MatchTrendDirection);
                    Print("closeTrendline"+closeTrendline);
                    
                    if(useRSIFilter)
                    {
                        conditionMetL = rsiIndPrim[0] >= rsiMinLong && rsiIndPrim[0] <= rsiMaxLong;
                    }
                    if(useATRFilter)
                    {
                        conditionMetL = conditionMetL || (atrInd[0] < MaxATRValue);
                    }
                    if(UseFirstHTF)
                    {
                        if(MatchTrendDirection)
                        {
                            conditionMetL = conditionMetL || (trendDirection2 == cRising2);
                        }
                        if(UseStochFirstFilter)
                        {
                            conditionMetL = conditionMetL || (stoch1HTF.D[0] >= stoch1HTFMin);
                        }
                        if(closeTrendline)
                        {
                            conditionMetL = conditionMetL || (MatchTrendDirection && Close[0] > trendPrice2);
                        }
                        else
                        {
                            conditionMetL = conditionMetL || (stoch1HTF.K[0] > stoch1HTF.D[0]);
                        }
                    }
                    if(UseSecHTF)
                    {
                        if(extendingBool)
                        {
                            conditionMetL = conditionMetL || !extendingShort;
                        }
                        else
                        {
                            conditionMetL = conditionMetL || !(stochHTF.D[0] <= 20);
                        }
                    }
                    if(useSlopeFilter)
                    {
                        conditionMetL = conditionMetL || (regSlope[0] <= 10 && regSlope[0] >= 0.01);
                    }
                    else
                    {
                        conditionMetL = conditionMetL || ((trendDirection == cFalling) && (Close[0] > trendPrice) && Close[1] < trendPrice && barMedianPrice < trendPrice);
                    }
                
                    LongTLBreakoutSetup = conditionMetL;
                }​
    if(LongTLBreakoutSetup)
    go long

    #2
    Hello tkaboris,

    Your print is at the beginning of your conditions, to know why the condition is not working as you expect you need to add more prints in each of the sections where you toggle the variable.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    80 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X