Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Code Executing when if() not true

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

    Code Executing when if() not true

    Hi hopefully I am just having a brain fart but I feel like this is an issue that doesn't have to do with me.

    Essentially all I am trying to do is set a stop at Breakeven once the price (High) has gone a certain number of points (BreakevenStop) above or below (depending on direction) the entry price.

    I have written this code over and over again on other strategies and it works flawlessly, that is why I am so confused as to why on this specific one it is not working.

    I am posting screenshots of the code and the output and the strategy analyzer below. Yes I have put Print statements in my code, that is what I will be showing.

    I have it set to Print every time the code is run, so essentially in theory I should only possibly have as many stop losses set as there are print statements.

    Also in the Print Statement I have it print the date that it is executed on. If you look at the trades dates you can see that it has stop loss fills at completely different dates.

    Let me know if I am just being stupid, my degree in Computer Science degree is crying right now

    Edit:
    I think I may of resolved the issue using ExitShortStopMarket() (In the past this order was bugged in the strategy Analyzer)

    Still would like to figure out the issue with this though
    Attached Files
    Last edited by Vikuno1; 12-29-2022, 09:39 PM.

    #2
    Hello, thanks for writing in.

    The Set methods should be set before the position is taken, otherwise the stop loss will be set to whatever was called before the previous entry was made. That is probably what you were seeing here.

    Kind regards,

    -ChrisL

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X