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