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

inserting order flow vwap into a script

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

    inserting order flow vwap into a script

    I've read the documentation on the indicator but still not clear on how to insert it. How might I replace the indicator I am using temporarily (which is inaccurate) with the native order flow vwap indicator (just the basic vwap plot, no bands). I see 4 places of reference for the indicator i wish to replace highlighted in blue (in the script i created in the builder), but not sure how to modify them with just the line of code given in the help guide:

    double VWAPValue = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("CME US Index Futures RTH"), VWAPStandardDeviations.Three, 1, 2, 3).VWAP[0];

    here is my script:




    //This namespace holds Strategies in this folder and is required. Do not change it.

    namespace NinjaTrader.NinjaScript.Strategies

    {

    public class vvwapLunch : Strategy

    {

    private NinjaTrader.NinjaScript.Indicators.TradingRevealed .TRVwapBands TRVwapBands1;


    protected override void OnStateChange()

    {

    if (State == State.SetDefaults)

    {

    Description = @"Enter the description for your new custom Strategy here.";

    Name = "vvwapLunch";

    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)

    {

    }

    else if (State == State.DataLoaded)

    {

    TRVwapBands1 = TRVwapBands(Close, true, true, false, false);

    SetProfitTarget("", CalculationMode.Ticks, 10);

    SetStopLoss("", CalculationMode.Ticks, 20, false);

    }

    }


    protected override void OnBarUpdate()

    {

    if (BarsInProgress != 0)

    return;


    if (CurrentBars[0] < 1)

    return;


    // Set 1

    if ((Times[0][0].TimeOfDay > new TimeSpan(11, 0, 0))

    && (Times[0][0].TimeOfDay < new TimeSpan(13, 0, 0))

    && (Close[0] > TRVwapBands1.PlotVWAP[0]))

    {

    EnterLongLimit(Convert.ToInt32(DefaultQuantity), (TRVwapBands1.PlotVWAP[0] + (5 * TickSize)) , "");

    }



    }

    }

    }

    how do i replace the four lines?
    thanks,
    David


    #2
    Hello David,

    Code:
    private OrderFlowVWAP VWAPValue;
    
    VWAPValue = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("CME US Index Futures RTH"), VWAPStandardDeviations.Three, 1, 2, 3);
    
    && (Close[0] > VWAPValue.VWAP[0]))
    
    EnterLongLimit(Convert.ToInt32(DefaultQuantity), (VWAPValue.VWAP[0] + (5 * TickSize)) , "");
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by jclose, Today, 09:37 PM
    0 responses
    5 views
    0 likes
    Last Post jclose
    by jclose
     
    Started by WeyldFalcon, 08-07-2020, 06:13 AM
    10 responses
    1,413 views
    0 likes
    Last Post Traderontheroad  
    Started by firefoxforum12, Today, 08:53 PM
    0 responses
    11 views
    0 likes
    Last Post firefoxforum12  
    Started by stafe, Today, 08:34 PM
    0 responses
    11 views
    0 likes
    Last Post stafe
    by stafe
     
    Started by sastrades, 01-31-2024, 10:19 PM
    11 responses
    169 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X