Can Prior SMA Crossover Price Levels be Stored? - futures io
futures io futures trading



Can Prior SMA Crossover Price Levels be Stored?


Discussion in NinjaTrader

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

Can Prior SMA Crossover Price Levels be Stored?

(login for full post details)
  #1 (permalink)
Brooklyn, NY USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Forex EUR/USD
 
Posts: 12 since Mar 2012
Thanks: 1 given, 1 received

Hello all,

I was thinking about trying my hand at Ninjascript programming to do a simple setups. I wanted to know if there's a way for Ninjatrader to store the particular price level of an SMA associated with an SMA crossover for comparison to a prior identical crossovers that occurred earlier.
For instance, if a 6-period SMA crosses above the 18-period SMA at the close of the current bar Ninjascript (as per instructions) would record the closing price level of the 18-period SMA the crossover occurred on... but the Ninjascript would also have recorded the 18-period SMA price level that occurred on an identical 6/18-period SMA crossover that occurred prior to the current one.
The two 18-period SMA price levels would then be compared to see which is lesser/greater to check for possible momentum.

Would that price level be considered a variable?
Is this possible?
I'm definitely not a programmer, so I ask that the response be in layman's terms.

Thanks in advance for any help provided.

Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(167 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(116 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #2 (permalink)
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 839 received

Maybe try something like,

int crossup = SMA(6)[0] > SMA(18)[0] && SMA(6)[1] < SMA(18)[1] ? 1 : 0;
int crossdown = SMA(6)[0] < SMA(18)[0] && SMA(6)[1] > SMA(18)[1] ? 1 : 0;

Cross1[0] = crossup ==1 || crossdown ==1 ? SMA(18)[0] : Cross1[1];
Cross2[0] = crossup ==1 || crossdown ==1 ? Cross1[1] : Cross2[1];
etc.

Will need to define Cross1 and Cross2 as dataseries.

Reply With Quote
The following user says Thank You to vegasfoster for this post:
 
(login for full post details)
  #3 (permalink)
Brooklyn, NY USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Forex EUR/USD
 
Posts: 12 since Mar 2012
Thanks: 1 given, 1 received


Thanks for your response vegasfoster.

"Maybe try something like,

int crossup = SMA(6)[0] > SMA(18)[0] && SMA(6)[1] < SMA(18)[1] ? 1 : 0;
int crossdown = SMA(6)[0] < SMA(18)[0] && SMA(6)[1] > SMA(18)[1] ? 1 : 0;

Cross1[0] = crossup ==1 || crossdown ==1 ? SMA(18)[0] : Cross1[1];
Cross2[0] = crossup ==1 || crossdown ==1 ? Cross1[1] : Cross2[1];
etc.

Will need to define Cross1 and Cross2 as dataseries.
"

I'm new to Ninjascript programming. I'm not familiar with the "? 1 : 0;" part of the statement. It seems it's referencing a previous and current SMA crossover occurrence. Please correct me if I'm wrong.
The "? SMA(18)[0] : Cross1[1];" and "? Cross1[1] : Cross2[1];" part of the statements I'm not familiar with. Could you give me a brief walk through of the logic?

Started this thread Reply With Quote
 
(login for full post details)
  #4 (permalink)
Brooklyn, NY USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Forex EUR/USD
 
Posts: 12 since Mar 2012
Thanks: 1 given, 1 received

vegasfoster,

I think I may understand the logic. I figure the best way to understand this is to do as much on my own as possible, so I did some brainstorming. Please, at your convenience, let me know if my understanding of the logic is correct.

int crossup = SMA(6)[0] > SMA(18)[0] && SMA(6)[1] < SMA(18)[1] ? 1 : 0;
int crossdown = SMA(6)[0] < SMA(18)[0] && SMA(6)[1] > SMA(18)[1] ? 1 : 0;

Logic: If statement is true value = "1", otherwise it's "0"

Cross1[0] = crossup ==1 || crossdown ==1 ? SMA(18)[0] : Cross1[1];
Logic: whether there's an SMA(18) crossover up or down, value will = SMA(18)[0] price level
which is stored as the 2nd and current SMA crossover price level (Cross1[0])...
... otherwise if the crossover SMA(18) value is not current (1 bar or more ago), it
will be stored as "Cross1[1]", the most recent and last SMA(18) crossover price level.


Cross2[0] = crossup ==1 || crossdown ==1 ? Cross1[1] : Cross2[1];
Logic: whether there's an SMA XO up or down, if a fresh current SMA(18) crossover took place
"Cross1[1]" then becomes the prior SMA(18) crossover price level and
"Cross1[0]" then becomes the current SMA(18) crossover price level
... otherwise when SMA(18) crossover is 1 bar old or more,
"Cross2[1]" becomes the stored prior SMA(18) crossover price level and
"Cross1[1]" becomes the most recent and last SMA(18) crossover price level.

Started this thread Reply With Quote
The following user says Thank You to Piptick for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > Can Prior SMA Crossover Price Levels be Stored?


Last Updated on April 23, 2013


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

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

March
 

Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only
     



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