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;
}
}
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
problem in OnExecution code block
Collapse
X
-
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:Tags: None
-
Hello GKonheiser,
Thank you for your post.
Try using Print() to print the name of the execution to verify. For example:
Please let me know if you are still seeing unexpected calls.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());
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
81 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
41 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
64 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
66 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
54 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment