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

TrailBuilder Example Su!ks

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

    TrailBuilder Example Su!ks

    i'm developing a strategy in hopes of having a trigger that then has a profit attain. the example is missing a bool and an int. can you provide some more assistance. is there anyway you can make an example that demonstrates a rachet of a frequency of 1 point with a -3 point distance for a duration of 8 points. i'm positive there are people who could benefit from seeing a demostration strategy with a little more umph illustrating a common feature that almost with all certainty anyone with a brain would use. i don't get the set trail stop application as it is very rudimentary. ya'll should have an example strategy not using the same numbers like 10 and -10 as that leads to confusion.

    #2
    Hello SteveReiza,

    Thanks for your post.

    We do not have a reference sample available that demonstrates your specific scenario. The TrailBuilderExample reference sample is a reference sample that demonstrates implementing a trailing stop loss in a Strategy Builder strategy.

    When testing the TrailBuilderExample script on my end I see it is working exactly as it is programmed to function.

    The way the TrailBuilderExample script works is as follows:

    In Set 1 of the TrailBuilderExample strategy, we check if we are in a Flat market position and reset the CurrentStopPrice variable to 0. This is so that anytime we go Flat, the CurrentStopPrice is reset.

    In Set 2, we check if we are in a Flat market position and check if the current State is State.Realtime to check that realtime data is processing. In this Set, we then call the EnterLong() method to enter a position. We also assign a value to the CurrentTriggerPrice and CurrentStopPrice.

    CurrentTriggerPrice is used to trail the stop order and CurrentStopPrice is used to update the price of the stop order.

    In Set 3, we check if we are in a Long market position and we check if the current Close price is greater than the CurrentTriggerPrice. In this Set, we update the CurrentTriggerPrice and CurrentStopPrice when the current close price trails above our CurrentTriggerPrice set in Set 2.

    In Set 4, we check if CurrentStopPrice is not equal to 0 (which also means we are not in a flat position. See Set 1) and submit our stop order to the CurrentStopPrice with ExitLongStopMarket().

    TrailStopDistance is how far away the stop is placed from the Close price in ticks since the stop loss uses CurrentStopPrice and we assign (Close[0] + (TrailStopDistance * TickSize)) to the Exit method.​

    For example, if TrailStopDistance is set to -4, this means that CurrentStopPrice will be assigned a value of the Close price minus 4 ticks. So the initial stop order would be placed 4 ticks below the entry and trail from there.

    TrailFrequency is used to offset the CurrentTriggerPrice by a set number of ticks. CurrentTriggerPrice is assigned (Close[0] + (TrailFrequency * TickSize)).

    If we set the TrailFrequency to 4, this means that CurrentTriggerPrice is assigned a value of the Close price plus 4 ticks. Then, anytime the price moves 4 ticks in your favor, the stop would move to the value assigned to CurrentStopPrice.​

    You would need to implement your own custom logic in the strategy to accomplish your specific goals.

    If you could provide some clarification on what exactly you mean by " a rachet of a frequency of 1 point with a -3 point distance for a duration of 8 points." we would be happy to provide you with some direction.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      thanks for the reply. i'm going to make one you can dole out as an example. i've figured as much out as i could from remembering a previous script i got from an add on partner to build a laddered stop with profit triggers and profit capture. i think i'm almost there. kudos to your design firm - java sucks -, C rules

      Comment


        #4
        Here. Give this one out - or, one like it.
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sukhob, Today, 01:10 PM
        1 response
        13 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, 11-29-2023, 07:15 AM
        3 responses
        98 views
        0 likes
        Last Post lunardiplomacy  
        Started by ZenCortexNow, Today, 01:28 PM
        0 responses
        15 views
        0 likes
        Last Post ZenCortexNow  
        Started by MatthewLesko, 12-10-2021, 10:24 AM
        51 responses
        6,191 views
        0 likes
        Last Post brenthilburn  
        Started by AnnaM, 11-01-2022, 08:17 PM
        14 responses
        1,073 views
        0 likes
        Last Post spiketrades9  
        Working...
        X