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 kinfxhk, 07-14-2026, 09:39 AM
    0 responses
    10 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    59 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    41 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    47 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    38 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X