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

Is this a right syntax?

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

    Is this a right syntax?

    HI i have if statment and 2 OR statements, first two seems working however I cant execute || ((Trade34B == true) && (UseVolFilter == true)) statement, it doesnt evaluate to true.
    Code:
    if (longsOn)
                    {
    
                        if (
                            ((Trade34B == true) && (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] + ABEMA34B * TickSize)
                            && !(Open[1] < High[1] && Close[0] < High[1])
                            && (EMA(200)[0] < slowEMA[0])
                            && (Close[0] < CurrentDayOHL().CurrentHigh[4] - DistanceToOHL * TickSize)  // distance to be greater then close of signal bar and current high
    
                            || ((Trade34B  == true) && (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] + ABEMA34B * TickSize)
                            && !(Open[1] < High[1] && Close[0] < High[1])
                            && (EMA(200)[0] < slowEMA[0])
                            && (MFI1[0] >= LevelForLongs)
    
                            || ((Trade34B  == true) && (UseVolFilter == 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] + ABEMA34B * TickSize)
                            && !(Open[1] < High[1] && Close[0] < High[1])
                            && (EMA(200)[0] < slowEMA[0])
                            && (VOL1[0] >= VolReading  )
                            )
    
                        {    
                            entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, TradeSize, 0, 0, "", "34B");
    
                            return;
                        }​

    #2
    Hello tkaboris,

    Thanks for your post.

    To understand how a script is behaving, debugging prints would need to be added to the script one line above your conditions that prints out each value being used in your condition to place an order along with the Time[0] of the bar. This allows you to understand how each value is evaluating to see if the condition is becoming true or false.

    Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

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

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

    Let us know if we may assist further.​
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      If I place print before condition, it gives an error. I know its not the right syntax
      if (longsOn)
      {

      if (
      Print("34B No filter")
      ((Trade34B == true) && (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] + ABEMA34B * TickSize)
      && !(Open[1] < High[1] && Close[0] < High[1])
      && (EMA(200)[0] < slowEMA[0])
      && (Close[0] < CurrentDayOHL().CurrentHigh[4] - DistanceToOHL * TickSize)) // distance to be greater then close of signal bar and current high

      Comment


        #4
        Hello tkaboris,

        Thanks for your note.

        The Print statement would need to be added outside of your condition. You would also need to print out each value in your condition along with the Time (Time[0]) of the bar to see how each individual value in the condition is evaluating. This means the print would need to be placed outside of your if condition.

        For example, the code you shared would look something like this:

        Print("34B No filter" + " Trade34B: " + Trade34B + " UseMFIFilter: " + UseMFIFilter) //Note that every value in the condition should be printed out to see how they are evaluating.
        if (
        ((Trade34B == true) && (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] + ABEMA34B * TickSize)
        && !(Open[1] < High[1] && Close[0] < High[1])
        && (EMA(200)[0] < slowEMA[0])
        && (Close[0] < CurrentDayOHL().CurrentHigh[4] - DistanceToOHL * TickSize)) // distance to be greater then close of signal bar and current high​


        A simple example of using a print outside of a condition can be seen below. Note that we print the values in the condition above the condition.

        Code:
        Print("Close price is: " + Close[0] + " Open price is: " + Open[0]);
        if (Close[0] > Open[0])
           EnterLong();​
        Please review the forum thread linked in post # 2 demonstrates how to go about using prints to understand a strategy's behavior.

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

        Comment


          #5
          Make sure you enclose everything on each side of the OR (||). Try something like this:
          if (
          ((Trade34B == true) && (UseMFIFIlter == false) //Removed parenthesis
          && (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] + ABEMA34B * TickSize)
          && !(Open[1] < High[1] && Close[0] < High[1])
          && (EMA(200)[0] < slowEMA[0])
          && (Close[0] < CurrentDayOHL().CurrentHigh[4] - DistanceToOHL * TickSize) ) //<== Added parenthesis to enclose all conditions

          || ((Trade34B == true) && (UseMFIFIlter == true) //Removed parenthesis
          && (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] + ABEMA34B * TickSize)
          && !(Open[1] < High[1] && Close[0] < High[1])
          && (EMA(200)[0] < slowEMA[0])
          && (MFI1[0] >= LevelForLongs) ) //<== Added parenthesis to enclose all conditions

          || ((Trade34B == true) && (UseVolFilter == true) //Removed parenthesis
          && (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] + ABEMA34B * TickSize)
          && !(Open[1] < High[1] && Close[0] < High[1])
          && (EMA(200)[0] < slowEMA[0])
          && (VOL1[0] >= VolReading ) ) //<== Added parenthesis to enclose all conditions
          )

          {
          entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, TradeSize, 0, 0, "", "34B");

          return;
          }​​
          eDanny
          NinjaTrader Ecosystem Vendor - Integrity Traders

          Comment


            #6

            Thank you, its helpful,

            I get these in output, I see that it sees mfi value, however, when i enable true MFI filter with redicilous off numbers there is no difference between with MFI filter or without MFI filter, so that says MFI filter is not working. I enabled all filters to true here

            What would be my next step?
            34B Trade34B: True UseVolFilter: True MFI Filter:True Stoch Filter:True Time: 2/16/2023 2:25:22 PM Volume: 934 MFI Value: 62.5812951174722 StochValue: 76.6666666666663
            34B Trade34B: True UseVolFilter: True MFI Filter:True Stoch Filter:True Time: 2/16/2023 2:25:47 PM Volume: 1181 MFI Value: 62.2591465403064 StochValue: 86.6666666666662
            34B Trade34B: True UseVolFilter: True MFI Filter:True Stoch Filter:True Time: 2/16/2023 2:26:21 PM Volume: 1643 MFI Value: 81.4199810937846 StochValue: 94.444444444444
            Enabling NinjaScript strategy 'BounceTraderAlgoV3/284762096' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=True MaxRestarts=4 in 5 minutes
            34B Trade34B: True UseVolFilter: True MFI Filter:True Stoch Filter:True Time: 2/16/2023 2:35:21 PM Volume: 16443 MFI Value: 92.2952176054865 StochValue: 98.8888888888885
            34B Trade34B: True UseVolFilter: True MFI Filter:True Stoch Filter:True Time: 2/16/2023 2:36:11 PM Volume: 2045 MFI Value: 93.0875224318023 StochValue: 99.9999999999996
            34B Trade34B: True UseVolFilter: True MFI Filter:True Stoch Filter:True Time: 2/16/2023 2:36:13 PM Volume: 534 MFI Value: 93.9667437386545 StochValue: 99.9999999999996​

            Comment


              #7
              Hello tkaboris,

              Thanks for your note.

              I do not see any condition in the code you shared that checks what the MFI value is in the conditions to place the order, only a condition checking if the bool 'UseMFIFilter' is true or false.

              If the 'UseMFIFilter' bool is false, all of the other conditions in that section of code seen below would need to be true for the script to place the order.

              if(
              ((Trade34B == true) && (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] + ABEMA34B * TickSize)
              && !(Open[1] < High[1] && Close[0] < High[1])
              && (EMA(200)[0] < slowEMA[0])
              && (Close[0] < CurrentDayOHL().CurrentHigh[4] - DistanceToOHL * TickSize) )


              Or, if the 'UseMFIFilter' variable is true and all the other conditions in the same section of code below are true, the order would be submitted.

              ((Trade34B == true) && (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] + ABEMA34B * TickSize)
              && !(Open[1] < High[1] && Close[0] < High[1])
              && (EMA(200)[0] < slowEMA[0])
              && (MFI1[0] >= LevelForLongs) )


              If any of the other conditions are not evaluating true, the order will not be placed since all the conditions in that section are not true.

              Further debugging would need to be done by adding more prints to determine how each value is being evaluated and how the logic throughout your script is behaving.

              Let me know if I may assist further.​​
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                hello,

                I have modified syntax but i think i created new trades and I wanted to create a filters for the same type of trades. if i run them individually they work alright, My main trade is 34B and useMFI, useVOl and use Stoch as filters but now its seperate trades... Is this how its suppose to be?

                My main trade is 34B and on backtest, if i select only 34B i get 66 trades, if i select 34B and StochFilter then i have 115 trades. Obviosly its not hwo it suppose to be because stochfilter should further limit trades but it increased. i am doing somethign wrong

                Code:
                if (longsOn)
                                {
                //                    Print("34B " + " Trade34B: " + Trade34B + " UseVolFilter: "
                //                    + UseVolFilter + " MFI Filter:" + UseMFIFIlter + " Stoch Filter:" +
                //                    UseStochFilter + " Time: " + Time[0]
                //                    +" Volume: " + VOL1[0] + " MFI Value: " + MFI1[0] + " StochValue: " + StochasticsFast1.D[0]);
                                    if (
                
                                        ((Trade34B  == true) && (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] + ABEMA34B * TickSize)
                                        && !(Open[1] < High[1] && Close[0] < High[1])
                                        && (EMA(200)[0] < slowEMA[0])
                                        && (MFI1[0] >= LevelForLongs)))
                
                                        {    
                                        entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, TradeSize, 0, 0, "", "34B");
                                        Print("34B: true, MFIFilter: True" + "Close price is: " + Close[0] + " Open price is: " + Open[0] );
                                        return;                    
                                        }
                
                                        else if (
                
                                         ((Trade34B  == true) && (UseVolFilter == 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] + ABEMA34B * TickSize)
                                        && !(Open[1] < High[1] && Close[0] < High[1])
                                        && (EMA(200)[0] < slowEMA[0])
                                        && (VOL1[0] >= VolReading  )))
                
                                        {    
                                        entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, TradeSize, 0, 0, "", "34B");
                                        Print("34B: true, VOLFilter: True" + "Close price is: " + Close[0] + " Open price is: " + Open[0] );
                                        return;                    
                                        }
                
                                        else if (
                                        ((Trade34B  == true) && (UseStochFilter == 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] + ABEMA34B * TickSize)
                                        && !(Open[1] < High[1] && Close[0] < High[1])
                                        && (EMA(200)[0] < slowEMA[0])
                                        && (StochasticsFast1.D[0] <= StochShortLevels)))
                
                                        {    
                                        entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, TradeSize, 0, 0, "", "34B");
                                        Print("34B: true, StochFilter: True" + "Close price is: " + Close[0] + " Open price is: " + Open[0] );
                                        return;                    
                                        }
                
                                        else if (
                                        ((Trade34B == true && UseStochFilter == false && UseVolFilter == false && 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] + ABEMA34B * TickSize)
                                        && !(Open[1] < High[1] && Close[0] < High[1])
                                        && (EMA(200)[0] < slowEMA[0])
                                        && (Close[0] < CurrentDayOHL().CurrentHigh[4] - DistanceToOHL * TickSize)))  // distance to be greater then close of signal bar and current high)
                
                                    {    
                                        entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, TradeSize, 0, 0, "", "34B");
                                        Print("34B no filters" + " Close price is: " + Close[0] + " Open price is: " + Open[0] );
                                        return;
                
                                    }​


                Last edited by tkaboris; 02-17-2023, 07:15 AM.

                Comment


                  #9
                  Hello tkaboris,

                  Thanks for your notes.

                  If you would like to enter a trade based on possible conditions, you would use an if else if statement. For example, see below for a simple example of this.

                  if (Close[0] > Open[0])
                  {
                  EnterLong();
                  Print("Long trade placed");
                  }
                  else if (Close[0] < Open[0])
                  {
                  EnterShort();
                  Print("Short trade placed");
                  }
                  else if (Close[0] == Open[0])
                  {
                  Print("Close price is equal to Open price. Trade not placed.");
                  }


                  If the strategy does not behave and place orders as you expect it to, you must further debug your strategy by adding more prints and reducing code to understand exactly how the script behaves. Note that in the Support department it is against our policy to create, modify, or debug a script on your behalf. It would be up to you to come up with the logic and debug the script so that it functions as you are expecting it to.

                  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 review the help guide document on the differences on real-time vs backtest (historical).
                  http://ninjatrader.com/support/helpG...ime_vs_bac.htm​​

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

                  Comment


                    #10
                    Hi thank you for your response. I understand the logic for if then or for above conditions. What would be the logic for if then statement but with a filter? Would this be a right syntax to create a filter?
                    Trade long and trade long with filter? For some reason, if i have this logic , trade with filter opens more trades then without filter

                    if (Close[0] > Open[0])
                    || ((Close[0] > Open[0]) && (Close[0] > EMA20[0]))

                    {
                    EnterLong();
                    Print("Long trade placed");
                    }
                    else if (Close[0] < Open[0])
                    {
                    EnterShort();
                    Print("Short trade placed");
                    }
                    else if (Close[0] == Open[0])
                    {
                    Print("Close price is equal to Open price. Trade not placed.");
                    }

                    Comment


                      #11
                      Hello tkaboris,

                      Thanks for your note.

                      No, you are missing some opening and closing parenthesis in the code you shared which would throw compile errors. Instead, it would look something like this:

                      if (
                      (Close[0] > Open[0])
                      || ((Close[0] > Open[0]) && (Close[0] > EMA20[0])))​
                      {
                      EnterLong();
                      Print("Long trade placed");
                      }
                      ...​


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

                      Comment


                        #12
                        Thank you. I still dont understand, with this current code, If i only select trade with no filter (last one) i get 15 trades for example, if I select No Filter Trade + Stoch Filter, it opens like 25 trades. What Am i doing wrong? Filter should limit further trades but it instead gives our more trades..
                        Code:
                        if (longsOn)
                                        {
                        
                                            if (
                                                //((Trade34B == true)
                        
                                                // MFI Filter
                                                ((emaAngulation > EMAAngulation * TickSize) // EMA Angulation is greater then (x)
                                                && (Trade34B == true)
                                                && (UseMFIFIlter == true) && (UseStochFilter == false) && (UseMFIFIlter == false)
                                                && (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] + ABEMA34B * TickSize
                                                && !(Open[1] < High[1] && Close[0] < High[1])
                                                && (EMA(200)[0] < slowEMA[0])
                                                && (MFI1[0] <= LevelForLongs))
                        
                                                // Vol Filter
                                                || ((Trade34B == true)
                                                && (UseVolFilter == true) && (UseStochFilter == false) && (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] + ABEMA34B * TickSize
                                                && !(Open[1] < High[1] && Close[0] < High[1])
                                                && (EMA(200)[0] < slowEMA[0])
                                                && (VOL1[0] >= VolReading))
                        
                                                // Stoch Filter
                                                || ((emaAngulation > EMAAngulation * TickSize) // EMA Angulation is greater then (x)
                                                && (Trade34B == true) && (UseStochFilter == true) && (UseVolFilter == false) && (UseMFIFIlter == false)// keep    
                                                && (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] + ABEMA34B * TickSize
                                                //&& !(Open[1] < High[1] && Close[0] < High[1])
                                                && EMA(200)[0] < slowEMA[0]
                                                && (StochasticsFast1.D[0] <= StochLongLevels))
                        
                                                // No Filter Plain 34B
                                                || ((emaAngulation > EMAAngulation * TickSize) // EMA Angulation is greater then (x)
                                                && (Trade34B == true) && (UseStochFilter == false) && (UseVolFilter == false) && (UseMFIFIlter == false)
                                                && (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] + ABEMA34B * TickSize
                                                //&& !(Open[1] < High[1] && Close[0] < High[1])
                                                && High[1] >= Open[1] && Close[0] >= High[1] // close higher then wick if
                                                && (EMA(200)[0] < slowEMA[0])
                                                && (Close[0] < CurrentDayOHL().CurrentHigh[4] - DistanceToOHL * TickSize)))
                        
                                            {
                                                entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, TradeSize, 0, 0, "", "34B");
                        
                                                return;
                                            }​

                        Comment


                          #13
                          Hello tkaboris,

                          Thanks for your note.

                          I do not see anything specific standing out in the code you shared that would cause an issue.

                          It would be up to you to further debug your script by adding prints and reducing code to understand exactly how your logic is evaluating and how your strategy is behaving. Once you understand exactly how the strategy is behaving, you could modify the script to suit your specific goals.

                          In regard to backtesting vs running the strategy live, see the help guide page linked below.

                          Please review the help guide document on the differences on real-time vs backtest (historical).
                          http://ninjatrader.com/support/helpG...ime_vs_bac.htm

                          It is expected that a strategy running real-time (live brokerage account, live market simulation, Playback connection etc...) will produce different results than the performance results generated during a backtest.

                          When in historical data, only the Open, High, Low, and Close will be available and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

                          Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.

                          Below is a link to the help guide on Calculate.
                          https://ninjatrader.com/support/help.../calculate.htm

                          Additional information may be found in this NinjaTrader Forum post: https://ninjatrader.com/support/foru...mance?t=102504

                          Please let me know if you need assistance creating certain prints.​​
                          Brandon H.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by adeelshahzad, Today, 03:54 AM
                          5 responses
                          32 views
                          0 likes
                          Last Post NinjaTrader_BrandonH  
                          Started by stafe, 04-15-2024, 08:34 PM
                          7 responses
                          32 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by merzo, 06-25-2023, 02:19 AM
                          10 responses
                          823 views
                          1 like
                          Last Post NinjaTrader_ChristopherJ  
                          Started by frankthearm, Today, 09:08 AM
                          5 responses
                          21 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by jeronymite, 04-12-2024, 04:26 PM
                          3 responses
                          43 views
                          0 likes
                          Last Post jeronymite  
                          Working...
                          X