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

AtmStrategyChangeStopTarget usage with chart trader

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

    AtmStrategyChangeStopTarget usage with chart trader

    Hi,

    I am attempting to use the AtmStrategyChangeStopTarget method within a strategy to set custom stops and targets. However, when viewing the orders with chart trader, the stop and target always set by the ATM template only.

    The following is the code block I'm using to set them:

    Code:
                    if (atmStrategyId.Length > 0 )
                    {
                        if(GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
                        {
                            Print("Flat");
                            atmStrategyId = string.Empty;
                        }
                        else
                        {
                            if( EnableFractalStop )
                            {
                                double avgPrice = GetAtmStrategyPositionAveragePrice(atmStrategyId);
    
                                stopTicks = getStopTicks(false, avgPrice);
                                targetTicks = (int)((double)stopTicks * RewardRatio);
    
                                stopPrice = avgPrice + (TickSize * (double)stopTicks);
                                targetPrice = avgPrice - (TickSize * (double)targetTicks);
    
                                AtmStrategyChangeStopTarget(0, stopPrice, "Stop1", atmStrategyId);
                                AtmStrategyChangeStopTarget(targetPrice, 0, "Target1", atmStrategyId);
                            }
                        }
                    }​
    Is there something I'm not doing correctly? Any feedback or resources would be greatly appreciated.

    #2
    Hello Newbie-NT-Scriptor,

    Are you certain that logic is being executed? Have you tried adding a print into the condition to make sure that AtmStrategyChangeStopTarget is being called?
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you Jesse, you were correct in that it was not being executed since it was immediately following the order submission.

      One more question, what would be the best way to find whether the stop or target has been filled or if there is no longer an active ATM strategy being that GetAtmStrategyStopTargetOrderStatus is only relative to an active strategy? I'm simply seeking to find when the strategy has gone back flat so I can track whether a new position can be taken.

      Thanks in advance!

      Comment


        #4
        Hello Newbie-NT-Scriptor,

        I would suggest reviewing the SampleATMStrategy that comes with the platform, that shows the base logic required to manage an ATM through its lifecycle Your script would need basically everything that shows to operate properly and know when the atm becomes flat. That covers all situations such as entry being filled, targets being filled or atm being cancelled.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by lakman184, 03-24-2024, 01:30 PM
        7 responses
        35 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by MrAdamSK, 04-02-2024, 11:25 PM
        2 responses
        41 views
        0 likes
        Last Post Marcos De Luca  
        Started by DawnTreader, 05-08-2024, 05:58 PM
        20 responses
        80 views
        0 likes
        Last Post DawnTreader  
        Started by llanqui, Yesterday, 10:29 AM
        5 responses
        26 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by lorem, 04-25-2024, 09:18 AM
        14 responses
        62 views
        0 likes
        Last Post lorem
        by lorem
         
        Working...
        X