bool flowCondition = flowStats.Score[0] > avgFlowstats.UpperbandScore[0];
// SELL
if ( flowCondition && !upcandleCondition)
{
Print("$SELL signal ");
Print(flowStats.Score[0] + " score > " + avgFlowstats.LowerbandScore[0]);
Print(Volume[0] + " VOl > " + avgFlowstats.UpperbandVolume[0]);
Print(flowStats.NumTrades[0] + " # > " + avgFlowstats.UpperbandNumTrades[0]);
string entryName = "";
if (Position.MarketPosition != MarketPosition.Long)
{
entryName = "short" + (Position.Quantity + 1).ToString();
PrintA("issuing " + entryName);
IOrder order = EnterShort(DefaultQuantity, entryName);
if (order != null)
{
Print("SELL:" + order.ToString());
ht.Add(entryName, DefaultQuantity);
}
else
Print(Time[0].ToString() + "--EnterShort: NULL Order");
Print("setting stop and target for " + entryName);
SetStopLoss(entryName, CalculationMode.Percent, 0.45, false);
SetProfitTarget(entryName, CalculationMode.Percent, 0.70);
}
else // long
{
entryName = "long" + Position.Quantity.ToString();
if (ht.ContainsKey(entryName))
{
PrintA("issuing " + "exit-" + entryName);
IOrder order = ExitLong(DefaultQuantity, "exit-" + entryName, entryName);
if (order != null)
{
//PrintA(order.ToString());
ht.Add("exit-" + entryName, DefaultQuantity);
}
else
PrintA(Time[0].ToString() + "--ExitLong: NULL Order");
}
else
Print(entryName + " doesn't exist");
}
}
flowCondition = flowStats.Score[0] < avgFlowstats.LowerbandScore[0];
// BUY
if ( flowCondition && upcandleCondition)
{
Print("$BUY signal ");
Print(flowStats.Score[0] + " score < " + avgFlowstats.LowerbandScore[0]);
Print(Volume[0] + " VOl > " + avgFlowstats.UpperbandVolume[0]);
Print(flowStats.NumTrades[0] + " # > " + avgFlowstats.UpperbandNumTrades[0]);
string entryName = "";
if (Position.MarketPosition != MarketPosition.Short)
{
entryName = "long" + (Position.Quantity + 1).ToString();
Print("issuing " + entryName);
IOrder order = EnterLong(DefaultQuantity, entryName);
if (order != null)
{
Print("BUY:" + order.ToString());
ht.Add(entryName, DefaultQuantity);
}
else
Print(Time[0].ToString() + "--EnterLong: NULL Order");
Print("setting stop and target for " + entryName);
SetStopLoss(entryName, CalculationMode.Percent, 0.45, false);
SetProfitTarget(entryName, CalculationMode.Percent, 0.70);
}
else // short
{
entryName = "short" + Position.Quantity.ToString();
if (ht.ContainsKey(entryName))
{
PrintA("issuing " + "exit-" + entryName);
IOrder order = ExitShort(DefaultQuantity, "exit-" + entryName, entryName);
if (order != null)
{
Print("Adding exit-" + entryName);
ht.Add("exit-" + entryName, DefaultQuantity);
}
else
PrintA(Time[0].ToString() + "--ExitShort: NULL Order");
}
else
Print(entryName + " doesn't exist");
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
SetStopLoss/SetProfitTarget
Collapse
X
-
SetStopLoss/SetProfitTarget
I am using these 2 calls in the code below, where I take a position using an explicit name in the appropriate overload of EnterLong and on occasions exit that position using the corresponding overload of Exitlong. Somehow the Stop and ProfitTaget calls are not activating. For example, for the below code, my stop is 045% and profit is 0.70%. This is yielding traces that have a PnL > 2% and in MFE > ProfitTarget and MAE > StopLoss, that should not happen right?
Code:Tags: None
-
I am looking for 0.45% stop loss and 0.7% profit target.
Please sen me an example of how exactly I can specify the various calculation modes, the help section and documentation is insufficient. I appreciate your effort.Last edited by newworldguy; 05-29-2014, 03:55 AM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
656 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
371 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
579 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment