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

Adding MFI Filter As An Option To Exisiting Condition

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

    Adding MFI Filter As An Option To Exisiting Condition

    Hi
    I want to add use MFI filter as an option for this buy logic condition. How Do i implement it? Do i need another If statement or Switch statement? is there an example? Right now its complaining that method name is expected.Thank you
    (MFI1[0] >= LevelForLongs)


    Trade34BCCI = true;

    LevelForLongs = 1;
    LevelForShorts = 1;
    MFIPeriod = 1;​

    MFI1 = MFI(Close, Convert.ToInt32(MFIPeriod));

    else if (Trade34BCCI
    && (UseMFIFIlter == false)
    && emaAngulation > EMAAngulation * TickSize // EMA Angulation is greater then (x)
    && emaAngulationXBarsBefore > EMAAngulationXBarsBefore * TickSize // EMA Angulation X bars before - angulation not on current bar but 5 bars before for example
    && Close[1] < Open[1] // previous bar bearish
    && Low[0] < Low[1] // and low of signal bar is lower then previous bar
    && Low[0] < slowEMA[0] && Close[0] > slowEMA[0] + ABEMA34BCCI * TickSize
    && !(Open[1] < High[1] && Close[0] < High[1])

    (UseMFIFIlter == true)
    && emaAngulation > EMAAngulation * TickSize // EMA Angulation is greater then (x)
    && emaAngulationXBarsBefore > EMAAngulationXBarsBefore * TickSize // EMA Angulation X bars before - angulation not on current bar but 5 bars before for example
    && Close[1] < Open[1] // previous bar bearish
    && Low[0] < Low[1] // and low of signal bar is lower then previous bar
    && Low[0] < slowEMA[0] && Close[0] > slowEMA[0] + ABEMA34BCCI * TickSize
    && !(Open[1] < High[1] && Close[0] < High[1])
    && (MFI1[0] >= LevelForLongs))
    {
    entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, TradeSize, 0, 0, "", "34BCCI");

    return;
    }​
    Last edited by tkaboris; 02-12-2023, 08:05 AM.

    #2
    Hello tkaboris,

    Thanks for your post.

    The MFI() method will return a double value, such as 60.12, which could be used in a comparison in your script.

    You could print out the MFI() method outside of your condition to place an order along with the Time[0] of the bar to see how the MFI() value is evaluating.

    More information about the MFI() method and sample code could be seen in the help guide page linked below.

    MFI(): https://ninjatrader.com/support/help..._index_mfi.htm

    You could also set up a condition using the MFI indicator in a Strategy Builder strategy and click the 'View code' button to see the generated syntax.

    Strategy Builder: https://ninjatrader.com/support/help...gy_builder.htm

    Ultimately, debugging prints should be added to the script to see exactly how the script is behaving and calculating logic.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.

    https://ninjatrader.com/support/foru...121#post791121

    Please let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Option Whisperer, Today, 09:55 AM
    1 response
    11 views
    0 likes
    Last Post bltdavid  
    Started by port119, Today, 02:43 PM
    0 responses
    1 view
    0 likes
    Last Post port119
    by port119
     
    Started by Philippe56140, Today, 02:35 PM
    0 responses
    3 views
    0 likes
    Last Post Philippe56140  
    Started by 00nevest, Today, 02:27 PM
    0 responses
    2 views
    0 likes
    Last Post 00nevest  
    Started by Jonafare, 12-06-2012, 03:48 PM
    5 responses
    3,986 views
    0 likes
    Last Post rene69851  
    Working...
    X