Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SL Condition Within Entry Condition

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

    SL Condition Within Entry Condition

    Hello everyone,

    Currently I have a strategy that sets a stoploss at the Low - 6 ticks or High + 6 ticks @ entry depending upon if it is a long or short. I want to add another option under certain conditions.

    I want to set either one stop loss OR the other, depending upon if a condition is true (if the wick of the entry candle is greater or less than a certain calculated tick value, saved to a variable diffLong or diffShort).

    What would be the proper syntax to make this possible? So far I haven't had any success. I have tried different combinations, including simply adding a condition and action with brackets WITHIN the brackets for the entry condition, I have tried if, else if syntax. Nothing.

    Code:
    if (Condition for Entry)
                {
                    if (ssdiff < 44) {SetStopLoss(@"TestStopShort", CalculationMode.Price, High[0] + 6 * TickSize, false);}
                    SetStopLoss(@"TestStopShort", CalculationMode.Ticks, 20, false);
                    EnterShort(1, Q, @"TestStopShort");
                }
    That is a snippet of my code just so you can see with greater specificity what I am dealing with.

    Thanks for any ideas.

    #2
    Hello lunardiplomacy,

    Thanks for your post.

    Have you tried this:

    if (Condition for Entry)
    {

    if (ssdiff < 44)
    {
    SetStopLoss(@"TestStopShort", CalculationMode.Price, High[0] + 6 * TickSize, false);
    }
    else
    {
    SetStopLoss(@"TestStopShort", CalculationMode.Ticks, 20, false);
    }


    EnterShort(1, Q, @"TestStopShort");
    }

    Comment


      #3
      Hi Paul, thanks for getting back to me.

      Yes, that syntax was the first that I tried and I thought that should absolutely work, right? But, it doesn't. I just tried again to make sure, and still the same result.

      However, I do have some additional information now. I tried tacking on 'ssdiff < 44' to my entry conditions, just to see if I intentionally ran it on a 100 tick wick, whether it would take a trade or not (it shouldn't), and it did indeed take a trade. Which means something is not right about how the entry is being taken.

      'ssdiff' prints the correct values, so I know it is over 44 when the trade is taken, and therefore calculating correctly. I even set that condition as a bool and added that it has to be true in order for the trade to be taken. And yet, in a test, I saw right before my eyes that it printed false and the diff printed over 100 ticks and still the trade was taken.

      I am so confused, things that should absolutely work are not working. I am going to try to isolate this set of conditions to a new script to see if I can get it to work. In the meantime, any ideas you might have for me in terms of what's going wrong would be greatly appreciated.

      Thank you.

      Comment


        #4
        Hello lunardiplomacy,

        Thanks for your reply.

        Make sure you are checking the "log" tab of the control center when you apply the script as any errors or ignored orders would be noted there.

        Otherwise, I would suggest debugging further and agree with the idea to "... try to isolate this set of conditions to a new script to see if I can get it to work."

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        113 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        60 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        40 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        43 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        81 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X