NexusFi: Find Your Edge


Home Menu

 





Strategy Builder for Non-Programmers NO CODE


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one jmont1 with 47 posts (85 thanks)
    2. looks_two romus with 29 posts (20 thanks)
    3. looks_3 Fugitive69 with 16 posts (30 thanks)
    4. looks_4 userque with 15 posts (11 thanks)
      Best Posters
    1. looks_one Fugitive69 with 1.9 thanks per post
    2. looks_two jmont1 with 1.8 thanks per post
    3. looks_3 romus with 0.7 thanks per post
    4. looks_4 userque with 0.7 thanks per post
    1. trending_up 48,798 views
    2. thumb_up 158 thanks given
    3. group 44 followers
    1. forum 132 posts
    2. attach_file 66 attachments




 
Search this Thread

Strategy Builder for Non-Programmers NO CODE

  #51 (permalink)
 markbb10 
Treasure Coast, Florida
 
Experience: Advanced
Platform: Ninja 8
Trading: Futures
Posts: 135 since Aug 2012
Thanks Given: 57
Thanks Received: 50

Hello,

I would like a user input in my strategy to be a previously defined Ninja ATM. Is this possible to do with the strategy builder or does anyone have any code samples of how to do it.

Thanks,
Mark

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Quant vue
Trading Reviews and Vendors
Cheap historycal L1 data for stocks
Stocks and ETFs
What broker to use for trading palladium futures
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
  #52 (permalink)
 loantelligence 
Syracuse, NY
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures/Zen-Fire
Trading: NQ
Posts: 218 since Jan 2011
Thanks Given: 31
Thanks Received: 189

There is an ATM Strategy in NT....Strategy Examples....you have to add your code to it....Ive got one under NT7...have to go copy it and include it here....

Reply With Quote
  #53 (permalink)
 loantelligence 
Syracuse, NY
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures/Zen-Fire
Trading: NQ
Posts: 218 since Jan 2011
Thanks Given: 31
Thanks Received: 189


Went into Strategy analyzer...created the strategy inside that....then copied the code into the ATM Strategy from NT....didnt have to write any code....

first is the original strategy from NT....ATM Sample......second is the same program with my code added to it...again the code was just copied from the analyzer once I created the strategy inside the wizard.....
Strategy..... to be executed from 9:30 - 3:30
Had to break the supertrendu11 and breakout of the dynamic SR color Band....then apply the ATM....note the Stop and Profit are not used because they are in the ATM Strategy.....
ON another note while putting this together during the last hour....was running the program in background(sim)...came up with $325......guess I should do some more testing....LOL

//
// Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
//

#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.Strategy;
#endregion


// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
///
/// </summary>
[Description("")]
public class SampleAtmStrategy : Strategy
{
#region Variables
private string atmStrategyId = string.Empty;
private string orderId = string.Empty;
#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()
{
// HELP DOCUMENTATION REFERENCE: Please see the Help Guide section "Using ATM Strategies"

// Make sure this strategy does not execute against historical data
if (Historical)
return;


// Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
// **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'AtmStrategyTemplate' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
}


// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);

// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
if (status.GetLength(0) > 0)
{
// Print out some information about the order to the output window
Print("The entry order average fill price is: " + status[0]);
Print("The entry order filled amount is: " + status[1]);
Print("The entry order order state is: " + status[2]);

// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderId = string.Empty;
}
} // If the strategy has terminated reset the strategy id
else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
atmStrategyId = string.Empty;


if (atmStrategyId.Length > 0)
{
// You can change the stop price
if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);

// Print some information about the strategy to the output window
Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId));
Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId));
}
}

#region Properties
#endregion
}
}


Sample of Program......the above program with my code inserted into it...….Note!! no backtesting just forward testing no History.....

//
// Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
//

#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.Strategy;
#endregion


// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
///
/// </summary>
[Description("")]
public class TestATM : Strategy
{
#region Variables
private string atmStrategyId = string.Empty;
private string orderId = string.Empty;
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
private int profit = 10; // Default setting for Profit
private int stop = 8; // Default setting for Stop
private int sRParm = 9; // Default setting for SRParm
// 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()
{
Add(DynamicSR_ColorBand(true, Color.Silver, SRParm));
Add(anaSuperTrendU11(3, 2.5, 15, false, anaSuperTrendU11BaseType.Median, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.Simple_Range));
Add(DynamicSR_ColorBand(true, Color.Silver, 3));
Add(anaSuperTrendU11(3, 2.5, 15, false, anaSuperTrendU11BaseType.Median, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.Simple_Range));
SetProfitTarget("", CalculationMode.Ticks, Profit);
SetStopLoss("", CalculationMode.Ticks, Stop, false);


CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// HELP DOCUMENTATION REFERENCE: Please see the Help Guide section "Using ATM Strategies"

// Make sure this strategy does not execute against historical data
if (Historical)
return;


// Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
// **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'AtmStrategyTemplate' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
// Condition set 1
if (Close[0] > DynamicSR_ColorBand(true, Color.Silver, SRParm).Resistance[0]
&& Close[0] > anaSuperTrendU11(3, 2.5, 15, false, anaSuperTrendU11BaseType.Median, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.Simple_Range).StopDot[0]
&& ToTime(Time[0]) > ToTime(9, 30, 0)
&& ToTime(Time[0]) < ToTime(15, 30, 0)
&& Variable0 < MyInput0)
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Market, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
Variable0 = 1;
}
// Condition set 2
if (Close[0] < DynamicSR_ColorBand(true, Color.Silver, SRParm).Support[0]
&& Close[0] < anaSuperTrendU11(3, 2.5, 15, false, anaSuperTrendU11BaseType.Median, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.Simple_Range).StopDot[0]
&& ToTime(Time[0]) > ToTime(9, 30, 0)
&& ToTime(Time[0]) < ToTime(15, 30, 0)
&& Variable1 < MyInput0)
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Market, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
Variable1 = 1;
}

// Condition set 3
if (Close[0] < DynamicSR_ColorBand(true, Color.Silver, SRParm).Resistance[0])
{
Variable0 = 0;
}

// Condition set 4
if (Open[0] > DynamicSR_ColorBand(true, Color.Silver, SRParm).Support[0])
{
Variable1 = 0;

}

// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);

// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
if (status.GetLength(0) > 0)
{
// Print out some information about the order to the output window
Print("The entry order average fill price is: " + status[0]);
Print("The entry order filled amount is: " + status[1]);
Print("The entry order order state is: " + status[2]);

// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderId = string.Empty;
}
} // If the strategy has terminated reset the strategy id
else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
atmStrategyId = string.Empty;


if (atmStrategyId.Length > 0)
{
// You can change the stop price
// if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
// AtmStrategyChangeStopTarget(0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);

// Print some information about the strategy to the output window
Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId));
Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId));
}
}

