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 NullPointStrategies, Today, 05:17 AM
    0 responses
    46 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    66 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