Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

problem in OnExecution code block

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

    problem in OnExecution code block

    i am having a strange problem in OnExecution for my long long trades, it is processing a code block it shouldn't as it is inside an If statement that equates to false. I checked my brackets and I pretty sure they are all good.


    Code:
    if(this.indPivAverage.ExtrnTrend[0] == 1) // OnExecution long trades
    			{
    				if (pEntry != null && pEntry == execution.Order) // [COLOR="red"]EVEN WHEN THSI IS FALSE[/COLOR]
    				{
    					if 	(	execution.Order.OrderState 	== OrderState.Filled 
    						|| 	execution.Order.OrderState 	== OrderState.PartFilled 
    						|| 	(execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0)
    						)
    					{
    						// Stop order
    						pStop = ExitLongStop(0, true, execution.Order.Filled, Array.FindLast(pivotsOnly, k => k <= pEntry.AvgFillPrice) - stop * TickSize , "Stop of Long", "pEntry");
    						
    						// Resets the entryOrder object to null after the order has been filled
    						if (execution.Order.OrderState != OrderState.PartFilled)
    						{
    							
    					
    							if(hPiv-lPiv >= 50 * TickSize)
    								{
    								target = lPiv + 2.0/3.0 * (hPiv-lPiv);
    								}
    							else if(hPiv-lPiv >= psb*TickSize)
    								{
    								target = hPiv - Math.Max(2*TickSize,(hPiv-lPiv)*0.1);
    								}
    							else if(hPiv-lPiv < psb*TickSize)
    								{
    								target = longLevels[longLevels.FindIndex(o => o > hPiv)];
    								}
    								
    							if(positionWatchLong != true)
    							{
    								longBar 			= CurrentBar;
    								pStopPrice			= pStop.StopPrice;
    								longPriceWatch		= pEntry.AvgFillPrice;
    								positionWatchLong	= true;
    								targetWatch			= target;
    							}
    							
    							pEntry 			= null;
    							fillBar			= CurrentBar; // for the drawling target
    							longPrice 		= pEntry.AvgFillPrice; // [COLOR="Red"]I AM GETTING AN ERROR HERE AS pEntry is null[/COLOR]
    							
    								
    							tradeHigh		= 0;
    						}
    					}
    				}
                       }

    #2
    Hello GKonheiser,

    Thank you for your post.

    Try using Print() to print the name of the execution to verify. For example:
    Code:
    if(this.indPivAverage.ExtrnTrend[0] == 1) // OnExecution long trades
    			{
    				if (pEntry != null && pEntry == execution.Order) 
    				{
    				    Print("Block processing for " + execution.Name.ToString() + " at " + Time[0].ToString());
    Please let me know if you are still seeing unexpected calls.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    666 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    376 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    110 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    580 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X