Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry Handling Problems

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

    Entry Handling Problems

    Hello,

    I am working on a strategy that has take profit 1 at 1:1 risk with 2:1 and b/e stop as a runner. However the code only seems to take on one contract per direction labeled "scalp", leaving the "runner" out. I have posted the relevant code for the task below. Any support here would be greatly appreciated.

    I have followed the examples NT has provided for working with multiple entries/exits to no avail.

    All entry conditions are working fine, just having issues with multiple contracts. Some entry logic was removed for simplicity.


    else if (State == State.DataLoaded)
    {
    SetProfitTarget("scalp", CalculationMode.Ticks, StopTicks);
    SetProfitTarget("runner", CalculationMode.Ticks, StopTicks * 2);

    SetStopLoss("scalp", CalculationMode.Ticks, StopTicks, false);
    }



    protected override void OnBarUpdate()
    {

    if (CurrentBar < BarsRequiredToTrade)
    return;

    MarketPosition macdBias = MacdBias();
    MarketPosition emaBias = EmaBias();

    if ((TriggerState >= 2)
    && (Position.MarketPosition == MarketPosition.Flat))
    {
    TriggerState = 0;
    }

    if (macdBias == MarketPosition.Long && emaBias == MarketPosition.Long && Position.MarketPosition == MarketPosition.Flat) {
    TriggerState = 1;
    EnterLong("scalp");
    EnterLong("runner");
    }
    else if (macdBias == MarketPosition.Short && emaBias == MarketPosition.Short && Position.MarketPosition == MarketPosition.Flat) {
    TriggerState = 1;
    EnterShort("scalp");
    EnterShort("runner");
    }


    if ((TriggerState == 1)
    && (Position.MarketPosition == MarketPosition.Long))
    {
    TriggerState = 2;
    StopPrice = (Position.AveragePrice + (StopTicks * TickSize)) ;
    TriggerPrice = (Position.AveragePrice + (StopTicks * TickSize)) ;

    }
    else if ((TriggerState == 1)
    && (Position.MarketPosition == MarketPosition.Short))
    {
    TriggerState = 2;
    StopPrice = (Position.AveragePrice + (StopTicks * TickSize)) ;
    TriggerPrice = (Position.AveragePrice - (StopTicks * TickSize)) ;
    }



    if ((TriggerState == 2)
    && (Close[0] >= TriggerPrice) && Position.MarketPosition == MarketPosition.Long)
    {
    TriggerState = 3;
    StopPrice = Position.AveragePrice + (beTicks * TickSize);
    }
    else if ((TriggerState == 2)
    && (Close[0] <= TriggerPrice) && Position.MarketPosition == MarketPosition.Short)
    {
    TriggerState = 3;
    StopPrice = Position.AveragePrice - (beTicks * TickSize);
    }



    if (TriggerState >= 2 && Position.MarketPosition == MarketPosition.Long)
    {
    SetStopLoss("runner", CalculationMode.Price, StopPrice, false);
    }
    else if (TriggerState >= 2 && Position.MarketPosition == MarketPosition.Short)
    {
    SetStopLoss("runner", CalculationMode.Price, StopPrice, false);
    }


    Thanks for taking the time to look at this!

    #2
    Hello cpbeamer,

    Have you set the entries per direction to 2 or the entry handling mode to UniqueEntries?




    I look forward to being of further assistance.

    Comment


      #3
      So I enabled both and the problem still persists. The runner contract is immediately stopped out upon taking up the position. It seems like an issue with the B/E stop loss rather than anything else. However, this is exactly how the example code worked it so I am at a loss

      Comment


        #4
        Hello cpbeamer,

        Having the order submitted but immediately stopped out would be a different issue than you described in post 1. If the order is not submitted at all and only 1 order is submitted that would relate to the entries per direction. If the order is submitted by immediately stopped out then that would very likely be the price you had used. You could try using a Print here to output the prices that you calculated. Alternatively you could try using a different calculation mode to see if the order does not get immediately stopped out to confirm its related to the price used.


        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X