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

Inverted Martingale

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

    Inverted Martingale


    Can some one please help me figure out how to build a strategy that sum my position size after each won and go back to 1 if I lost.
    When the first transaction reaches the Take profit line, the following transaction opens with an additional contract automatically, but if that transaction end up being negative all resets back to the initial 1 contract.

    Example:
    Open 1 contract (if won) open the second with 2 contracts ( if won ) open the third with 3 contracts ( if lost) go back to 1 contract for the following transaction.
    (1-2-3-4-5-6-7.....) in this sequence, not doubling.


    #2
    Hello Karelgp7,

    This thread will remain open who would like to create this logic or the script as a convenience to you.

    I am happy to assist you if you would like to create this script.

    Below is a link to a forum post with helpful information about getting started with NinjaScript.
    https://ninjatrader.com/support/foru...040#post786040

    To know if the last trade is profit or loss use the SystemPerformance collection.
    https://ninjatrader.com/support/help...erformance.htm
    https://ninjatrader.com/support/help...8/currency.htm

    For example:
    if (SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitCurrency > 0)
    {
    // trade was profitable
    }
    else if (SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitCurrency < 0)
    {
    // trade was a loss
    }

    You can increment an integer to increase the quantity size and reset this to 0 with other criteria.
    https://ninjatrader.com/support/foru...260#post812260
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by AttiM, 02-14-2024, 05:20 PM
    12 responses
    212 views
    0 likes
    Last Post DrakeiJosh  
    Started by cre8able, 02-11-2023, 05:43 PM
    3 responses
    236 views
    0 likes
    Last Post rhubear
    by rhubear
     
    Started by frslvr, 04-11-2024, 07:26 AM
    8 responses
    115 views
    1 like
    Last Post NinjaTrader_BrandonH  
    Started by stafe, 04-15-2024, 08:34 PM
    10 responses
    47 views
    0 likes
    Last Post stafe
    by stafe
     
    Started by rocketman7, Today, 09:41 AM
    3 responses
    11 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X