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

build a strategy of two successive candles

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

    build a strategy of two successive candles

    Hello,

    I want to build a strategy based on counting candles so my strategy is working like that “if I have two successive red candles and next candle is green I know we can’t tell if we are having a green candle but let say if the price reach the open of the first two red candle we are counting it should take an operation at that pointe
    my problem here that my orders are noting filled in the same pointe as the strategy should be
    and some times the strategy ignore the condition that is should counter two candles first

    Click image for larger version

Name:	GOEI.jpg
Views:	33
Size:	71.8 KB
ID:	1292050


    this a part of the code that driving me crazy over 9 month , I'm still learinng but i need help
    Click image for larger version

Name:	first-set.jpg
Views:	32
Size:	39.6 KB
ID:	1292051



    XD
    Click image for larger version

Name:	set-2.jpg
Views:	31
Size:	36.5 KB
ID:	1292052

    ​thank you so much for reading and any help will be appreciated

    #2
    Hello lafava7118,

    I think you are wanting to have all of this in one condition set and to be using Open bars ago 2 is greater than Close bars ago 2, Open bars ago 1 is greater than Close bars ago 1, and Close bars ago 0 is greater than or equal to Open bars ago 0 (or bars ago 1 if you want to compare to the previous bar).

    With Calculate.OnPriceChange the currently updating bar can be checked on each price change.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      hi ChelseaB​ thank you for your reply even so , i change everything in the same set it will take the order randomly and i need it to fire the order in the same Candel "green" and if it dont meet the conditions it should not make any actions
      # how can i make it take actions in the same next candle "Green"
      # How to ignore the other single till I exit the operation
      i tried to use Nbarup and Nbardown but it didn't work for me


      Click image for larger version

Name:	actions.jpg
Views:	29
Size:	64.4 KB
ID:	1292098

      Comment


        #4
        Hello lafava7118,

        The "Next" candle doesn't exist. You can only check the currently building (or most recently closed candle) and the previous candles.

        To check if the current candle is green, use Close[0] > Open[0].

        To check if the previous candle is red, use Close[1] < Open[1].

        To check if the second prior candle is red, use Close[2] < Open[2]/
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by llanqui, Today, 03:53 AM
        0 responses
        3 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        10 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        14 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        11 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        14 views
        0 likes
        Last Post strategist007  
        Working...
        X