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

Renko Trading Strategy NT8

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

    Renko Trading Strategy NT8

    I have downloaded this NT script:
    https://ninjatraderecosystem.com/use...-strategy-nt8/

    Is there anybody that could help me add a condition to enter long only over the 21 EMA and short under the 21 EMA?

    I have tried adding it to the script. However, I was only successful either with the long or short but cannot have it function on both sides simultaneously, long and short.

    Thank you

    #2
    Hello Meirf193,

    Welcome to the NinjaTrader forums!

    To confirm, you mean the current price is greater than the EMA?

    if (Close[0] > EMA(21)[0])
    {
    EnterLong();
    }

    else if (Close[0] < EMA(21)[0])
    {
    EnterShort();
    }

    These could be added to the existing conditions if that's what you are trying to do.. Or you could have these as separate conditions.

    Below I am providing a link to a forum post with helpful information about getting started with NinjaScript and C#.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea,
      This is the condition I have used, it works well for the longs, but for the shorts, it enters short only above the EMA (instead of only going short below the EMA)
      I am pasting here the script, can you tell me where in the script I should place it?

      if(CurrentBar < EntryStrength || CurrentBar < ExitStrength)
      return;

      if(Position.MarketPosition == MarketPosition.Flat)
      {
      for(int i = 0; i < EntryStrength; i++)
      EntryBarArray[i] = false;

      for(int i = EntryStrength-1; i >=0; i--)
      {
      if(Close[i] > Open[i])
      {
      EntryBarArray[i] = true;
      }
      else
      {
      EntryBarArray[i] = false;
      }
      }

      adhoc = true;
      foreach(bool b in EntryBarArray)
      {
      adhoc = adhoc && b;
      }

      if(adhoc && AllowLong)

      {
      EnterLong();
      }
      else
      {
      for(int i = 0; i < EntryStrength; i++)
      EntryBarArray[i] = false;

      for(int i = EntryStrength-1; i >=0; i--)
      {
      if(Close[i] < Open[i])
      {
      EntryBarArray[i] = true;
      }
      else
      {
      EntryBarArray[i] = false;
      }
      }

      adhoc = true;
      foreach(bool b in EntryBarArray)
      {
      adhoc = adhoc && b;
      }

      if(adhoc && AllowShort)
      {
      EnterShort();
      }
      }

      }

      for(int i = 0; i < ExitStrength; i++)
      ExitBarArray[i] = false;

      if(Position.MarketPosition == MarketPosition.Long && BarsSinceEntryExecution() >= 1)
      {
      for(int i = ExitStrength-1; i >=0; i--)
      {
      if(Close[i] < Open[i])
      {
      ExitBarArray[i] = true;
      }
      }

      adhoc = true;
      foreach(bool b in ExitBarArray)
      {
      adhoc = adhoc && b;
      }

      if(adhoc && UseExitStrength)
      {
      ExitLong();
      }

      }
      else if(Position.MarketPosition == MarketPosition.Short && BarsSinceEntryExecution() >= 1)
      {
      for(int i = ExitStrength-1; i >=0; i--)
      {
      if(Close[i] > Open[i])
      {
      ExitBarArray[i] = true;
      }
      }

      adhoc = true;
      foreach(bool b in ExitBarArray)
      {
      adhoc = adhoc && b;
      }

      if(adhoc && UseExitStrength)
      {
      ExitShort();
      }

      Comment


        #4
        Hello Meirf193,

        What is the specific single condition you are investigating?

        Add prints to confirm the condition is true.

        Print the time of the bar, print all values used in the condition. This will let you know why the condition is evaluating as true or false.

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


        To save the output from the output window as a text file, right-click the output window and select Save As.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmtjoancolmenero, 04-25-2024, 03:58 PM
        14 responses
        59 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by raffu, Yesterday, 11:41 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cmtjoancolmenero, Yesterday, 11:56 AM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by reynoldsn, 04-21-2024, 07:53 PM
        3 responses
        25 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by cmtjoancolmenero, Yesterday, 03:40 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X