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 MatthewLesko, Yesterday, 11:35 AM
      1 response
      21 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Agustinvitalee, Yesterday, 10:15 AM
      1 response
      20 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by sarder2008, Yesterday, 09:54 AM
      1 response
      19 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by kaywai, Today, 12:42 PM
      0 responses
      3 views
      0 likes
      Last Post kaywai
      by kaywai
       
      Started by BartMan, Today, 11:37 AM
      0 responses
      10 views
      1 like
      Last Post BartMan
      by BartMan
       
      Working...
      X