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 pibrew, Today, 06:37 AM
        0 responses
        4 views
        0 likes
        Last Post pibrew
        by pibrew
         
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        14 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        11 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        16 views
        0 likes
        Last Post AaronKoRn  
        Working...
        X