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 cre8able, Today, 06:18 PM
        0 responses
        5 views
        0 likes
        Last Post cre8able  
        Started by ETFVoyageur, Today, 06:05 PM
        0 responses
        3 views
        0 likes
        Last Post ETFVoyageur  
        Started by TAJTrades, 04-28-2024, 09:46 AM
        2 responses
        17 views
        0 likes
        Last Post TAJTrades  
        Started by ETFVoyageur, Today, 02:04 PM
        2 responses
        19 views
        0 likes
        Last Post ETFVoyageur  
        Started by mjbatts91, Today, 04:48 PM
        0 responses
        5 views
        0 likes
        Last Post mjbatts91  
        Working...
        X