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

Pair trade Profit Loss Sum

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

    Pair trade Profit Loss Sum

    Hello !!! i have litle troble to access two symbols profit loss sum
    if i enter
    if (Close[0] < Position.AvgPrice - ProfitS * TickSize)
    works fine but only one curency
    if i enter
    if (Closes[1][0] < Position.AvgPrice - ProfitS * TickSize)

    Exit at frst bar !!! dont count profit

    AvgPrice count for every curency separate or sum of prices?

    if (BarsInProgress==0)
    {
    entryOrder = EnterShort(0,Lot, "Sell");
    entryOrder = EnterShort(1,Lot, "Sell1");
    }
    if (Closes[0][0] < Position.AvgPrice - ProfitS * TickSize ||
    Closes[1][0] > Position.AvgPrice + StopS * TickSize)
    if (BarsInProgress==0 || BarsInProgress==1)
    {
    entryOrder = ExitShort(0,Lot,"Exit Short","Sell");
    entryOrder = ExitShort(1,Lot,"Exit Short1","Sell1");
    }

    #2
    Hello GainForex,

    Thank you for writing in.

    As you are utilizing multiple instruments in your strategies, you will want to use the Positions collection rather than the Position collection.

    The Positions collection holds an array of Position objects that represent positions managed by the strategy.

    More information about the Positions collection can be found in the NinjaTrader help guide at this link: https://ninjatrader.com/support/help...?positions.htm

    Utilizing Position.AvgPrice will obtain the average entry price for whatever Bars object has called OnBarUpdate(). As you would like to access the average entry price for the instrument at the index of 1, you would want to utilize Positions[1].AvgPrice.

    I would also suggest taking a look at the Multi-Time Frame & Instruments section of the help guide for further information about running a multiple instrument/multiple time frame strategy: https://ninjatrader.com/support/help...nstruments.htm

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,280 views
    0 likes
    Last Post Leafcutter  
    Started by WHICKED, Today, 12:45 PM
    2 responses
    19 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Tim-c, Today, 02:10 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    5 views
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    53 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Working...
    X