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

Long/Short problem

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

    Long/Short problem

    Hello. I created a region for the order management Long / Short called: ManagerOrder().
    The variables double myRangeLong and double my RangeShort, are used to determine the Exit. The Long part works fine, while the Short, opens and closes the position on the same bar. If, however, use only the Short is okay. I tried to create for the operation Short, callOnce2 but does not work.
    Ciao
    Roberto


    Code:
    # region OrderRouting
    private void ManagerOrder ()
    {
    if (Position.MarketPosition == MarketPosition.Long callOnce & &)
    double myRangeLong = (MAX (HIGH, 5) [0]-MIN (Low, 10) [5]);
    callOnce = false;
    }

    {
    if (BE1 & & High [0]> (Position.AvgPrice +5)
    SetStopLoss (CalculationMode.Price, Position.AvgPrice);


    if (Position.MarketPosition == MarketPosition.Short callOnce & &)
    double myRangeShort = ((MIN (Low, 5) [0] - MAX (H, 10) [5]) *- 1);
    callOnce = false;

    protected override void OnBarUpdate ()

    if (Position.MarketPosition == MarketPosition.Flat)
    callOnce = true;

    ManagerOrder ();
    if (Position.MarketPosition! = MarketPosition.Flat) return;

    / / Long
    Etc. ....

    / / Short
    Etc. ...

    #2
    Roberto,

    You will have to debug your strategy, using Print() statements and TraceOrders output. If you can't track the behavior, then simplify your setup until it works as you expect. More information for these techniques is available here:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      The Trace order had already activated and I always use the Print. I did not put in the example , for not to extend the example code. Just the Print I saw that if the variable is not updated Short is still 0.
      Roberto

      Comment


        #4
        Roberto, If you're interested in professional level debugging services, please see our list of NS consultants available here:
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by arvidvanstaey, Today, 02:19 PM
        4 responses
        11 views
        0 likes
        Last Post arvidvanstaey  
        Started by samish18, 04-17-2024, 08:57 AM
        16 responses
        59 views
        0 likes
        Last Post samish18  
        Started by jordanq2, Today, 03:10 PM
        2 responses
        9 views
        0 likes
        Last Post jordanq2  
        Started by traderqz, Today, 12:06 AM
        10 responses
        18 views
        0 likes
        Last Post traderqz  
        Started by algospoke, 04-17-2024, 06:40 PM
        5 responses
        47 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X