DMI14 crossover DEMA 10 and 20. (Ninja Trader)
Forums › ProRealTime English forum › ProBuilder support › DMI14 crossover DEMA 10 and 20. (Ninja Trader)
- This topic has 1 reply, 2 voices, and was last updated 5 years ago by Vonasi.
-
-
02/22/2019 at 9:48 AM #92023
Hi guys
Please could you covert my ninja trader script.
Thank you
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class DMIDEMACrossoverStrategy01 : Strategy
{
private DEMA slowdema;
private DEMA fastdema;
private DM dm;protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @”DMI and DEMA crossovers.”;
Name = “DMIDEMACrossoverStrategy01”;
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
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;
FastDEMA = 10;
SlowDEMA = 20;
DMIPeriod = 14;
}
else if (State == State.DataLoaded)
{
slowdema = DEMA(SlowDEMA);
fastdema = DEMA(FastDEMA);
dm = DM(DMIPeriod);fastdema.Plots[0].Brush = Brushes.Goldenrod;
slowdema.Plots[0].Brush = Brushes.SeaGreen;
dm.Plots[0].Brush = Brushes.DarkSeaGreen;
dm.Plots[1].Brush = Brushes.DodgerBlue;
dm.Plots[2].Brush = Brushes.Crimson;AddChartIndicator(slowdema);
AddChartIndicator(fastdema);
AddChartIndicator(dm);
}
}protected override void OnBarUpdate()
{
//Add your custom strategy logic here.if(CurrentBar < 10)
return;double dema1 = DEMA(FastDEMA)[0];
double dema2 = DEMA(FastDEMA)[1];
double dema20_1 = DEMA(SlowDEMA)[0];
double dema20_2 = DEMA(SlowDEMA)[1];
double DMPlusDI_1 = DM(DMIPeriod).DiPlus[0];
double DMPlusDI_2 = DM(DMIPeriod).DiPlus[1];
double DMMinusDI_1 = DM(DMIPeriod).DiMinus[0];
double DMMinusDI_2 = DM(DMIPeriod).DiMinus[1];//+DI crosses above -DI && Fast DEMA crosses above Slow DEMA
if( (DMPlusDI_2 <= DMMinusDI_2) && (DMPlusDI_1 > DMMinusDI_1) &&
(dema2 <= dema20_2) && (dema1 > dema20_1) )
{
//BUY[0] = Low[0]-(10*TickSize);
ExitShort();
EnterLong();
}//+DI crosses below -DI && Fast DEMA crosses below Slow DEMA
if( (DMPlusDI_2 >= DMMinusDI_2) && (DMPlusDI_1 < DMMinusDI_1) &&
(dema2 >= dema20_2) && (dema1 < dema20_1) )
{
//SELL[0] = High[0]+(10*TickSize);
ExitLong();
EnterShort();
}}
#region Properties
[Range(1, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = “FastDEMA”, GroupName = “NinjaScriptParameters”, Order = 0)]
public int FastDEMA
{ get; set; }[Range(1, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = “SlowDEMA”, GroupName = “NinjaScriptParameters”, Order = 1)]
public int SlowDEMA
{ get; set; }[Range(1, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = “DMIPeriod”, GroupName = “NinjaScriptParameters”, Order = 2)]
public int DMIPeriod
{ get; set; }#endregion
}
}02/22/2019 at 10:09 AM #92031Please follow the instructions that can be found here when requesting a code conversion:
https://www.prorealcode.com/free-code-conversion/
Screenshots, files of the code and detailed descriptions of how it is supposed to work all help the person doing the coding to do their thing. Expecting them to research it all themselves first does not! 🙂
-
AuthorPosts
Find exclusive trading pro-tools on