code for different entry conditions for optimizer - futures io
futures io futures trading

code for different entry conditions for optimizer

Discussion in NinjaTrader

    1. trending_up 350 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 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

code for different entry conditions for optimizer

(login for full post details)
  #1 (permalink)
Prague Czech republic
Experience: Beginner
Platform: Ninjatrader
Trading: Futures
Posts: 4 since Sep 2015
Thanks: 1 given, 0 received

Hello, I am working on a strategy usable for optimizer to work with different entry conditions and can not get over this problem. First of all my code:

#region Variables
private int entryoption= 1; //I can choose between 1 and 2 (or more )which will be choosing between 2 entry conditions (or more)

I also have

private int entrycondition1 = 0;
private int entrycondition2 = 0;
private double entrypoint = 0;

and my condition in protected override void OnBarUpdate():

if (entryoption==1) { entrycondition1 =1; entrycondition2 =0;}
if (entryoption==2) { entrycondition1 =0; entrycondition2 =1;}

(in firts case, strategy will work with entrycondition1, in second case with entryconditon2)

now when I know which entrycondition it will use, I need to define entrypoint:

if (entrycondition1==1) { entrypoint =High[1]}
if (entrycondition2==1) { entrypoint =Low[1]}

(both of them define entrypoint, but it does not matter, because these conditions can not work at the same time, always only one of them).
if ((entrycondition1==1)
&& (Close[0]> entrypoint))
EnterLong(DefaultQuantity, "long");

(or second option)

if ((entrycondition2==1)
&& (Close[0]> entrypoint))
EnterLong(DefaultQuantity, "long");

However, it gives me not right results....In first case entry should be above High[1], in second case above Low[1].Problem must be somewhere in entrypoint, because if I do not use entrypoint and write :
if ((entrycondition1==1)
&& (Close[0]> High[0]))
EnterLong(DefaultQuantity, "long");

it works. However I am planning to have about 10 different variable entries(entrycondition1,entrycondition2, entrycondition3 etc.), so I need this entrypoint. Lets say that I want to keep logic for entry order is still the same for every entrycondition.
if ((entryconditionX==1)
&& (Close[0]> entrypoint))
EnterLong(DefaultQuantity, "long");

but only what will be defined and different for every entrycondition, will be entrypoint...How to achieve that? In my opinion, if I choose, entryoption==1, it will trigger entrycondition1==1, which will leads to entrypoint= High[0]. In otherwords - I want to achieve, that my entry logic is always same (Close[0]> entrypoint)), only entrypoint has many definitions and I will choose one of them from variables (entryoption)...What I am doing wrong?
I will be happy for any idea or help. I searched this forum, tried ninjatrader forum, but still can not move forward with it and of course solution will be so simple that I can not simply see it . Thank you Tomas

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
Short Interest Ratio indicator?
Cross border fund flows / fx correlations
Treasury Notes and Bonds
Volume Profile Indicator for Ninja Script in NT8
Indicators for pair trading MES and M2K
Platforms and Indicators
Trading Reviews and Vendors
Best Threads (Most Thanked)
in the last 7 days on futures io
Battlestations: Show us your trading desks!
137 thanks
Want your NinjaTrader indicator created, free?
32 thanks
Big Mike in Ecuador
30 thanks
Saturday Morning Market Replay!
20 thanks
Selling Options on Futures?
19 thanks

futures io Trading Community Platforms and Indicators NinjaTrader > code for different entry conditions for optimizer

Last Updated on July 5, 2018

Upcoming Webinars and Events

NinjaTrader Indicator Challenge!


Battlestations! Show us your trading desk - $1,500 in prizes!


Importance of Finding Your Own Way w/Adam Grimes

Elite only

Journal Challenge w/Jigsaw


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