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

Open Position on daily Open

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

    Open Position on daily Open

    Hello,
    Could anyone help with this task?
    I use daily graph and I'd like to programm strategy which open a position on Daily OPEN if this OPEN is lower then previous CLOSE.
    But it always open the position next day.


    I guess that this code is completely wrong but I have change it many times and I am feel really lost...
    Code:
    			
    if (BarsInProgress == 1)
    {
    	openPrice = GetCurrentAsk();
    }
    			
    if (BarsInProgress == 0)
    {
    	if (Time[0].DayOfWeek == DayOfWeek.Friday)
    	{
    		lastFridayClose = Close[0];
    		tradeProceed = false;
    		BackColor = Color.LightSkyBlue;
    	}
    				
    	if (openPrice < lastFridayClose && !tradeProceed)
    	{
    		tradeProceed = true;
    		EnterLong(1, 1, "Long: 1min");
    		BackColor = Color.Chartreuse;
    	}
    }
    Thanks a lot for your support.

    Martin
    Last edited by Luigio; 01-19-2013, 12:56 PM.

    #2
    Hi again,

    I have already solved .
    So, for others how would spend a lot of time the same topick, it is really simple:
    Code:
    protected override void Initialize()
    {
            CalculateOnBarClose = true;
            ExitOnClose = true;
            ExitOnCloseSeconds = 30;
            Enabled = true;
           [B][COLOR="Red"] Add(PeriodType.Minute, 1);[/COLOR][/B]
    }
    protected override void OnBarUpdate()
    {
    	if (Open[[COLOR="Red"][B]-1[/B][/COLOR]] < Close[0] && Time[0].DayOfWeek == DayOfWeek.Friday)
    	{
    		EnterLong(0, 1, "Long: 1min");
    		BackColor = Color.Chartreuse;
    	}
    }
    Last edited by Luigio; 01-19-2013, 02:30 PM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 05-06-2023, 09:03 PM
    9 responses
    258 views
    0 likes
    Last Post ender_wiggum  
    Started by Mizzouman1, Today, 07:35 AM
    4 responses
    18 views
    0 likes
    Last Post Mizzouman1  
    Started by philmg, Today, 01:17 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by cre8able, Today, 01:01 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by manitshah915, Today, 12:59 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X