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:

    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

          }

          }

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          52 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          70 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          44 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X