Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Stop Loss Strategy Builder Current Day OHL

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

    #16
    Hello walter739,

    I would suggest adding a print as an action to the Entry condition to see if that is being called more than you expect. From the code it currently has no conditions to check if you are flat so that logic should be able to be run for every bar where the conditions is true. If you are already in a position that would just reset the variables price which would later be used for the stop. Another way to look at this would be to execute a trade in realtime and then observe it, is the stop moving prices or is it always stationary and the same price?


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #17
      Hello walter739,

      Are you seeing that the price of the target is being moved after it was submitted? The condition that you have now does not check that the position is flat so potentially the conditions is becoming true again and resetting the price. You could confirm this by observing a trade in realtime and noting the price which it was submitted at. If the price changes while you are waiting for a fill the entry condition is resetting the price. The entry would be ignored if you are already in a position but the remainder of the logic would still be executed.

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #18
        Hello Jesse, many thanks for your time, you are right, i change the code and work fine.

        Regards and thanks

        protected override void OnBarUpdate()
        {
        if (BarsInProgress != 0)
        return;

        if (CurrentBars[0] < 1
        || CurrentBars[1] < 0)
        return;

        // Set 1
        if ((EMA1[0] < EMA2[0])
        && (CrossBelow(Close, EMA3, 1))
        && (Position.MarketPosition == MarketPosition.Flat))
        {
        EnterShort(Convert.ToInt32(QuantityStocks), @"sell");
        Shortloss = Swing1.SwingHigh[0];
        }

        // Set 2
        if (Position.MarketPosition == MarketPosition.Short)
        {
        ExitShortStopMarket(Convert.ToInt32(QuantityStocks ), Shortloss, @"exitshortloss", @"sell");
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ZenCortexCLICK, Today, 04:58 AM
        0 responses
        2 views
        0 likes
        Last Post ZenCortexCLICK  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        172 responses
        2,280 views
        0 likes
        Last Post sidlercom80  
        Started by Irukandji, Yesterday, 02:53 AM
        2 responses
        17 views
        0 likes
        Last Post Irukandji  
        Started by adeelshahzad, Today, 03:54 AM
        0 responses
        5 views
        0 likes
        Last Post adeelshahzad  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X