Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Indicator as Condition for Profit

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

    Adding Indicator as Condition for Profit

    Hi,

    can you tell me is it possible in the strategy bellow to link my profit taking with the
    following condition: MACD(BarsArray[1], 12, 26, 9).Diff[0] < 0 instead with the
    existing condition execution.Order.AvgFillPrice + (profit * TickSize)



    /* We advise monitoring OnExecution to trigger submission of stop/target orders instead of OnOrderUpdate() since OnExecution() is called after OnOrderUpdate()
    which ensures your strategy has received the execution which is used for internal signal tracking. */
    if (entryOrder != null && entryOrder == execution.Order)
    {
    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
    {
    // Stop-Loss order 4 ticks below our entry price
    stopOrder = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + (initialStopDistance * TickSize), "MyStop", "MyEntry");

    // Target order 8 ticks above our entry price
    targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + (profit * TickSize), "MyTarget", "MyEntry");

    }
    }

    // Reset our stop order and target orders' IOrder objects after our position is closed.
    if ((stopOrder != null && stopOrder == execution.Order) || (targetOrder != null && targetOrder == execution.Order))
    {
    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled)
    {
    stopOrder = null;
    targetOrder = null;
    }
    }

    #2
    flexi, that would be possible yes - which order type would you want to use if the condition is fulfilled? You would not monitor for this price / indicator condition based exit though in OnExecution() but your OnBarUpdate() method then.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    639 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    572 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X