Is there some secret settings I need to know about?
I do not have chart trader active, only a chart with an active strategy running.
public class AccumulateShortSwingLowExit : Strategy
{
private int Initial_Position_Size;
private RSI RSI1;
private RSI RSI2;
private Swing Swing1;
private MAX MAX1;
private EMA EMA1;
private ADX ADX1;
private SMA SMA1;
private MACD MACD1;
private EMA EMA2;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Accumulating position until trend swings the other way";
Name = "AccumulateShortSwingLowExit";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 8;
EntryHandling = EntryHandling.UniqueEntries;
IsExitOnSessionCloseStrategy = false;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 4;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
RSIOnHigherTF = 80;
RSIOnLowerTF = 95;
RSI_Period = 2;
Swing_Period = 10;
Account_Size = 10000;
PipTarget = 50;
Initial_Position_Size = 1000;
}
else if (State == State.Configure)
{
//AddDataSeries("EURUSD", BarsPeriod.BarsPeriodType, 4 * BarsPeriod.Value, Data.MarketDataType.Last);
AddDataSeries("EURUSD", Data.BarsPeriodType.Minute, 240, Data.MarketDataType.Last);
AddDataSeries("EURUSD", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
AddPlot(Brushes.Lime, "Average price"); //PLOTTING AVERAGE ENTRY PRICE
//SetStopLoss(CalculationMode.Percent, 0.03);
}
else if (State == State.DataLoaded)
{
RSI1 = RSI(Closes[0], Convert.ToInt32(RSI_Period), 2);
RSI2 = RSI(Close, Convert.ToInt32(RSI_Period), 2);
Swing1 = Swing(Close, 10);
MAX1 = MAX(High, 14); //minimum low last 14 bars
EMA1 = EMA(Close, 55);
ADX1 = ADX(Closes[1], 14);
SMA1 = SMA(Close,200);
MACD1 = MACD(Closes[1], 34, 55, 13);
EMA2 = EMA(ADX1, 14);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1
|| CurrentBars[1] < 1)
return;
Values[0][0] = (Position.AveragePrice != 0)?Position.AveragePrice:Close[0];
//----------------------LONG ENTRIES----------------------------------------
// LE1 ENTRY
if ((Position.MarketPosition == MarketPosition.Flat)
&& (RSI1.Default[0] > RSIOnHigherTF)
&& (RSI2.Default[0] > RSIOnLowerTF)
&& (Close[0] > High[1])
&& (Close[0] > Swing1.SwingHigh[0])
&& (MACD1.Diff[0] > 0))
{
EnterShort(Convert.ToInt32(100), @"SE1");
}
// LE1 EXIT
if ((Position.MarketPosition == MarketPosition.Short)
&& (Position.Quantity == 100)
&& (Close[0] < Swing1.SwingLow[0]))
{
Print("LE1 Entry time is:");
Print(Time[0]);
ExitShort(Convert.ToInt32(100), @"SExit1", @"SE1");
}
// LE2 ENTRY
if ((Position.Quantity == 100)
&& (Close[0] > High[1])
&& (Close[0] > Swing1.SwingHigh[0])
&& (Close[0] > Position.AveragePrice - .002)
&& (Close[0] > MAX1[1])
&& (MACD1.Diff[0] > 0))
{
Print("LE2 Entry time is:");
Print(Time[0]);
EnterShort(Convert.ToInt32(200), @"SE2");
}
// LE2 EXIT
if ((Position.Quantity == 300)
&& (Close[0] < Swing1.SwingLow[0]))
{
ExitShort(Convert.ToInt32(200), @"SExit2", @"SE2");
}
// LE3 ENTRY
if ((Position.Quantity == 300)
&& (Close[0] > High[1])
&& (Close[0] > Swing1.SwingHigh[0])
&& (Close[0] > Position.AveragePrice - .002)
&& (Close[0] > MAX1[1])
&& (MACD1.Diff[0] > 0))
{
Print("LE3 Entry time is:");
Print(Time[0]);
EnterShort(Convert.ToInt32(600), @"LE3");
}
// LE3 EXIT
if ((Position.Quantity == 900)
&& (Close[0] < Swing1.SwingLow[0]))
{
ExitShort(Convert.ToInt32(600), @"LExit3", @"LE3");
}
// LE4 ENTRY
if ((Position.Quantity == 900)
&& (Close[0] > High[1])
&& (Close[0] > Swing1.SwingHigh[0])
&& (Close[0] > Position.AveragePrice - .002)
&& (Close[0] > MAX1[1])
&& (MACD1.Diff[0] > 0))
{
Print("LE4 Entry time is:");
Print(Time[0]);
EnterShort(Convert.ToInt32(1800), @"LE4");
}
// LE4 EXIT
if ((Position.Quantity == 2700)
&& (Close[0] < Swing1.SwingLow[0]))
{
ExitShort(Convert.ToInt32(1800), @"LExit4", @"LE4");
}
// LE5 ENTRY
if ((Position.Quantity == 2700)
&& (Close[0] > High[1])
&& (Close[0] > Swing1.SwingHigh[0])
&& (Close[0] > Position.AveragePrice - .002)
&& (Close[0] > MAX1[1])
&& (MACD1.Diff[0] > 0))
{
Print("LE5 Entry time is:");
Print(Time[0]);
EnterShort(Convert.ToInt32(5400), @"LE5");
}
// LE5 EXIT
if ((Position.Quantity == 8100)
&& (Close[0] < Swing1.SwingLow[0]))
{
ExitShort(Convert.ToInt32(5400), @"LExit5", @"LE5");
}
// LE6 ENTRY
if ((Position.Quantity == 8100)
&& (Close[0] > High[1])
&& (Close[0] > Swing1.SwingHigh[0])
&& (Close[0] > Position.AveragePrice - .002)
&& (Close[0] > MAX1[1])
&& (MACD1.Diff[0] > 0))
{
Print("LE6 Entry time is:");
Print(Time[0]);
EnterShort(Convert.ToInt32(16200), @"LE6");
}
// LE6 EXIT
if ((Position.Quantity == 24300)
&& (Close[0] < Swing1.SwingLow[0]))
{
ExitShort(Convert.ToInt32(16200), @"LExit6", @"LE6");
}
// LE7 ENTRY
if ((Position.Quantity == 24300)
&& (Close[0] > High[1])
&& (Close[0] > Swing1.SwingHigh[0])
&& (Close[0] > Position.AveragePrice - .002)
&& (Close[0] > MAX1[1])
&& (MACD1.Diff[0] > 0))
{
Print("LE7 Entry time is:");
Print(Time[0]);
EnterShort(Convert.ToInt32(48600), @"LE7");
}
// LE7 EXIT
if ((Position.Quantity == 72900)
&& (Close[0] < Swing1.SwingLow[0]))
{
ExitShort(Convert.ToInt32(48600), @"LExit7", @"LE7");
}
// LE8 ENTRY
if ((Position.Quantity == 72900)
&& (Close[0] > High[1])
&& (Close[0] > Swing1.SwingHigh[0])
&& (Close[0] > Position.AveragePrice - .002)
&& (Close[0] > MAX1[1])
&& (MACD1.Diff[0] > 0))
{
Print("LE8 Entry time is:");
Print(Time[0]);
EnterShort(Convert.ToInt32(145800), @"LE8");
}
// LE8 EXIT
if ((Position.Quantity == 218700)
&& (Close[0] < Swing1.SwingLow[0]))
{
ExitShort(Convert.ToInt32(145800), @"LExit8", @"LE8");
ExitShort(Convert.ToInt32(48600), @"LExit7", @"LE7");
ExitShort(Convert.ToInt32(16200), @"LExit6", @"LE6");
ExitShort(Convert.ToInt32(5400), @"LExit5", @"LE5");
ExitShort(Convert.ToInt32(1800), @"LExit4", @"LE4");
ExitShort(Convert.ToInt32(600), @"LExit3", @"LE3");
ExitShort(Convert.ToInt32(200), @"LExit2", @"LE2");
ExitShort(Convert.ToInt32(100), @"LExit1", @"LE1");
}
//****** CLOSE ALL ON TRADE FAILURE ******************************
//if ((Position.Quantity == 218700)
// && (Close[0] < Low[1]))
//{
// ExitLong(Convert.ToInt32(145800), @"LExit8", @"LE8");
// ExitLong(Convert.ToInt32(48600), @"LExit7", @"LE7");
// ExitLong(Convert.ToInt32(16200), @"LExit6", @"LE6");
// ExitLong(Convert.ToInt32(5400), @"LExit5", @"LE5");
// ExitLong(Convert.ToInt32(1800), @"LExit4", @"LE4");
// ExitLong(Convert.ToInt32(600), @"LExit3", @"LE3");
// ExitLong(Convert.ToInt32(200), @"LExit2", @"LE2");
// ExitLong(Convert.ToInt32(100), @"LExit1", @"LE1");
//}
}
protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice,
int quantity, int filled, double averageFillPrice,
Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
{
Print("The most current order state is: " + order.OrderState); // OrderState.PartFilled
Print("This particular order update state is: " + orderState); // OrderState.Working
}
if (MACD1.Diff[0] > 0)
{
Print("Current 4 hr MACD Diff at " + Time[0] + " is greater than zero - condition met");
}
if (Close[0] > High[1])
{
Print("Close greater than prior High at " + Time[0] + " - condition met");
}
if (Close[0] > Swing1.SwingHigh[0])
{
Print("Close greater than swing high at " + Time[0] + " - condition met");
}
if (Close[0] > Position.AveragePrice - .002)
{
Print("Close greater than average entry price at " + Time[0] + " - condition met");
}
if (Close[0] > MAX1[1])
{
Print("Close greater than maximum high last 14 bars at " + Time[0] + " - condition met");
}
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
{
[B]Print(order.ToString());[/B]
}
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
77 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
45 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
27 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
32 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
62 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|
Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one’s financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.
CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates.
Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.

Comment