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 tsantospinto, 04-12-2024, 07:04 PM
        7 responses
        126 views
        0 likes
        Last Post aligator  
        Started by futtrader, 04-21-2024, 01:50 AM
        5 responses
        56 views
        0 likes
        Last Post NinjaTrader_Eduardo  
        Started by PeakTry, Today, 10:49 AM
        0 responses
        2 views
        0 likes
        Last Post PeakTry
        by PeakTry
         
        Started by llanqui, Today, 10:32 AM
        0 responses
        5 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by StockTrader88, 03-06-2021, 08:58 AM
        45 responses
        3,994 views
        3 likes
        Last Post johntraderuser2  
        Working...
        X