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

AccDistRangeBreakout Strategy posted in UserApp

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

    AccDistRangeBreakout Strategy posted in UserApp

    Hi, Can you please assist with the coding of the AccDistRangeBreakout Strategy posted in UserApp for entering Short positions? It only entering Long positions?? Thanks

    Accumulation/Distribution Range Breakout strategy was published in the August 2018 Stocks and Commodities article titled ‘Portfolio Strategy Based On Accumulation/Distribution’ by Domenico D’Errico.


    Below is the partial code for Long position:

    ********************************
    protected override void OnBarUpdate()
    {
    if (CurrentBar < Length || CurrentBar < 12 || CurrentBar < VolAvg || CurrentBar < VolDelay)
    return;

    // Persist previous Top and Bot
    Top[0] = Top[1];
    Bot[0] = Bot[1];

    Range_[0] = MAX(High,Length)[0] - MIN(Low,Length)[0];

    if (Range_[0] < ConsolidationFactor * Range_[Length])
    {
    Top[0] = MAX(High, Length)[0];
    Bot[0] = MIN(Low, Length)[0];
    }

    if (ToDay(Time[0]) > 20030101 && Close[0] > Top[0] && Bot[0] > Bot[12]
    && SMA(Volume, VolAvg)[VolDelay] > VolRatio * SMA(Volume, VolAvg)[VolAvg + VolDelay])
    {
    int ProfitQuantity = 0;
    if (TradeProfit)
    ProfitQuantity = (int)Math.Floor(SystemPerformance.RealTimeTrades.T radesPerformance.NetProfit / Close[0]);
    EnterLong((int)Math.Floor(AmountToBuy/Close[0]) + ProfitQuantity);
    }
    if (Position.MarketPosition == MarketPosition.Long && Close[0] < Bot[0])
    ExitLong();
    }​
    **************************

    #2
    Hello Faranzi,

    While our support cannot make changes to the existing file on the user app share you can download it and edit it on your end by using the NinjaScript editor. Because this was made for only long you would have to use prints to check the values used in the conditions to make sure that also makes sense to be used as a trigger for a short trade. If so you can make similar conditions to what you have posted to enter short instead. Other logic may also be required depending on your overall goal with how you wanted that to work with long and short trades together.

    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,404 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    95 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    7 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    159 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    8 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X