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 inanazsocial, Today, 01:15 AM
    0 responses
    2 views
    0 likes
    Last Post inanazsocial  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    5 responses
    22 views
    0 likes
    Last Post trilliantrader  
    Started by Davidtowleii, Today, 12:15 AM
    0 responses
    3 views
    0 likes
    Last Post Davidtowleii  
    Started by guillembm, Yesterday, 11:25 AM
    2 responses
    9 views
    0 likes
    Last Post guillembm  
    Started by junkone, 04-21-2024, 07:17 AM
    9 responses
    71 views
    0 likes
    Last Post jeronymite  
    Working...
    X