Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Help with Reversing Strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help with Reversing Strategy

    Hi NT Community.

    I downloaded this strategy from the free ecosystem and I noticed that it might be much better if it were reversed, and if it could have the add trades for the opposite direction. Can someone please help me reverse it and add the opposite directional trades to it?

    Some notes:
    - This strategy is currently for Longs only - you will see
    - I tried simply replacing the text "Long" with"Short" but that didn't accomplish the reversal - I had a historical performance of zero trades, so I assume there must be more to change about the code
    - After reversing it, (replacing the Longs for Shorts), please add the trade for the opposite direction (which will be for Longs after changing the original Long entry to Shorts)
    - Thank you! - Code is below:


    ***


    ***




    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class TimingModel : Strategy
    {
    private RSI myRSI;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Timing Model from the June 2008 Stocks and Commodities magazine Article";
    Name = "TimingModel";
    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;
    }
    else if (State == State.Configure)
    {
    myRSI = RSI(High, 2, 3);
    SetProfitTarget(CalculationMode.Percent, 0.075);
    AddChartIndicator(myRSI);
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 200)
    return;

    // Enter long
    if (myRSI.Default[0] < 2 && myRSI.Default[1] > 1 && Close[0] > SMA(200)[0])
    EnterLongLimit(Low[0] * 1.025);

    // Exit conditions
    if (Close[0] > High[2] || BarsSinceEntryExecution() > 5)
    ExitLong();
    }
    }
    }

Latest Posts

Collapse

Topics Statistics Last Post
Started by tradebot, Today, 01:25 PM
0 responses
4 views
0 likes
Last Post tradebot  
Started by seq2seq, 05-07-2023, 07:26 PM
6 responses
563 views
0 likes
Last Post duniya_trader  
Started by i2ogu3, Yesterday, 11:31 PM
4 responses
23 views
0 likes
Last Post i2ogu3
by i2ogu3
 
Started by reynoldsn, Yesterday, 07:11 PM
3 responses
16 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by manueldecastro, Today, 10:26 AM
2 responses
12 views
0 likes
Last Post manueldecastro  
Working...
X