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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    102 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    144 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X