Atm strategy help - futures io
futures io



Atm strategy help


Discussion in NinjaTrader

Updated
    1. trending_up 1,147 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)
 darkmarine 
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));
}
}
}
}}

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
For the experts of Metastock
Platforms and Indicators
Platform/Trade Issue/Question
Emini and Emicro Index
TradingView help in improving Anchored Vwap
Platforms and Indicators
Experience with AGN (Introducing Broker)
Brokers
Time Segmented Volume
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Webinar: Happy Hour w/Cem Karsan
30 thanks
Avoiding Account Killing Freight Trains
20 thanks
Losing faith...
15 thanks
TST/OneUp/LeeLoo/Earn2Trade
14 thanks
Fail to Plan - Plan to Fail: What can go wrong?
13 thanks
 
(login for full post details)
  #2 (permalink)
 darkmarine 
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

Started this thread Reply With Quote
 
(login for full post details)
  #3 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,131 since Jun 2009
Thanks: 32,602 given, 98,794 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/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter 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)
 darkmarine 
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

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
Wickwor
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

Your Charts Should Speak To You w/Bob Cometta

Elite only
 

Our 12-year anniversary w/ $$,$$$ prizes (check soon)

August
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), 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