Atm strategy help - futures io
futures io futures trading



Atm strategy help


Discussion in NinjaTrader

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Atm strategy help

(login for full post details)
  #1 (permalink)
NEW BRUNSWICK
 
Experience: Intermediate
Platform: ninjatrader
Trading: nq
 
Posts: 11 since Jun 2020
Thanks: 2 given, 0 received

below is a atm strategy that i want to build but i dont know why is not working how is suppose to





protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;

if(State == State.Historical)
return;


if (orderIdL.Length == 0 &&
atmStrategyIdL.Length == 0
&& (Stochastics1.K[0] < 20)



{
isAtmStrategyCreatedL = false;
atmStrategyIdL = GetAtmStrategyUniqueId();
orderIdL = GetAtmStrategyUniqueId();
AtmStrategyCreate(OrderAction.Buy, OrderType.Market, Low[0], 0, TimeInForce.Day, orderIdL, "ES-LONG", atmStrategyIdL, (atmCallbackErrorCode, atmCallBackId) => {

if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyIdL)
isAtmStrategyCreatedL = true;
});



}
if (orderIdS.Length == 0 &&
atmStrategyIdS.Length == 0
&& (Stochastics1.K[0] > 80)

{
CandleOutlineBrush = Brushes.Crimson;
BarBrush = Brushes.Crimson;
}
{
isAtmStrategyCreatedS = false;
atmStrategyIdS = GetAtmStrategyUniqueId();
orderIdS = GetAtmStrategyUniqueId();
AtmStrategyCreate(OrderAction.Buy, OrderType.Market, Low[0], 0, TimeInForce.Day, orderIdS, "ES-SHORT", atmStrategyIdS, (atmCallbackErrorCode, atmCallBackId) => {

if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyIdS)
isAtmStrategyCreatedS = true;
});
}

if (!isAtmStrategyCreatedS)
return;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (orderIdL.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderIdL);

// 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")
orderIdL = string.Empty;
}
} // If the strategy has terminated reset the strategy id
else if (atmStrategyIdL.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyIdL) == Cbi.MarketPosition.Flat)
atmStrategyIdL = string.Empty;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (orderIdS.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderIdS);

// 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")
orderIdS = string.Empty;
}
} // If the strategy has terminated reset the strategy id
else if (atmStrategyIdS.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyIdS) == Cbi.MarketPosition.Flat)
atmStrategyIdS = string.Empty;

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

// Print some information about the strategy to the output window, please note you access the ATM strategy specific position object here
// the ATM would run self contained and would not have an impact on your NinjaScript strategy position and PnL
Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyIdL));
Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyIdL));
Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyIdL));
Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyIdL));

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

// Print some information about the strategy to the output window, please note you access the ATM strategy specific position object here
// the ATM would run self contained and would not have an impact on your NinjaScript strategy position and PnL
Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyIdS));
Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyIdS));
Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyIdS));
Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyIdS));
}
}
}
}}

Reply With Quote

 
Best Threads (Most Thanked)
in the last 7 days on futures io
How did you learn to trade?
137 thanks
2020 profit and loss results
71 thanks
Big Mike in Ecuador
70 thanks
NinjaTrader buys TransAct Futures (Infinity Brokers), plans its own FCM
62 thanks
Whos afraid of the big bad Glitch
45 thanks
 
(login for full post details)
  #2 (permalink)
NEW BRUNSWICK
 
Experience: Intermediate
Platform: ninjatrader
Trading: nq
 
Posts: 11 since Jun 2020
Thanks: 2 given, 0 received

Could anybody tell me what I am doing wrong

Reply With Quote
 
(login for full post details)
  #3 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,352 since Jun 2009
Thanks: 32,032 given, 96,597 received


What is the error message?

darkmarine View Post
Could anybody tell me what I am doing wrong

Sent using the futures.io mobile app

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my Facebook Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:
 
(login for full post details)
  #4 (permalink)
NEW BRUNSWICK
 
Experience: Intermediate
Platform: ninjatrader
Trading: nq
 
Posts: 11 since Jun 2020
Thanks: 2 given, 0 received


Big Mike View Post
What is the error message?


Sent using the futures.io mobile app

Suppose to but when is under 20 and go short when is above 80 but will buy all the time and will never go short

Reply With Quote
 
(login for full post details)
  #5 (permalink)
Sydney Australia
 
 
Posts: 1 since Aug 2020
Thanks: 1 given, 0 received


darkmarine View Post
Suppose to but when is under 20 and go short when is above 80 but will buy all the time and will never go short

It does this because both of your ATM Create orders are Buy

AtmStrategyCreate(OrderAction.Buy

One needs to be a Sell

Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > Atm strategy help


Last Updated on August 9, 2020


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Are you doing what it takes to trade right? w/FuturesTrader71

Jan 21
 

Journal Challenge!

February
 

Battlestations!

March
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts