create the exact interactive brokers app : START → INITIAL SETUP
The process begins with a daily CSV entry sheet that requires manual input of:

Ticker symbol (Stock or Futures with options)
Position type (Long or Short)
Initial stop loss for calculating shares
Full or partial take profit exit criteria
Manual adjustment stop loss constants for all trades
Risk amount ($) for position size calculation
Percentage (%) for entry price range
Other parameters (detailed on next page)
TICKER API CALCULATIONS
For each ticker symbol, the API performs calculations including:

Price range for entry
Mid orders based on previous day's High/Low (varies depending on Short/Long position)
Share quantity calculations based on Risk and Initial stop loss
ORDER CREATION AND MONITORING LOOP

API creates conditional orders in Interactive Brokers (IB)
System checks if order was filled in IB
If NO: Returns to API to adjust/delete conditional orders based on entry sheet (daily update)
If YES: Proceeds to profit management
PROFIT MANAGEMENT BRANCH
The system branches based on Full or Partial Take Profit Exit:

FULL TAKE PROFIT EXIT PATH:

API creates take-profit and stop-loss orders based on fill price
Uses initial stop loss from entry sheet
Stop losses can be manually adjusted during trade progress
Monitors for either Stop-Loss or Take-Profit trigger in IB
PARTIAL TAKE PROFIT EXIT PATH:

API creates take-profit for partial position
Based on fill price and formula using initial stop loss
Maintains stop loss for full position
Stop loss can be manually adjusted during trade
Monitors for Stop-Loss or Take-Profit trigger in IB
FINAL STAGES
If Take-Profit triggers:

API creates trailing stop for remaining half position
Based on manual adjustment of stop loss
If Stop-Loss triggers:

Proceeds to final recording
TRADE RECORDING
API creates comprehensive record including:

Entry price
Exit price(s)
Number of shares
Entry/exit dates
Profit/Loss
Commissions
The process then ends (END)


EXAMPLE – Trade Long, ﬂip logic for Short

Default settings that are applied to all trades, but can be manually adjusted for a given trade

   •    Risk $ to calculate position size: $2,000 [1]
   •    % to calculate price range for entry 1: 2% [2]
   •    % to calculate price range for entry 2: 25% [3]
   •    Stop loss hours: Regular Trading Hours (RTH)
   •    Take Proﬁt hours: Extended Trading Hours (e.g. outside RTH)
   •    Entry type hours: RTH
   •    Entry Time in Force: Good for day (Day)

Entry criteria (Ticker, Long/Short, SL, TP share%, manual adjustment stop loss, IB account)

   •    SPX [4]
   •    Long [5]
   •    5760 [6]
   •    50% [7]
   •    10% [8]
   •    3429294

API calculates:

    •   Previous day SPX High: $5,850 [9]
    •   Risk per contract (given that [5] is L, then Risk [9]-[6]): $90 [10]
    •   Price for entry 1 ([2]*[10]+[9]): $5,851.80 [11]
    •   Price for entry 2 ([3]*[10]+[9]): $5,872.50 [12]
    •   Contracts to buy (Rounddown([1]/[10])): 21 [13]

API creates Order Ticket in TWS

    •   [4] SPX mkt order
    •   [13] 21 contracts
    •   [11] Conditional entry low price
    •   [11] Conditional entry high price

Order is successful - API creates SL/TP in TWS

    •   Avg. entry at $5855 [14]
    •   Risk ([14]-[6]): $95 [15]
    •   TP (1R): $5,950 for half the position (see [7])
    •   SL ([14]-[8]*[15]): $5,845.50 [16]

Take proﬁt hit – API create SL based on manual input

    •   No TP
    •   SL based on daily manual adjustments
Active Risk Summary Tab

For each active trade calculate:

   •   Risk: Difference between Entry [14] and Stop Loss [16]. Note, if this is positive, then zero risk
   •   Stocks – Sector

Provide Summary Table of Active Risk by

   •   Overall Portfolio
   •   Indices
   •   Futures
   •   Sectors