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 maybeimnotrader, Today, 05:46 PM
      0 responses
      6 views
      0 likes
      Last Post maybeimnotrader  
      Started by quantismo, Today, 05:13 PM
      0 responses
      6 views
      0 likes
      Last Post quantismo  
      Started by AttiM, 02-14-2024, 05:20 PM
      8 responses
      166 views
      0 likes
      Last Post jeronymite  
      Started by cre8able, Today, 04:22 PM
      0 responses
      8 views
      0 likes
      Last Post cre8able  
      Started by RichStudent, Today, 04:21 PM
      0 responses
      5 views
      0 likes
      Last Post RichStudent  
      Working...
      X