Announcement

Collapse
No announcement yet.

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.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    89 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X