• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

what would script be to have trailstop base on 1 bar ago

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

    what would script be to have trailstop base on 1 bar ago

    this xml script has a profit target, a stop loss, and a trailing stop HOW TO MODIFY SCRIPT TO HAVE TRAIL STOP ADVANCE ONBARCLOSE TO ADVANCE THE TRAIL STOP TO

    low[1] less 6 ticks

    here is the xml script THANKS

    ************************************************** *****

    <?xml version="1.0" encoding="utf-8"?>
    <NinjaTrader>
    <AtmStrategy xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <IsVisible>true</IsVisible>
    <AreLinesConfigurable>true</AreLinesConfigurable>
    <ArePlotsConfigurable>true</ArePlotsConfigurable>
    <BarsToLoad>0</BarsToLoad>
    <DisplayInDataBox>true</DisplayInDataBox>
    <From>2099-12-01T00:00:00</From>
    <Panel>0</Panel>
    <ScaleJustification>Right</ScaleJustification>
    <ShowTransparentPlotsInDataBox>false</ShowTransparentPlotsInDataBox>
    <To>1800-01-01T00:00:00</To>
    <Calculate>OnBarClose</Calculate>
    <Displacement>0</Displacement>
    <IsAutoScale>true</IsAutoScale>
    <IsDataSeriesRequired>false</IsDataSeriesRequired>
    <IsOverlay>false</IsOverlay>
    <Lines />
    <MaximumBarsLookBack>TwoHundredFiftySix</MaximumBarsLookBack>
    <Name>AtmStrategy</Name>
    <Plots />
    <SelectedValueSeries>0</SelectedValueSeries>
    <BarsRequiredToTrade>0</BarsRequiredToTrade>
    <Category>Atm</Category>
    <ConnectionLossHandling>KeepRunning</ConnectionLossHandling>
    <DaysToLoad>1</DaysToLoad>
    <DefaultQuantity>1</DefaultQuantity>
    <DisconnectDelaySeconds>0</DisconnectDelaySeconds>
    <EntriesPerDirection>1</EntriesPerDirection>
    <EntryHandling>AllEntries</EntryHandling>
    <ExitOnSessionCloseSeconds>0</ExitOnSessionCloseSeconds>
    <IncludeCommission>false</IncludeCommission>
    <IsAggregated>false</IsAggregated>
    <IsExitOnSessionCloseStrategy>false</IsExitOnSessionCloseStrategy>
    <IsFillLimitOnTouch>false</IsFillLimitOnTouch>
    <IsOptimizeDataSeries>false</IsOptimizeDataSeries>
    <IsStableSession>false</IsStableSession>
    <IsTickReplay>false</IsTickReplay>
    <IsTradingHoursBreakLineVisible>false</IsTradingHoursBreakLineVisible>
    <IsWaitUntilFlat>false</IsWaitUntilFlat>
    <NumberRestartAttempts>0</NumberRestartAttempts>
    <OptimizationPeriod>10</OptimizationPeriod>
    <OrderFillResolution>High</OrderFillResolution>
    <OrderFillResolutionType>Tick</OrderFillResolutionType>
    <OrderFillResolutionValue>1</OrderFillResolutionValue>
    <RestartsWithinMinutes>0</RestartsWithinMinutes>
    <SetOrderQuantity>Strategy</SetOrderQuantity>
    <Slippage>0</Slippage>
    <StartBehavior>AdoptAccountPosition</StartBehavior>
    <StopTargetHandling>ByStrategyPosition</StopTargetHandling>
    <SupportsOptimizationGraph>false</SupportsOptimizationGraph>
    <TestPeriod>28</TestPeriod>
    <TradingHoursSerializable />
    <Gtd>1800-01-01T00:00:00</Gtd>
    <Template>200TrailExit</Template>
    <TimeInForce>Day</TimeInForce>
    <AtmSelector>d91ae296e49347deb9936c0a22dd737f</AtmSelector>
    <OnBehalfOf />
    <ReverseAtStopStrategyId>-1</ReverseAtStopStrategyId>
    <ReverseAtTargetStrategyId>-1</ReverseAtTargetStrategyId>
    <ShadowStrategyStrategyId>-1</ShadowStrategyStrategyId>
    <ShadowTemplate />
    <Brackets>
    <Bracket>
    <Quantity>100</Quantity>
    <StopLoss>31</StopLoss>
    <StopStrategy>
    <AutoBreakEvenPlus>10</AutoBreakEvenPlus>
    <AutoBreakEvenProfitTrigger>60</AutoBreakEvenProfitTrigger>
    <AutoTrailSteps>
    <AutoTrailStep>
    <Frequency>5</Frequency>
    <ProfitTrigger>100</ProfitTrigger>
    <StopLoss>35</StopLoss>
    </AutoTrailStep>
    </AutoTrailSteps>
    <IsSimStopEnabled>false</IsSimStopEnabled>
    <VolumeTrigger>0</VolumeTrigger>
    <Template>AutoTrailExit</Template>
    </StopStrategy>
    <Target>75</Target>
    </Bracket>
    <Bracket>
    <Quantity>100</Quantity>
    <StopLoss>31</StopLoss>
    <StopStrategy>
    <AutoBreakEvenPlus>10</AutoBreakEvenPlus>
    <AutoBreakEvenProfitTrigger>60</AutoBreakEvenProfitTrigger>
    <AutoTrailSteps>
    <AutoTrailStep>
    <Frequency>5</Frequency>
    <ProfitTrigger>100</ProfitTrigger>
    <StopLoss>35</StopLoss>
    </AutoTrailStep>
    </AutoTrailSteps>
    <IsSimStopEnabled>false</IsSimStopEnabled>
    <VolumeTrigger>0</VolumeTrigger>
    <Template>AutoTrailExit</Template>
    </StopStrategy>
    <Target>300</Target>
    </Bracket>
    </Brackets>
    <CalculationMode>Ticks</CalculationMode>
    <ChaseLimit>0</ChaseLimit>
    <EntryQuantity>200</EntryQuantity>
    <InitialTickSize>0</InitialTickSize>
    <IsChase>false</IsChase>
    <IsChaseIfTouched>false</IsChaseIfTouched>
    <IsTargetChase>false</IsTargetChase>
    <ReverseAtStop>false</ReverseAtStop>
    <ReverseAtTarget>false</ReverseAtTarget>
    <UseMitForProfit>true</UseMitForProfit>
    <UseStopLimitForStopLossOrders>false</UseStopLimitForStopLossOrders>
    </AtmStrategy>
    </NinjaTrader>

    ************************************************** *********


    #2
    Hello DTSSTS,

    I would recommend providing a screenshot of the Atm Strategy window with the parameters you have chosen.

    Atm Strategies do not use chart information such as bar closes in any way. These update tick for tick and pretty much ignore the chart all together.

    You would need a fully automated NinjaScript Strategy to trigger events when the bar closes in OnBarUpdate().

    Below is a link to a forum post with helpful information about getting started with NinjaScript Strategies.
    https://ninjatrader.com/support/foru...040#post786040

    And a link to an example script made with the Strategy Builder that does a trailing exit.
    https://ninjatrader.com/support/foru...427#post527427
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ok i have the strategy doing that, but someone in support said that could be done with a custom script , so you could enter without a strategy entry. Also if the Adopt position worked in the strategy builder that could be done as well, then you could apply strategy when you take a position.

      Comment


        #4
        Hello DTSSTS,

        A custom coded script would be a strategy, indicator, or addon.

        NinjaScript Strategies would need the entry placed by the Atm Strategy Create method, or if Atm Strategy Methods are not used, then it needs to place an entry with an entry order like EnterLong() or SubmitOrderUnmanaged().

        If you want to make an addon that monitors an account for manual entries to automatically place exit orders, that would be possible, extremely complicated, and would require a lot of custom programming.

        Below is a link to the Accounts section within Addons of the help guide and the Account.ExecutionUpdate event to point you in the right direction.
        https://ninjatrader.com/support/help...ount_class.htm
        https://ninjatrader.com/support/help...tionupdate.htm


        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          i put a sma 1 period, set to plot on the Low *no close( displaced 1 bar on my chart, then enter trade, , then enter a stop price, then click attach the stop to indicator * which was the low of 1 bar ago

          that is pretty simple , Just need to apply what ever script this created to xml file for a ATM

          Comment


            #6
            Hello DTSSTS,

            It sounds like you want to automatically enter the trade based on criteria. This would be simpler than monitoring an account for a manually submitted entry.

            If you are wanting a trail that updates using bar information, the TrailBuilder would be the best example of this.

            Atm Strategy Methods submit orders outside of the NinjaScript Strategy and are not updated with bar information. These work exactly the same as manually placed orders and trail based on real-time price (and does not use the bar information)

            If you are interested in submitting orders through Atm Strategy Methods, below is a link to the help guide.
            https://ninjatrader.com/support/help...gy_methods.htm
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              over my head, I have contact 2 programmers and they all say cannot create a custom script for ATM , so even many of the pros can figure this junk out,


              I would like to be able to enter thru atm, but at a min i wouild like to have my trail stop on bars in atm when i enter manually

              Comment


                #8
                where do you find this TrailBuilder

                Comment


                  #9
                  Hello DTSSTS,

                  It is both possible to create a custom NinjaScript that has custom coded logic for trailing that works exactly the same as an Atm Strategy and it is also possible to place an entry order using Atm Strategy Methods that has an existing Atm Strategy template attached.

                  I have provided you a link to the TrailBuilderExample in post #2.

                  The SampleAtmStrategy included with NinjaTrader demonstrates how to place an order from a strategy with an Atm Strategy attached using Atm Strategy Methods.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    so i understand how to build a strategy, and i got the trailbuilder imported

                    Now how does that become a ATM on the chart trader

                    Comment


                      #11
                      Hello DTSSTS,

                      The TrailBuilderExample demonstrates how to custom code a trailing stop with logic that is based on bar information.

                      If bar information is going to be used, then you would need to custom code the logic for the exit behavior.

                      If you do not need to reference bar information then you can use Atm Strategy Methods to submit an order with an Atm Strategy attached. This would require that you unlock the script and code this by hand as this is not something the Strategy Builder is capable of. The SampleAtmStrategy included with NinjaTrader demonstrates.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        so with the many different answers i am getting from many different people. It sounds like there is No way to attach an ATM that trail bar information or an indicator from this screen


                        https://gyazo.com/a97226174e688f8127676c332b903c34

                        then enter the trade manually and have the ATM manage the trade

                        Comment


                          #13
                          Hello DTSSTS,

                          This is correct. Atm Strategies do not use bar information from the chart. Atm Strategies only use real-time ticks for movement and ignore the chart bars completely. (The same as if you placed the order from the SuperDOM instead of on a chart)

                          You would need custom coded logic for an exit that uses bar information from the chart.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            • "You would need custom coded logic for an exit that uses bar information from the chart."
                            so the answer is you CAN attach from the chart ATM

                            if you have custom coded logic ?

                            problem is i have contacted 3 programmers and they all say cannot be done

                            ************************************************** **************************


                            Comment


                              #15
                              Hello DTSSTS,

                              The TrailBuilderExample is a basic example of custom logic using bar information to control the movement of an exit stop order.

                              A more complex script can be found here.
                              https://ninjatrader.com/support/foru...269#post802269

                              An addon version of the same kind of logic can be found here.
                              https://ninjatrader.com/support/foru...082#post536082

                              An addon that places orders through an atm strategy can be found here.
                              http://ninjatrader.com/support/forum...555#post515555

                              With an Atm Strategy you can use AtmStrategyChangeStopTarget() to control the movement of a stop as well.
                              https://ninjatrader.com/support/help...stoptarget.htm

                              Looping through an accounts active atm strategies is also possible and is demonstrated in the Addon Framework script available in the help guide.
                              https://ninjatrader.com/support/help...t_overview.htm

                              Last, reading the xml files of atm strategy templates and parsing the information and creating an extremely complex script that replicates the template is possible but would be very difficult and would be way outside of what is supported by NinjaTrader.

                              The pieces are there for different approaches. Likely, what you are specifically asking for is far more complex than the developers you are working with are willing to do.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NW Trader, Today, 03:42 PM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by ralett, Today, 01:42 PM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by Barry Milan, Today, 01:33 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by dkbyond, Yesterday, 04:11 PM
                              1 response
                              20 views
                              0 likes
                              Last Post NinjaTrader_ChrisL  
                              Started by w0lverine, Yesterday, 08:22 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChrisL  
                              Working...
                              X