#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int Profit
{
get { return profit; }
set { profit = Math.Max(1, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int Stop
{
get { return stop; }
set { stop = Math.Max(1, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int SRParm
{
get { return sRParm; }
set { sRParm = Math.Max(1, value); }
}

#endregion
}
}


Above ….with my strategy inserted.....

Reply With Quote
Thanked by:
  #54 (permalink)
 jmont1 
New York, NY
 
Experience: Intermediate
Platform: NinjaTrader8
Broker: Data = Rithmic -- Gives 70 Level II Data
Trading: 6C (Low Margin,) 6E, CL, GC, ES and Maybe DX for smaller tick value
Posts: 1,394 since May 2011
Thanks Given: 1,719
Thanks Received: 1,020


markbb10 View Post
Hello, I would like a user input in my strategy to be a previously defined Ninja ATM. Is this possible to do with the strategy builder or does anyone have any code samples of how to do it. Thanks, Mark

@markbb10, @loantelligence probably means strategy wizard or builder reference to Strategy Analyzer to cull that code. But LoanIntelligence's plan does require you to break the NT8 SB code which means it limits your ability to keep throwing "What Ifs" at the strategy. Apologize if I am misreading it loantelligence.

If you want to stay within the Strategy Builder and have an ATM sort of capability it can be a bit difficult because Strategy Builder is never expected to add an ATM call even though many have requested it.

So the forum created a thread for how to do it "manually" in strategy builder so you can continue to do "what If's."

https://forum.ninjatrader.com/forum/suggestions-and-feedback/suggestions-and-feedback-aa/103992-request-breakeven-functions-in-strategy-builder

It can build out to 26 or more steps for a complex manual ATM. Plus there is no way to cancel them without ending the strategy while in a trade.

If you find a moderately successful BOT - please post here for others to help build it out better and point to it in free strategy thread. Unfortunately, apparently when a GOOD/Great strategy is developed - we stop hearing about it and it is lost to the people whom may have assisted in getting there.

Remember there are MILLIONS of traders out there. It is unlikely that sharing something on Futures.io will kill your profitability. In fact assuming you enliven multiple people trying to enter where you do -- it supports your entry level. But try to front run them on the exit --

Good Trading All !!!

Started this thread Reply With Quote
  #55 (permalink)
 loantelligence 
Syracuse, NY
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures/Zen-Fire
Trading: NQ
Posts: 218 since Jan 2011
Thanks Given: 31
Thanks Received: 189

The Dynamic SR Color Band is actually from 6.5....works fine in NT7 though....go to Indicators, Ninja Trader, 6.5, page 18....Dynamic SR....you can change the parms to anything my example is 3, I believe the norm is 21...I also use 9....you can also color the inside of the bands to make them stand out....as I did on my example...

Attached Files
Elite Membership required to download: DynamicSR_ColorBand.zip
Reply With Quote
  #56 (permalink)
 loantelligence 
Syracuse, NY
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures/Zen-Fire
Trading: NQ
Posts: 218 since Jan 2011
Thanks Given: 31
Thanks Received: 189

Jmont1....Thanks...I have been looking for something like that for years.....no one has ever mentioned it before.... theyd all said just code it inside of the ATM example, however no ever knew how......will put some of those examples to work...Steve

Reply With Quote
  #57 (permalink)
 markbb10 
Treasure Coast, Florida
 
Experience: Advanced
Platform: Ninja 8
Trading: Futures
Posts: 135 since Aug 2012
Thanks Given: 57
Thanks Received: 50

@loantelligence Thank you for your post it was very helpful

Reply With Quote
  #58 (permalink)
 loantelligence 
Syracuse, NY
 
Experience: Intermediate
Platform: Ninja Trader
Broker: Mirus Futures/Zen-Fire
Trading: NQ
Posts: 218 since Jan 2011
Thanks Given: 31
Thanks Received: 189

Dynamic S/R with Color V2 also on page 16 indicators, Ninja Trader, 6.5 page 16

Reply With Quote
  #59 (permalink)
 jmont1 
New York, NY
 
Experience: Intermediate
Platform: NinjaTrader8
Broker: Data = Rithmic -- Gives 70 Level II Data
Trading: 6C (Low Margin,) 6E, CL, GC, ES and Maybe DX for smaller tick value
Posts: 1,394 since May 2011
Thanks Given: 1,719
Thanks Received: 1,020

@markbb10, No one replied with how to fix the Trend but that may be OK.

Since I do not code, I understand how frustrating it can be to think you have a great setup but cannot find a way to automate it. So I went a bit further and created a Strategy builder for you. It probably has a better method than the trend signal since it can be adjusted based on the volume.

The indicator has a count that you can see on the Data box for Down and up. So rather than just rely on the standard -1, +1 - I am using the count on the up and down. They are both set to zero now. So below zero is short and above is long. BUT they zero can be adjusted to a number so you could say down needs to be at least -500 or up needs at least 250. This should work better for your testing and can be used for strategy optimization.

As always, if you set this up better and think we all could be helped from other settings OR more likely additional settings on other indicators, PLEASE post. It is highly unlikely in these markets that suddenly you will miss trades from others using similar BOTs.

If you need help figuring this out - you may contact me through a DM.

Attached Files
Elite Membership required to download: WWMAiRbasic1.cs
Started this thread Reply With Quote
Thanked by:
  #60 (permalink)
 markbb10 
Treasure Coast, Florida
 
Experience: Advanced
Platform: Ninja 8
Trading: Futures
Posts: 135 since Aug 2012
Thanks Given: 57
Thanks Received: 50


@jmont1 Thank you VERY much for taking the time and effort to do this. I will load it and play with it tomorrow.

Very Appreciative of your efforts.

Mark

Reply With Quote




Last Updated on November 16, 2021


© 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