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

Change Target Price after Multi Touch w/no fill

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

    Change Target Price after Multi Touch w/no fill

    Hi.

    Should this code work? I am trying to create a code in my strategy with a multi time frame with the secondary time frame being 1 second so that it can count how many times the price hit the target during the main bar for each second. So say it hit the target 20 times in the last 20 seconds without filling the strategy moves the profit target from 2 ticks to 1 tick or even breakeven. Do I have it right or am I even close? I tried to make the Close [1][0] like that but it wouldn't allow it so I was hoping that if I used the BarsInProgress==1 it would use seconds instead of the main timeframe of say 1 minute. It's a bit hard to backtest so I wanted to know if I am even close before I try to figure the testing part out. Thank you for any help.

    if (BarsInProgress == 1)
    {
    if (Close[0] == Position.AvgPrice +2 * TickSize)
    {
    TargetTouch = TargetTouch +1;
    }
    if (TargetTouch >= 20)
    {
    SetProfitTarget("Long 1a", CalculationMode.Price, Position.AvgPrice +1 * TickSize);
    }
    }

    #2
    Hi cre8it8, without having tested it I think the concept is fine, Close[0] in BarsInProgress 1 would be the added series price. However if you wish to backtest most accurately by executing on the 1 second series, then please use the Exit() methods for your target / stop orders, you can designate a BarsInProgress parameter here to submit the order to.

    ExitLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName, string fromEntrySignal)
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the info!

      Comment


        #4
        Originally posted by cre8it8 View Post
        Hi.

        Should this code work? I am trying to create a code in my strategy with a multi time frame with the secondary time frame being 1 second so that it can count how many times the price hit the target during the main bar for each second. So say it hit the target 20 times in the last 20 seconds without filling the strategy moves the profit target from 2 ticks to 1 tick or even breakeven. Do I have it right or am I even close? I tried to make the Close [1][0] like that but it wouldn't allow it so I was hoping that if I used the BarsInProgress==1 it would use seconds instead of the main timeframe of say 1 minute. It's a bit hard to backtest so I wanted to know if I am even close before I try to figure the testing part out. Thank you for any help.

        if (BarsInProgress == 1)
        {
        if (Close[0] == Position.AvgPrice +2 * TickSize)
        {
        TargetTouch = TargetTouch +1;
        }
        if (TargetTouch >= 20)
        {
        SetProfitTarget("Long 1a", CalculationMode.Price, Position.AvgPrice +1 * TickSize);
        }
        }
        Comparing doubles can be tricky. You may want to Round2TickSize, the Position.AvgPrice +2 * TickSize quantity.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Austiner87, Today, 03:42 PM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by cshox, Today, 11:11 AM
        2 responses
        15 views
        0 likes
        Last Post cshox
        by cshox
         
        Started by algospoke, Today, 06:53 PM
        0 responses
        9 views
        0 likes
        Last Post algospoke  
        Started by mlprice12, 12-21-2021, 04:55 PM
        3 responses
        297 views
        0 likes
        Last Post paypachaysa  
        Started by lorem, 04-25-2024, 09:18 AM
        20 responses
        86 views
        0 likes
        Last Post lorem
        by lorem
         
        Working...
        X