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 Waxavi, Today, 02:10 AM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Kaledus, Today, 01:29 PM
      5 responses
      13 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Waxavi, Today, 02:00 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by alifarahani, Today, 09:40 AM
      5 responses
      23 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X