Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding to postion

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

    Adding to postion

    this is the code that I have write now
    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]
    [SIZE=2][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] (Position.GetProfitLoss(Close[[/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000]], PerformanceUnit.Currency) <= [/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]200[/COLOR][/SIZE][/FONT]
    [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]&& Position.MarketPosition == MarketPosition.Long)[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
    [SIZE=2][FONT=Courier New]EnterLong([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
    [/SIZE][/FONT]
    however what I noticed is Ninjatrader takes a trade every new bar. (See Picture)
    What I want Ninjatrader to do is
    When a unrealized loss of 200 ---> add 1 more contract(only). So now I should only be long 2 contracts in the market. Furthermore, If the price continues to go lower, and now my loss is $1000 unrealized with the 2 contracts that i have opened, add 3 more contract. so a Total of 5. .
    ===================================
    What I think ninjatrader does it everytime it see a 200 losss it continues adding. so by end of the day i might be long 30 contracts, 1 tick move down and it would add again. What I want is ninjatrader to Add at a -200 loss once and again only ONCE at -1000 losss.
    Attached Files

    #2
    Hello wallsteetking,
    You have coded current profit less than 200. If you want to evaluate current loss then please replace your code with the below:
    Code:
    if (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) <= -200  //mind the minus before 200
    Also how many contract NinjaTrader will add will depend on the entry handling rules.


    I would suggest to use Unique entry names for each entries and set the Entries per direction to 1 so that there are no unwanted positions.
    JoydeepNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,404 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    95 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    8 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    159 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    8 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X