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 benmarkal, Yesterday, 12:52 PM
    3 responses
    23 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by helpwanted, Today, 03:06 AM
    1 response
    19 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    11 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    244 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    388 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X