Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Have problem with the code on history and live demo

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

    Have problem with the code on history and live demo

    Help please.

    Have such code:
    Code:
    if (Position.MarketPosition == MarketPosition.Flat &&
    				(Closes[0][0] - X) > 0 &&
    				(Closes[0][0] - X) > 10*TickSize		
    				
    				)
    			{ 
    				if (BarsInProgress == 0)				
    				EnterShort(5);						
    				
    				if (BarsInProgress == 1)
    				EnterLong(2);					
    			}
    to enter open position towards each other.

    If it is history all is OK:


    If it is Demo Love have problem:


    It enters not in same time, delay in 1-3 bars of time frame.
    Why this can happen?

    #2
    Hello iskip,

    Thanks for your post.

    To help understand what is happening I recommend that you add some Drawdots on your chart so that you can see where the entry conditions are true compared to where your orders are actually entering. This way you can isolate if it is an order entry or logic issue.

    For example:

    if (Position.MarketPosition == MarketPosition.Flat &&
    (Closes[0][0] - X) > 0 &&
    (Closes[0][0] - X) > 10*TickSize

    )
    {
    if (BarsInProgress == 0)
    {
    EnterShort(5);
    DrawDot ("test1"+CurrentBar, true, 0, High[0] + 3 * TickSize, Color.Red);
    }

    if (BarsInProgress == 1)
    {
    EnterLong(2);
    DrawDot ("test2"+CurrentBar, true, 0, Low[0] - 3 * TickSize, Color.Green);
    }
    }
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Blaze212, Today, 06:16 PM
    0 responses
    7 views
    0 likes
    Last Post Blaze212  
    Started by visvabalaji, 02-12-2024, 04:38 PM
    2 responses
    513 views
    0 likes
    Last Post 0xikem
    by 0xikem
     
    Started by AmberBamber1999, 11-01-2023, 02:40 PM
    5 responses
    132 views
    0 likes
    Last Post esanders251206  
    Started by ThatMikey, Yesterday, 10:30 AM
    23 responses
    792 views
    4 likes
    Last Post BarzTrading  
    Started by robertdavis52, Today, 04:19 PM
    0 responses
    7 views
    0 likes
    Last Post robertdavis52  
    Working...
    X