Announcement

Collapse
No announcement yet.

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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        176 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        331 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        254 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        356 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        184 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X