NexusFi: Find Your Edge


Home Menu

 





ATM TRADING USING SCRIPT STRATEGY


Discussion in NinjaTrader

Updated
    1. trending_up 6,461 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

ATM TRADING USING SCRIPT STRATEGY

  #1 (permalink)
demit177
TORONTO, CANADA
 
Posts: 2 since May 2011
Thanks Given: 0
Thanks Received: 0

Hello ,
i'm looking to get help with implementing an ATM strategy into script strategy.
very simple stuff for a programmer, or for a person who has NT trading experience.
will really appreciate your time and experience.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,440 since Jun 2009
Thanks Given: 33,213
Thanks Received: 101,599



demit177 View Post
Hello ,
i'm looking to get help with implementing an ATM strategy into script strategy.
very simple stuff for a programmer, or for a person who has NT trading experience.
will really appreciate your time and experience.

I've written a lot of strategies that use Ninja's ATMs. Post what you have so far and what problems you are running into, and someone will likely help. I'll try to help to, but having not used NT for such a long time I am a bit rusty

If you are wanting someone to do it for you, you should make your request more clear that you are looking to hire a programmer - and they can contact you via PM to discuss details.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
demit177
TORONTO, CANADA
 
Posts: 2 since May 2011
Thanks Given: 0
Thanks Received: 0

than you for prompt reply, Mike.
am looking to have my ATM strategy to be triggered by a Ninja Script, which is very simple.
Go long or short on cross above of two EMA's and exit long or short on a cross of the opposite direction.

when the position is open i need this position to be managed by my ATM strategy. and whatever shares are left open to be closed by NT on the opposite cross.

So far, the script i have triggers on the MA crossover the ATM strategy i need. But it does not close the position in the opposite cross. Please have a look at my script below and advise me how to rectify this problem

Your time and efforts are greatly appreciated. PLEASE let me know.

Thanks

NT SCRIPT:

#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// ENTER LONG & EXIT LONG ONLY
/// </summary>
[Description("ENTER LONG & EXIT LONG ONLY")]
public class LONG : Strategy
{
#region Variables
// Wizard generated variables
private int fAST = 15; // Default setting for FAST
private int sLOW = 35; // Default setting for SLOW
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{

CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(EMA(15), EMA(35), 1))
{
//string a = "b12345";
string a = GetAtmStrategyUniqueId();
string orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Action.Buy, OrderType.Market, 0, 0,TimeInForce.Day, orderId, "TNA 50 SHARES",GetAtmStrategyUniqueId());
Alert("CROSS ABOVE", Priority.High, "ENTER LONG", "", 0, Color.White, Color.Black);
}

// Condition set 2
//if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
if (CrossBelow(EMA(15), EMA(35), 1))
{
//AtmStrategyClose(a);
//AtmStrategyChangeStopTarget(0, EMA(15)[0], "STOP1",GetAtmStrategyUniqueId() );
//ExitLong();
Alert("EXIT LONG", Priority.High, " EXIT LONG", "", 0, Color.White, Color.Black);
}
}

#region Properties
[Description("")]
[Category("Parameters")]
public int FAST
{
get { return fAST; }
set { fAST = Math.Max(18, value); }
}

[Description("")]
[Category("Parameters")]
public int SLOW
{
get { return sLOW; }
set { sLOW = Math.Max(25, value); }
}
#endregion
}

Reply With Quote
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,440 since Jun 2009
Thanks Given: 33,213
Thanks Received: 101,599

Here is a bit of code from an old strategy. Maybe it will help.

 
Code
                            
private void GoLong()

        {
            
            if (
atm_id != null)
            {
                
string[] entryOrder GetAtmStrategyEntryOrderStatus(atm_id);
                
                if (
GetAtmStrategyMarketPosition(atm_id) != MarketPosition.Flat)
                    return;
                
                if (
entryOrder.Length 0)
                {
                
                    if (
entryOrder[2].ToString() != "Filled")
                        return;
                }
                
            }
            
atm_id    GetAtmStrategyUniqueId();
            
AtmStrategyCreate(Action.BuyOrderType.LimitPrice_High0TimeInForce.Dayatm_idATM_Nameatm_id);
            
            
conslong++;
            
        }
        
        private 
void GoShort()
        {
            
            if (
atm_id != null)
            {
                
string[] entryOrder GetAtmStrategyEntryOrderStatus(atm_id);
                
                if (
GetAtmStrategyMarketPosition(atm_id) != MarketPosition.Flat)
                    return;
                
                if (
entryOrder.Length 0)
                {
                
                    if (
entryOrder[2].ToString() != "Filled")
                        return;
                }
                
            }
            
            
atm_id    GetAtmStrategyUniqueId();
            
AtmStrategyCreate(Action.SellShortOrderType.LimitPrice_Low0TimeInForce.Dayatm_idATM_Nameatm_id);
            
            
consshort++;
            
            
        }


        
# onbarupdate

if (Time[0] > end_time)
            {
            
                
// check to see if not flat, close all open orders
                
if (atm_id != null)
                {
                    if (
GetAtmStrategyMarketPosition(atm_id) != MarketPosition.Flat)
                        
AtmStrategyClose(atm_id);
                }
                
                
// otherwise
                
return;
                
            } 
Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on May 29, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts