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 DJ888, 04-16-2024, 06:09 PM
    4 responses
    12 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by terofs, Today, 04:18 PM
    0 responses
    8 views
    0 likes
    Last Post terofs
    by terofs
     
    Started by nandhumca, Today, 03:41 PM
    0 responses
    6 views
    0 likes
    Last Post nandhumca  
    Started by The_Sec, Today, 03:37 PM
    0 responses
    3 views
    0 likes
    Last Post The_Sec
    by The_Sec
     
    Started by GwFutures1988, Today, 02:48 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X