Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Thanks this helped, its workiong now

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by futtrader, 04-21-2024, 01:50 AM
      4 responses
      41 views
      0 likes
      Last Post futtrader  
      Started by Option Whisperer, Today, 09:55 AM
      1 response
      11 views
      0 likes
      Last Post bltdavid  
      Started by port119, Today, 02:43 PM
      0 responses
      3 views
      0 likes
      Last Post port119
      by port119
       
      Started by Philippe56140, Today, 02:35 PM
      0 responses
      4 views
      0 likes
      Last Post Philippe56140  
      Started by 00nevest, Today, 02:27 PM
      0 responses
      2 views
      0 likes
      Last Post 00nevest  
      Working...
      X