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 Shansen, 08-30-2019, 10:18 PM
    24 responses
    938 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    3 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    2 views
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    27 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Working...
    X