• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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:
    https://ninjatrader.com/support/foru...ja-excel/page9
    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 davidwade, Today, 02:51 AM
          0 responses
          1 view
          0 likes
          Last Post davidwade  
          Started by aviat72, 04-26-2020, 09:41 PM
          10 responses
          90 views
          0 likes
          Last Post kissandfly  
          Started by healthooa, Today, 01:28 AM
          0 responses
          7 views
          0 likes
          Last Post healthooa  
          Started by superkolleech, Today, 12:46 AM
          0 responses
          10 views
          0 likes
          Last Post superkolleech  
          Started by harjinderjit, Yesterday, 08:24 PM
          0 responses
          20 views
          0 likes
          Last Post harjinderjit  
          Working...
          X