Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time Based Set Profit Target | Not working for me | please help

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

    Time Based Set Profit Target | Not working for me | please help

    Hi, I want to setup 3 time based take profit conditions however it is only detecting the first take profit of $1000.

    Please help

    Im currently in eastern time trading /NQ


    DateTime currentTimeEastern = Time[0].AddHours(-4);
    //Time Based Take Profit Conditions
    if (currentTimeEastern.TimeOfDay < new TimeSpan(11, 30, 0))
    {
    // Before 11:30 AM Eastern Time, set profit target to $1000
    SetProfitTarget("", CalculationMode.Currency, 1000);
    }
    else if (currentTimeEastern.TimeOfDay >= new TimeSpan(11, 30, 0) )
    {
    // Between 11:30 AM and 2:00 PM Eastern Time, set profit target to $400
    SetProfitTarget("", CalculationMode.Currency, 400);
    }
    else if (currentTimeEastern.TimeOfDay > new TimeSpan(14, 0, 0))
    {
    // After 2:00 PM Eastern Time, set profit target to $100
    SetProfitTarget("", CalculationMode.Currency, 100);
    }​

    #2
    Hello osmanigarces,

    Thank you for your post.

    Where is this code located? Is it in OnBarUpdate()?

    Also please note, set methods cannot be unset. To reset the ProfitTarget, you should before a new entry is placed and when the strategy is flat. From the Help Guide:

    "Should you call this method to dynamically change the target price in the strategy OnBarUpdate() method, you should always reset the target price / offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your profit target order on your next open position​"



    This sample script demonstrates modifying the price of profit target orders:



    Please let me know if you have any further questions.

    Comment


      #3
      Thanks this helped, its workiong now

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X