Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

question about a code

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

    question about a code

    hello in this code attached the trailing stop is with every green renko the trail stop moves the length of the renko bar 5 points if the renko bars were 20. my question is i looked into the code but i did not find any setting to define that (i got the code from ecosystem on ninjatrader)
    1- where can I change in the code to move 5 points with every renko bar regardless if it is green or red
    2- define how many points to move whether 5 or more...
    any help is appreciated. thank you
    Attached Files

    #2
    Hello babouin77,

    In this script the trail stop is being set to a constant value of StopLossValue which is one of the user inputs.

    To change this to move only with a set allotment of distance would require using conditions and to manage the trailing stop order yourself. The trail stop is otherwise updated on each tick in realtime if you choose to or would use OnBarClose in historical. Instead of using an amount of ticks you would have to calculate the new price for each each OnBarUpdate.

    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 07-17-2020, 09:32 AM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      so o understand this well, when the strategy starts the stop loss value for example is 25... the trail stop is set at 25ticks... then it is moving with every bar close the value of the bar which in this case is 5 points (or 20 ticks). can you show me where in the code (either paste it or the line) it says to update on each tick? i couldnt find it.

      thanks again for your help

      Comment


        #4
        and how do I need to make it where it can move the number of ticks regardless if the ticks are positive or negative. now it trails only when the ticks are positive... trying to make it trail 5 points up regardless if positive or negative.

        Comment


          #5
          Hello babouin77,

          The trail stop is controlled with SetTrailStop, that is on line 77 of the file you provided. The OnEachTick update would be controlled in your script if you have set that, otherwise it will update with the OnBarUpdate as I had mentioned.


          To trail in a different way than the trail stop normally works you would just submit the type of order you wanted and control it yourself. You could submit a stop market order as an example and then control that by changing its price.

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

          Comment


            #6
            oh got you. so the way it is the built in trail stop will only move when price goes up... so the way it is it will only move up when price moves up... i would not be able to achieve that it will move with every renko close... correct?

            Comment


              #7
              what should the code look like to make the trail stop to move on every renko close regardless if it is up or down

              Comment


                #8
                Hello babouin77,

                You would be able to have the trail each renko close, it would move and trail assuming the price moved up otherwise it would stay at the same price if the price stayed the same or went the opposite way.

                I am not certain how to answer the second part of your question, you would need a calculation which brings a price closer to the current close price if you wanted to also trail on down bars. An indicator value could be used or your own logic, you would just be attaching the order to the indicator price or your calculated price to move it. From OnBarUpdate you could call the order again to update it and change its price.



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

                Comment


                  #9
                  Got you. Thanks for your help

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by rhyminkevin, Today, 04:58 PM
                  3 responses
                  47 views
                  0 likes
                  Last Post Anfedport  
                  Started by iceman2018, Today, 05:07 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post iceman2018  
                  Started by lightsun47, Today, 03:51 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post lightsun47  
                  Started by 00nevest, Today, 02:27 PM
                  1 response
                  14 views
                  0 likes
                  Last Post 00nevest  
                  Started by futtrader, 04-21-2024, 01:50 AM
                  4 responses
                  50 views
                  0 likes
                  Last Post futtrader  
                  Working...
                  X