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

reverse using unmanaged mode

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

  • Papercut110
    replied
    Thanks a lot, guys, now try

    Leave a comment:


  • bltdavid
    replied
    Originally posted by Papercut110 View Post
    while on the other hand the script needs to understand what the position was closed by stop - long or short...
    I solved this problem by naming the entry order in a special way.

    For entry orders:
    I prefix CurrentBar with an 'L' or 'S', depending on direction.
    (Example: L2345)

    For stop orders, I add suffix "stp" to the entry order name.
    (Example: L3245stp)

    For target orders, I add suffix "tgt" to the entry order name.
    (Example: L3245tgt)

    OK, so when dealing with your stop order, just look at the stopOrder.Name field and check the first letter, then you'll know the direction.

    Leave a comment:


  • koganam
    replied
    Originally posted by Papercut110 View Post
    I understand you correctly, it should look something like this?
    if (stopOrder != null && stopOrder == execution.Order)
    {
    }

    while on the other hand the script needs to understand what the position was closed by stop - long or short...
    Pretty much, provided your exit order (stop loss) is called stopOrder.

    Your question kind of implied that your Stop Loss being hit would be to take the position flat, which is why I stopped where I did. Otherwise, you would have to query the Position for its size, and calculate the necessary size of the reversal order to put you in the position that you want to be in. The Position object holds all the data that you need to determine your existing market posture, at any time.

    Leave a comment:


  • Papercut110
    replied
    I understand you correctly, it should look something like this?
    if (stopOrder != null && stopOrder == execution.Order)
    {
    }

    while on the other hand the script needs to understand what the position was closed by stop - long or short...

    Leave a comment:


  • koganam
    replied
    Originally posted by Papercut110 View Post
    Good day, help me please, I wrote a simple strategy in learning mode, unmanaged, but still can't figure out how to do a position reversal from the initial point of entry if the stop loss gets triggered, could you help me?

    below I put the code
    Use the OnExecution() handler to determine ff the Stop Loss was the executed trade, then enter another trade in the desired direction?
    Last edited by koganam; 01-23-2017, 05:55 PM. Reason: Corrected spelling.

    Leave a comment:


  • Papercut110
    started a topic reverse using unmanaged mode

    reverse using unmanaged mode

    Good day, help me please, I wrote a simple strategy in learning mode, unmanaged, but still can't figure out how to do a position reversal from the initial point of entry if the stop loss gets triggered, could you help me?

    below I put the code
    Attached Files

Latest Posts

Collapse

Topics Statistics Last Post
Started by carnitron, Today, 08:42 PM
0 responses
5 views
0 likes
Last Post carnitron  
Started by strategist007, Today, 07:51 PM
0 responses
6 views
0 likes
Last Post strategist007  
Started by StockTrader88, 03-06-2021, 08:58 AM
44 responses
3,974 views
3 likes
Last Post jhudas88  
Started by rbeckmann05, Today, 06:48 PM
0 responses
8 views
0 likes
Last Post rbeckmann05  
Started by rhyminkevin, Today, 04:58 PM
4 responses
58 views
0 likes
Last Post dp8282
by dp8282
 
Working...
X