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 reversing this entry signal

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

    Help reversing this entry signal

    Hello, I have this strategy that only enters long. I would like to add a code to also trade short signals. Could anyone please help me reverse this long ONLY entry??

    Thanks
    ================================================== ================================================== ======================

    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 futuros,

    Thanks for your post.

    It would be hard to help with this without understanding what it does.

    It looks like if the Close is greater than the MAX of the high series for some length and the Min of the low series of some length is less than it was 12 bars ago to enter a long trade. I would, perhaps incorrectly, assume ToDay(Time[0]) > 20030101 and that SMA(Volume, VolAvg)[VolDelay] > VolRatio * SMA(Volume, VolAvg)[VolAvg + VolDelay] remains the same for long or short entries.

    You might want to consult with the originator of the code to better understand the entry conditions.


    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by zstheorist, Today, 07:52 PM
    0 responses
    3 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    149 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    5 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post tkaboris  
    Working...
    X