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

Buying Condition Day of Week

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

    Buying Condition Day of Week

    Hello
    I try to test a simple strategy: buying on Monday at market open, but only when before that Monday the Friday close was higher than the Friday open. I used the strategy builder and clicked me through to the point "Conditions and Actions". There I built the following sets of conditions:
    If (Times[0][0].DayOfWeek == DayOfWeek.Friday) and Default input [0] > Open[0]
    then EnterLong(DefaultQuantity,"");

    If (Times[0][0].DayOfWeek == DayOfWeek.Monday), then ExitLong(DefaultQuantity,"");

    But when I test the strategy with the strategy analyzer, the entry time is always Friday (15:32), the exit time Friday (22:00). What am I doing wrong? How must I change the strategy input to buy Monday at market open and sell at Monday's close?

    Best regards
    Value57

    #2
    Hello value57,

    Your condition says to EnterLong is the DayOfWeek is Friday. Do you have the actions switched around for the conditions. Do you mean to be exiting on friday and entering on monday?

    You can use the PriorDayOHLC indicator if you want to get the PriorClose and PriorOpen for the previous session.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Dear Chelsea
      Thank you very much for your help. I didn't knew the PriorDayOHLC indicator. But with that I managed to build my strategy :-) Best regards.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by helpwanted, Today, 03:06 AM
      1 response
      16 views
      0 likes
      Last Post sarafuenonly123  
      Started by Brevo, Today, 01:45 AM
      0 responses
      11 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      6 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      244 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      387 views
      1 like
      Last Post Gavini
      by Gavini
       
      Working...
      X