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);
    }
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    305 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    198 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    186 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    274 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    228 views
    0 likes
    Last Post CarlTrading  
    Working...
    X