Announcement

Collapse
No announcement yet.

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 toughiee, Today, 12:04 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post toughiee  
                  Started by vdoan20, Yesterday, 08:30 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post vdoan20
                  by vdoan20
                   
                  Started by gupagoer, Yesterday, 07:42 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post gupagoer  
                  Started by Holligoly, Yesterday, 05:13 PM
                  2 responses
                  11 views
                  0 likes
                  Last Post Holligoly  
                  Started by Raginpower, Yesterday, 01:53 PM
                  0 responses
                  14 views
                  0 likes
                  Last Post Raginpower  
                  Working...
                  X