Is There a way to create a flip flop switch with NT? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Is There a way to create a flip flop switch with NT?
Updated: Views / Replies:375 / 3
Created: by Momozo Attachments:0

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

Is There a way to create a flip flop switch with NT?

  #1 (permalink)
Trading Apprentice
fortaleza + ceara/brazil
 
Futures Experience: Advanced
Platform: ninjatrader, amibroker
Favorite Futures: crude oil
 
Posts: 23 since Jun 2014
Thanks: 26 given, 4 received

Is There a way to create a flip flop switch with NT?

Hello! Here I am again!

Well, this time I need some help with a switch device. Let me try to explain (sorry for my bad english):


The system I'm trying to write is not exactly this one, but it uses a similar mechanism.

I use 2 variables.

BuyModeOn and ShortModeOn. When BuyModeOn == 1 and theres a buy signal, I want the system to execute my buy. When BuyModeOn == 0, I want the system to ignore my buy signals. The same with ShortModeOn.

So, lets say BuyModeOn goes 1 when Price moves above an MA. The code I tried is like this:


 
Code
OnBarUpdate()

BuyModeOn = 0;
ShortModeOn = 0;

if (Close[1] < EMA(10)[1]  && Close[0] > EMA(10)[0]) //its a cross above
{
   BuyModeOn = 1;
   ShortModeOn = 0;
   if (//buycondition at the same bar...)
   {
      EnterLong()
   }
}

if (Close[1] > EMA(10)[1]  && Close[0] < EMA(10)[0]) //its a cross below
{
   BuyModeOn = 0;
   ShortModeOn = 1;
   if (//shortcondition at the same bar...)
   {
      EnterShort()
   }
}

if (BuyModeOn == 1 && buycondition...)
{
   EnterLong()
}

if (ShortModeOn == 1 && shortcondition...)
{
   EnterShort()
}
So, the code works... but only at the EXACTLY time of the cross above or below. It seems like the ModeOn values dont hold for the rest of the bars. Why is that? Do I need to make it inside a loop?

PS: While I was writing the thread, I just had the though that its because the variables are inside the OnBarUpdate(), initially setted to 0... So in every bar it becomes as 0... I'll try it soon, but I'll post it anyway... I may be wrong after all.

Thanks in advance!!

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,091 received


Hi @Momozo, it might help you to see things more clearly if you investigate using the 'bool' type for flags and also the built-in CrossAbove and CrossBelow functions. Always keep clear meanings for flags, usually it's a sign of bugs to follow if their meanings and uses starts to merge.

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #4 (permalink)
Trading Apprentice
fortaleza + ceara/brazil
 
Futures Experience: Advanced
Platform: ninjatrader, amibroker
Favorite Futures: crude oil
 
Posts: 23 since Jun 2014
Thanks: 26 given, 4 received


ratfink View Post
Hi @Momozo, it might help you to see things more clearly if you investigate using the 'bool' type for flags and also the built-in CrossAbove and CrossBelow functions. Always keep clear meanings for flags, usually it's a sign of bugs to follow if their meanings and uses starts to merge.


Thanks, Ratfink. I already tried using bool type, using true and false instead of 1 and 0. But it gave me errors. I've spent a lot of time searching for a solution, but with no success.

In Amibroker, there was a function called "flip(condition1, condition2)", that worked for this purpose. When condition 1 gave a true signal, it would remain true until condition 2 became true. Then both conditions became false. Quite handy!

I saw a sample at ninjatrader forum that was exactly like the way i wrote the code, but there was one difference: they used variable0 instead of BuyModeOn (dont know if it influences...).

Well, I'll keep looking. Oh, and I use MRO() for one of the conditions. Do you think it can cause problems?

Reply With Quote
The following user says Thank You to Momozo for this post:

Reply



futures io > > > > > Is There a way to create a flip flop switch with NT?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Coin Flip - bias of an edge Yukoner Traders Hideout 33 March 4th, 2014 09:11 AM
Facebook Flop May Create a Silver Lining for IPO Investors Quick Summary News and Current Events 0 May 21st, 2012 06:10 PM
Dennis Gartman Now Long Of Flip Flopping In Laughing Stock Terms kbit News and Current Events 0 April 4th, 2012 07:43 PM
Flip-flopper-in-chief kbit News and Current Events 4 February 8th, 2012 01:43 AM
Way to flip chart pairs in ninja? nirajkrishna Traders Hideout 4 April 15th, 2011 02:03 PM


All times are GMT -4. The time now is 10:52 PM.

Copyright © 2017 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
Page generated 2017-12-14 in 0.09 seconds with 19 queries on phoenix via your IP 54.90.207.75