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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X