NexusFi: Find Your Edge


Home Menu

 





Pair trading Profit Loss


Discussion in NinjaTrader

Updated
    1. trending_up 1,909 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
ural01's Avatar
 ural01 
Colorado Springs, CO
 
Experience: Master
Platform: NinjaTrader
Broker: GAIN CAPITAL
Trading: Currency Futures
Posts: 24 since Mar 2010
Thanks Given: 9
Thanks Received: 0

Hello !!! i have a problem with pair trading strategy that after disconnect to IB wont close profit or stop positions

if (CurrentBars[0] < BarsRequiredToTrade || CurrentBars[1] < BarsRequiredToTrade)
return;

if (
PositionsAccount[0].MarketPosition == MarketPosition.Flat &&
PositionsAccount[1].MarketPosition == MarketPosition.Flat &&
myCci[0] <= myBuyLevel[0])

{
if (BarsInProgress ==0 || BarsInProgress ==1)
BuyOrder = EnterLong(0,Convert.ToInt32(FrontLegLot), "");
SellOrder = EnterShort(1,Convert.ToInt32(BackLegLot), "");
}
/////////////////////////////// Exit Buy Order ////////////////////////////////////

if (
PositionsAccount[0].MarketPosition == MarketPosition.Long &&
PositionsAccount[1].MarketPosition == MarketPosition.Short &&
((Closes[0][0] - PositionsAccount[0].AveragePrice) + (Closes[1][0] - PositionsAccount[1].AveragePrice) > Profit * TickSize ||
(Closes[0][0] - PositionsAccount[0].AveragePrice) + (Closes[1][0] - PositionsAccount[1].AveragePrice) < -Stop * TickSize))

{
if (BarsInProgress ==0 || BarsInProgress ==1)
ExitLong(0, FrontLegLot, "Exit Buy", "");
ExitShort(1, BackLegLot, "Exit Sell", "");


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Probability Collapse: Bitcoin $150k Craters from 15% to …
Prediction Markets & Event Contracts
CPI Eve: Fed Hike Odds Hold at 52% for the First Time, I …
Prediction Markets & Event Contracts
NYSE Owner ICE Invests in Crypto Exchange OKX at $25 Bil …
Cryptocurrency
Topstep Slashes XFA Payout Caps by Up to 60% -- Flagship …
Funded Trading Evaluation Firms
CME Lists U.S. Election Event Contracts as 2028 Democrat …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks




Last Updated on March 29, 2020


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts