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

how to define 'the future' ?

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

    how to define 'the future' ?

    Hi

    i want to define a trailing stop if the market reach a risk reward of 1... so i define my rr1 and i have a problem when i want to define my limit, here my code

    // initiate a trailing stop on the top of the shooting after RR1 reached
    rr1 = Close[0]-((High[0]+ 3*TickSize)-Close[0])*1;
    rr1hit = (Low [bar] <= rr1);
    if (Position.MarketPosition == MarketPosition.Short)
    {

    if (rr1hit)
    {
    SetStopLoss(CalculationMode.Price, High[
    0]);
    }

    my problem on my code is bold... rr1hit = if the market hit the rr1 but i have a problem with the Low... i would to say Low of the market, but how can i write it...

    #2
    Thomas79,

    Not sure I follow you. If you want the Low of the market you can use Low[0]. I'm not sure what you are asking exactly.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      i want to write : if the market hit my limit rr1... so i have to write (something define the market <= rr1)

      if i write :
      Low [0] = that not works because this is the low of the bar where i have my signal
      Low [CurrentBar] = that not work because avoid me my trailing stop the bar after

      i just want to say, if my market hit the limit, put the trailing stop on the top of my signal and not move it...

      Comment


        #4
        Originally posted by Thomas79 View Post
        i want to write : if the market hit my limit rr1... so i have to write (something define the market <= rr1)

        if i write :
        Low [0] = that not works because this is the low of the bar where i have my signal
        Low [CurrentBar] = that not work because avoid me my trailing stop the bar after

        i just want to say, if my market hit the limit, put the trailing stop on the top of my signal and not move it...
        What do you mean by market? The last traded price? If yes, the you should use Close[0].
        RayNinjaTrader Customer Service

        Comment


          #5
          i just want to say, if the market hit the limit, put the trailing stop on the top of my signal

          market = the quote = the trade price

          not only the last trade price... the thing is that if i write low [0] it take the low of my signal... not the future market

          Comment


            #6
            Thomas,

            as long as the current bar is not finished and a different price is traded you will get calls into OnBarUpdate() and Close[0] will reflect the latest traded price.
            (all this with CalculateOnBarClose=false)
            If you need current Bid and Ask you should consider
            OnMarketData() which will be called also when Bid and Ask changes.
            Usually this is not necessary.


            In your example you would use
            if(Close[0]-entryprice) > InitialRisk) SetStopLoss(CalcMode.Price,Close[0]-InitialRisk);
            andreas

            Comment


              #7
              Hi, that not works... trailing stop is not working

              here my script

              // initiate a trailing stop on the top of the shooting after Risk Reward 1 reached
              // here the definition of the risk riward of 1 with High[0] the high of the shooting star
              // and High + 3 ticks the initial stop and close [0] the entry level
              rr1 = Close[0]-((High[0]+ 3*TickSize)-Close[0])*1;
              // here the risk reward of one hit
              rr1hit = (Low [0] <= rr1);
              DrawLine(
              "RR1" + CurrentBar,false, 10, rr1, 0, rr1, Color.Green, DashStyle.Dot,2);

              if (Position.MarketPosition == MarketPosition.Short)
              {
              // here the script for the trailing stop
              if (rr1hit)
              {
              SetTrailStop(CalculationMode.Price, High[
              0]);
              }


              and here the result


              Comment


                #8
                I cannot help you further, no time ...

                Good luck
                A

                Comment


                  #9
                  Thomas79,

                  Unfortunately you cannot use a trailing stop with CalculationMode.Price. Please try a different mode.
                  Josh P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Mestor, 03-10-2023, 01:50 AM
                  16 responses
                  388 views
                  0 likes
                  Last Post z.franck  
                  Started by rtwave, 04-12-2024, 09:30 AM
                  4 responses
                  31 views
                  0 likes
                  Last Post rtwave
                  by rtwave
                   
                  Started by yertle, Yesterday, 08:38 AM
                  7 responses
                  29 views
                  0 likes
                  Last Post yertle
                  by yertle
                   
                  Started by bmartz, 03-12-2024, 06:12 AM
                  2 responses
                  22 views
                  0 likes
                  Last Post bmartz
                  by bmartz
                   
                  Started by funk10101, Today, 12:02 AM
                  0 responses
                  7 views
                  0 likes
                  Last Post funk10101  
                  Working...
                  X