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 Shansen, 08-30-2019, 10:18 PM
    24 responses
    938 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    3 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    2 views
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    27 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Working...
    X