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 CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        224 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        143 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        157 views
        1 like
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        237 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        196 views
        0 likes
        Last Post CarlTrading  
        Working...
        X