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 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