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 charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
51 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
142 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
160 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
96 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
275 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|

Comment