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

ATMStrategyClose()

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

  • NinjaTrader_Kate
    replied
    Hello MisterGee,

    Thank you for your reply.

    We could certainly take a look at your log and trace files to see if that's what may be occurring - if that's what it is we should be able to see it occur in those. Rather than post them here, since they may contain personally identifiable information like your account number, please send them to us directly through the platform, via Help > Email Support. In the subject line, please put 2861801 ATTN Kate W. so we know to route it to me when it comes in. The box for Log and Trace files should automatically be checked.

    Thanks in advance; I look forward to assisting you further.

    Leave a comment:


  • MisterGee
    replied
    Thank you for the reply,

    All positions entered are done so via automated strategy, but it's only one position at a time on one instrument. The account is flat when the startegy is started.

    When the short position is opened it is unprotected and get closed when the automated strategy opens a long position.

    I'm not in front of my screen right now but I don't think it happened every time, but any time the position was closed via ATM stop loss or PT it did NOT happen. Only when it was closed with ATMStrategyClose().

    This is run OnBarClose.

    I'm wondering if you're on to something with the stop being hit close to when the ATMStrategyClose is being called.. any suggestions for testing that idea?

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello MisterGee,

    Thank you for your post.

    When running this, are you manually entering any orders on the same instrument and account combination? Is there an existing position when the strategy is started?

    When the short position is opened, does it too get an ATM stop and target, or is it an unprotected short position?

    Does this occur each time the strategy is run, or only occasionally?

    I'm not seeing anything in this particular code sample that would normally cause a reversal into a short position, however, if the stop is hit at essentially the same time you call AtmStrategyClose, it could cause such a scenario to occur, since that would submit a market sell order to close the long position it thinks is still there.

    Are you running this OnEachTick, OnPriceChange or OnBarClose?

    Thanks in advance, I look forward to assisting you further.

    Leave a comment:


  • MisterGee
    started a topic ATMStrategyClose()

    ATMStrategyClose()

    Hello;

    I am working with an ATM Strategy. I have a manually coded trailing stop, and a second set of rules that closes the ATM Strategy if the trailing stop is adjusted higher than the current price. I have noticed that when ATMStrategyClose() is invoked the long position is closed but the strategy opens a short position even though there are no rules to allow that. How can I ensure that the strategy waits for another long entry signal before entering another long trade, rather than going short?


    Code:
    // Change the stop if the close is above the currentlevel
    if (GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Long && Close[0] > CurrentLevel)
    {
    AtmStrategyChangeStopTarget(0, InitialY + (Slope1 * BarsElapsed), "STOP1", atmStrategyId);
    }
    
    // Close if close below current level
    else if (GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Long && Close[0] < CurrentLevel)
    {
    AtmStrategyClose(atmStrategyId);
    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by hazylizard, Today, 08:38 AM
0 responses
4 views
0 likes
Last Post hazylizard  
Started by Max238, Today, 01:28 AM
5 responses
42 views
0 likes
Last Post Max238
by Max238
 
Started by giulyko00, Yesterday, 12:03 PM
3 responses
12 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by habeebft, Today, 07:27 AM
1 response
14 views
0 likes
Last Post NinjaTrader_ChristopherS  
Started by AveryFlynn, Today, 04:57 AM
1 response
13 views
0 likes
Last Post NinjaTrader_Erick  
Working...
X