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 code condition about wick and tail?

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

    How to code condition about wick and tail?

    I am not a programmer, but I have adjusted a code template of a previously existing strategy code. I would like the strategy to take a trade on the third bar after HMAinflective and SmartThickness cross. I was able to get the strategy to do this. But I would like to add a condition to not take the trade if there is a wick or tail on that bar. Is there a way to do this?

    So the strategy would take a trade on the third bar after HMAinflective and SmartThickness cross UNLESS there is a wick or tail on on that third bar.

    Any advice?

    #2
    Hello defo1,

    Thanks for your post and welcome to the forums.

    I am assuming your definition of a wick is the line at the top of the candle regardless of being an up or down candle and a tail is the line below the candle regardless if it is an up or down candle. Based on that definition then you can perform these type checks:

    To check for a wick:
    In the case of an Up bar, if the High[0] is > Close[0]
    In the case of the Down bar, if the High[0] is > Open[0]

    To check for a tail:
    In the case of an Up bar, if the Low[0] is < Open[0]
    In the case of a Down bar, if the Low[0] is < Close[0]
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by defo1 View Post
      I am not a programmer, but I have adjusted a code template of a previously existing strategy code. I would like the strategy to take a trade on the third bar after HMAinflective and SmartThickness cross. I was able to get the strategy to do this. But I would like to add a condition to not take the trade if there is a wick or tail on that bar. Is there a way to do this?

      So the strategy would take a trade on the third bar after HMAinflective and SmartThickness cross UNLESS there is a wick or tail on on that third bar.

      Any advice?
      Code:
      bool HasNoWickOrTail = ((High[0] == Math.Max(Close[0], Open[0])) && (Low[0] == Math.Min(Close[0], Open[0])));
      
      if (EntryConditions && HasNoWickOrTail){//trade}
      where EntryConditions is your current code for entering. In other words you need to define the bool flag HasNoWickOrTail, and then add it to your current entry conditions as a gate.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by maybeimnotrader, Yesterday, 05:46 PM
      1 response
      18 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Perr0Grande, Yesterday, 08:16 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by f.saeidi, Yesterday, 08:12 AM
      3 responses
      25 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by algospoke, Yesterday, 06:40 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by quantismo, Yesterday, 05:13 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X