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

Trade Tracking Object not working as expected

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

    Trade Tracking Object not working as expected

    Good day,

    Please could someone assist me with the following Ninjascript Strategy for (Forex markets) that I am trying to create (I am new to Ninjascript).

    The goal of the script is to test an object which I have called "TradeTracker". The object simply stores the following information regarding a trade, when an entry is provided (for the purpose of this test script, the entry and exit signal are generated by the Sample MACrossover script):

    1. EntryPrice
    2. StopLoss (if one is used)
    3. The trade type indicted by the field "Position"- this can be either flat, short or long.

    Also note that I have added two additional data series to the strategy: a minute bid and a minute ask series. These are used only for entries and exits, as I require higher granularity when back testing.
    The problem with the current script is that if the first entry signal is a long signal, the TradeTracker will only record long entries and exits for the rest of the backtest. Similarly, if the first trade is a short trade, the TradeTracker will only record short entries and exits for the rest of the backtest.

    Please could you assist me by identifying a possible error in my code. I have tried my best but I cannot seem to find the error. I have attached the compressed source file titled "TestTradeTracking".

    Sincerely,
    David
    Attached Files

    #2
    Hello DavidSpire,

    Thanks for your post.

    To understand exactly how the TradeTracker in your script is processing, you must print out the values of the TradeTracker throughout the script.

    Please add prints to the script that print out the TradeTracker values so that you could see how the logic in your script is processing and see the TradeTracker values that are being assigned. For example, outside the condition, add prints that print out tracker.TrackerPosition to see what position the tracker is in before the condition is called to update the tracker. Then, after updating the tracker, print out that value again to see if it is being updated correctly.

    Once you understand exactly how the TradeTracker logic is processing and why, you could modify the script to suit your goals.

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

    https://ninjatrader.com/support/foru...121#post791121

    Let us know if we may assist further.​
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your response Brandon. I will do so and will post any results that I find, on the forum.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Option Whisperer, Today, 09:55 AM
      1 response
      11 views
      0 likes
      Last Post bltdavid  
      Started by port119, Today, 02:43 PM
      0 responses
      1 view
      0 likes
      Last Post port119
      by port119
       
      Started by Philippe56140, Today, 02:35 PM
      0 responses
      3 views
      0 likes
      Last Post Philippe56140  
      Started by 00nevest, Today, 02:27 PM
      0 responses
      1 view
      0 likes
      Last Post 00nevest  
      Started by Jonafare, 12-06-2012, 03:48 PM
      5 responses
      3,986 views
      0 likes
      Last Post rene69851  
      Working...
      X