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

Problem with Strategy

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

    Problem with Strategy

    Hi guys,

    i got a Problem to run the Strategy Analyzer on an Indicator i created.

    I attached some screenshots to clarify the Problem.

    My Indicator calculates something from a big csv and outputs me 1, 2 or 3 on the chart.
    I want to enter a long position if it switches to 3.

    As you can see on the chart there are several times on which the indicator is at 3 but it never enters a trade?
    Can you tell me what i did wrong? Thanks a lot!

    If I add
    Print(TK_ZR(Close, @"")[0].ToString());
    as a task
    and change the condition to
    TK_ZR("")[0] < 2
    it only returns me a lot of zeros. Buut the indicator shows 1-3 on the Chart?
    Last edited by Branpo; 10-27-2019, 08:14 AM.

    #2
    Hello Branpo, thanks for your post.

    It looks like something is going wrong on the historical data run. What kind of values are you getting from the .csv file on each historical bar? You can check this with:

    if(State == State.Historical)
    {
    Print(MyFile.<Information>);
    }

    Excel integration is not in the scope of support I can provide, but there is an example here from a user:
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi ChrisL,
      thanks for your reply.
      I tried to add the print line to my script but it doesnt work.
      I added you a screenshot.


      Best regars
      Branpo

      Comment


        #4
        Ill upload you the cs and the csv maybe its easier to help me then

        The Indicator is only working for the ZR Future at the moment and the csv needs to be in the following folder: NinjaTrader.Core.Globals.UserDataDir\APData\COT\OI \
        feel free to change it in the cs if its easier for you.

        Thanks again for your help
        Attached Files
        Last edited by Branpo; 10-27-2019, 09:56 PM.

        Comment


          #5
          Hi Branpo, thanks for your patience.

          I had a look at your script and it's not setting the data properly. When you start up a script it will iterate through each bar on the chart, I call this the "Historical run". The script needs to be designed such that it sets a value each time CurrentBar is incremented. Try Printing out CurrentBar in OnBarUpdate and you will see there is a unique value for each bar on the chart. Data access not provided by the data connection not supported to use so it will be up to you to make the .csv data access work properly.

          My code posted earlier was just pseudocode, so it won't compile. It was to demonstrate how to separate historical bar processing from real-time e.g.:

          OnBarUpdate()
          {

          if(State == State.Historical)
          {

          Print("Running in Historical Mode, CurrentBar = " + CurrentBar);

          }
          else
          {

          //realtime

          }

          }
          Chris L.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by prdecast, Today, 06:07 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Christopher_R, Today, 12:29 AM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by chartchart, 05-19-2021, 04:14 PM
          3 responses
          577 views
          1 like
          Last Post NinjaTrader_Gaby  
          Started by bsbisme, Yesterday, 02:08 PM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by i019945nj, 12-14-2023, 06:41 AM
          3 responses
          60 views
          0 likes
          Last Post i019945nj  
          Working...
          X