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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    67 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    41 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    24 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    27 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    53 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X