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, 07: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, 08: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 CarpetHooligan, Yesterday, 05:49 PM
          0 responses
          15 views
          0 likes
          Last Post CarpetHooligan  
          Started by EquityTrader, Yesterday, 03:33 PM
          0 responses
          14 views
          0 likes
          Last Post EquityTrader  
          Started by ahelton, Yesterday, 11:53 AM
          2 responses
          41 views
          0 likes
          Last Post ahelton
          by ahelton
           
          Started by tonynt, Yesterday, 02:07 PM
          0 responses
          22 views
          0 likes
          Last Post tonynt
          by tonynt
           
          Started by sgordet, Yesterday, 01:57 PM
          0 responses
          20 views
          0 likes
          Last Post sgordet
          by sgordet
           
          Working...
          X