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

Multiple entries per direction, only the favorable buys

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

    Multiple entries per direction, only the favorable buys

    In my strategy I've enabled multiple entries per direction (up to 5). Every time a buy signal is triggered my strategy buys long than when a sell is triggered it sells long all held share. Some buy signals are better than others in relationship to the previous buy price. Any way to say only buy again if the price has dropped lower than the 1st buy price? I'd like to skip buying a second share if the price is higher on the 2nd, 3rd, 4th or 5th buy trigger.

    Also if the buy price has dropped since the first buy I'd like to buy double.

    For example:

    there are 3 buy signals

    1st buy trigger at $2 = buy long 1 share
    2nd buy trigger at $1 = buy long 2 shares
    3rd buy trigger at $3 = skip buying

    1st sell trigger = sell long all held shares and reset buy triggers

    Any way to do this or something like this? Thanks

    #2
    Hello jerblaster23,

    Welcome to the NinjaTrader forums!

    You can compare the an order's AverageFillPrice from an order that is assigned to a variable in OnOrderUpdate().


    For example:

    if (myOrder != null && myOrder.OrderState == OrderState.Filled && Close[0] < myOrder.AverageFillPrice)
    {
    EnterLong(myOrder.Quantity * 2);
    }

    Below I am providing a link to a forum post with helpful information about getting started with NinjaScript and C#.


    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Gerik, Today, 09:40 AM
    2 responses
    6 views
    0 likes
    Last Post Gerik
    by Gerik
     
    Started by RookieTrader, Today, 09:37 AM
    2 responses
    10 views
    0 likes
    Last Post RookieTrader  
    Started by alifarahani, Today, 09:40 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by KennyK, 05-29-2017, 02:02 AM
    3 responses
    1,285 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by AttiM, 02-14-2024, 05:20 PM
    11 responses
    186 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X