Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can we use ninjascript + hotkeys for trade management (once a trade is live?)

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

    Can we use ninjascript + hotkeys for trade management (once a trade is live?)

    I am not a programmer but I can understand some basic coding (took a couple of classes back in my college days, it was basically intro to c++)

    Is it possible to program a script and tie it to a hotkey, for example:

    I am long ES X lots at 3000.

    Price shoots up to 3006.

    I want to hit a hotkey (ie: F4) and have it automatically place (X - 1) lots 2 ticks below current price.

    So whenever I hit F4, I want to dump all but 1 lot of whatever my total position is and keep 1 left as a runner. I want it to be 2 ticks below current price as I prefer that than market orders.

    Could someone help point me in the right direction? Thanks!



    #2
    Hello LenovoX1E,

    Thanks for your post.

    This could be accomplished using C# and the PreviewKeyDown event from the ChartControl to look for the keys and set e.Handled = true;.

    See the example script that was created by my colleague Chelsea in this forum post: https://ninjatrader.com/support/foru...973#post685973

    Note that this concept is applied to the text box in this sample. The textbox needs to be in focus in this sample for the key handling to occur. This would be the same general concept for placing orders, except that you would subscribe to ChartControl in place of the textbox.

    The ChartControl is what is focused when the indicator is applied. If you use ChartControl then you would have general key handling on the chart. Note that since ChartControl is already a property in the script, you would check if ChartControl != null in State.Historical. Then, you would subscribe to ChartControl.PreviewDownKey += ChartControl_PreviewDownKey;.

    See the help guide documentation below.
    ChartControl: https://ninjatrader.com/support/help...artcontrol.htm

    Let us know if we may assist further.
    Last edited by NinjaTrader_BrandonH; 03-15-2022, 08:39 AM.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    132 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X