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 WHICKED, Today, 12:45 PM
    2 responses
    18 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by GussJ, 03-04-2020, 03:11 PM
    15 responses
    3,275 views
    0 likes
    Last Post xiinteractive  
    Started by Tim-c, Today, 02:10 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    3 views
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    51 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Working...
    X