Please help with simple strategy with SMA - NinjaTrader Programming | futures io social day trading
futures io futures trading


Please help with simple strategy with SMA
Updated: Views / Replies:3,178 / 17
Created: by dimkrinichnyi Attachments:3

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
 3  
 
Thread Tools Search this Thread
 

Please help with simple strategy with SMA

  #1 (permalink)
Just starting out...
Moscow
 
Futures Experience: Beginner
Platform: None
Favorite Futures: Stocks
 
Posts: 2 since Jan 2011
Thanks: 2 given, 0 received

Please help with simple strategy with SMA

Dear All.

Please help me.

I want to use very simple strategy - to open long when SMA cross Price in up direction and short when go to down.

I use such a code
if (CrossAbove(Close[0], SMA(Slow), 1) && Close[0]>Open[0])
EnterLong();

But this strategy not working every time when Close Price cross SMA.

What I did wrong?

Thank you

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)
Trading Apprentice
New Delhi, India
 
Futures Experience: Intermediate
Platform: Amibroker
Favorite Futures: Stocks
 
Posts: 14 since Aug 2010
Thanks: 5 given, 6 received


I hope the OP found the solution via strategy wizard.

I'm facing a simple but tough question so would like to use this thread before losing my sanity.

When I use both the SetStopLoss and ExitLong in the OnBarUpdate section, the strategy gives weird results. I have used the wizard to code a simple strategy of MA crossover, now trying to add a stoploss via

if (Position.MarketPosition == MarketPosition.Long)
{
SetStopLoss(CalculationMode.Price, Low[BarsSinceEntry("BUY")+2] - 50* TickSize);
}

IT gives weird results... like same entry and same exit price...............

Please HELP!

Reply With Quote
 
  #4 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received


lurker View Post
I hope the OP found the solution via strategy wizard.

I'm facing a simple but tough question so would like to use this thread before losing my sanity.


IT gives weird results... like same entry and same exit price...............

Please HELP!

Try this. AFTER you tell your strategy to get long, insert this. Where the highlighted variables are your stopSize and profitTarget respectively:

 
Code
			if (Position.MarketPosition == MarketPosition.Long)
			{
					SetStopLoss("Long1", CalculationMode.Price, Position.AvgPrice - (initialStop*TickSize), false);
					SetProfitTarget("Long1", CalculationMode.Ticks, profitTarget);
			}

Reply With Quote
 
  #5 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received


dimkrinichnyi View Post
Dear All.

Please help me.

I want to use very simple strategy - to open long when SMA cross Price in up direction and short when go to down.

For the OP if you're still around, when you use the CrossAbove() Function, you don't need to pass it the index like you are doing.

CrossAbove(), you used the highlighted in red, which is not needed:
 
Code
if (CrossAbove(Close[0], SMA(Slow), 1) && Close[0]>Open[0])
EnterLong();
When you pass it the close, you should do it like so:
 
Code
if (CrossAbove(Close, SMA(Slow), 1) && Close[0]>Open[0])
EnterLong();

Reply With Quote
 
  #6 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,859 since Jun 2009
Thanks: 480 given, 3,255 received


lurker View Post
I hope the OP found the solution via strategy wizard.

I'm facing a simple but tough question so would like to use this thread before losing my sanity.

When I use both the SetStopLoss and ExitLong in the OnBarUpdate section, the strategy gives weird results. I have used the wizard to code a simple strategy of MA crossover, now trying to add a stoploss via

if (Position.MarketPosition == MarketPosition.Long)
{
SetStopLoss(CalculationMode.Price, Low[BarsSinceEntry("BUY")+2] - 50* TickSize);
}

IT gives weird results... like same entry and same exit price...............

Please HELP!

You haven't provided enough details, there are a lot of things that could be causing your problems. I recommend you upload your strategy for further review.

Reply With Quote
 
  #7 (permalink)
Trading Apprentice
New Delhi, India
 
Futures Experience: Intermediate
Platform: Amibroker
Favorite Futures: Stocks
 
Posts: 14 since Aug 2010
Thanks: 5 given, 6 received


shodson View Post
You haven't provided enough details, there are a lot of things that could be causing your problems. I recommend you upload your strategy for further review.

Thanks, here is the code:

 
Code
if (CrossAbove(SMA(MAfast), SMA(MAslow), 1)
                && RSI(15, 1)[0] > 40)
            {
                EnterLong(DefaultQuantity, "Bought");
            }

 if (CrossBelow(SMA(MAfast), SMA(MAslow), 1))
            {
                ExitLong("", "Bought");
            }

            if (Position.MarketPosition == MarketPosition.Long)
            {
                SetStopLoss(CalculationMode.Price, Low[BarsSinceEntry("Bought")+1] + 0.50);
                DrawDot("stoptag1" + CurrentBar, true, 0, Low[BarsSinceEntry("Bought")+1] + 0.50, Color.BlueViolet);
            }
            
            
            
            if (CrossBelow(SMA(MAfast), SMA(MAslow), 1)
                && RSI(15, 1)[0] < 60)
            {
                EnterShort(DefaultQuantity, "Short");
            }
           
            if (Position.MarketPosition == MarketPosition.Short)            
            {
                SetStopLoss(CalculationMode.Price, High[BarsSinceEntry("Short") + 1] + 0.50);
                DrawDot("stoptag2" + CurrentBar, true, 0, High[BarsSinceEntry("Short") + 1] +0.50, Color.BlueViolet);
            }             

            
            if (CrossAbove(SMA(MAfast), SMA(MAslow), 1))
            {
                ExitShort("", "Short");
            }

Reply With Quote
 
  #8 (permalink)
Trading Apprentice
New Delhi, India
 
Futures Experience: Intermediate
Platform: Amibroker
Favorite Futures: Stocks
 
Posts: 14 since Aug 2010
Thanks: 5 given, 6 received


forrestang View Post
Try this. AFTER you tell your strategy to get long, insert this. Where the highlighted variables are your stopSize and profitTarget respectively:

 
Code
            if (Position.MarketPosition == MarketPosition.Long)
            {
                    SetStopLoss("Long1", CalculationMode.Price, Position.AvgPrice - (initialStop*TickSize), false);
                    SetProfitTarget("Long1", CalculationMode.Ticks, profitTarget);
            }

I'll probably need more help with the code

Reply With Quote
 
  #9 (permalink)
Urban Samurai
Chicago IL
 
Futures Experience: Intermediate
Platform: Ninja, MT4,TOS, SC, Matlab
Broker/Data: CQG, AMP, MB, DTN
Favorite Futures: E/U, G/U
 
forrestang's Avatar
 
Posts: 1,039 since Jun 2010
Thanks: 226 given, 688 received


lurker View Post
I'll probably need more help with the code

Also, just something else, when you reset your stoploss when you are in the trade, you are globally changing it. So at the beginning, you might want to check to see if you are flat.... I.e. if you are flat you will want to re-initialize your stop to the original value.

So at the beginning, of onBarUpdate(), you will want to add something like:
 
Code
            if (Position.MarketPosition == MarketPosition.Flat)
            {
                    SetStopLoss("Long1", CalculationMode.Price, Position.AvgPrice - (initialStop*TickSize), false);
             }
Post the .cs file if you could.

Reply With Quote
 
  #10 (permalink)
Trading Apprentice
New Delhi, India
 
Futures Experience: Intermediate
Platform: Amibroker
Favorite Futures: Stocks
 
Posts: 14 since Aug 2010
Thanks: 5 given, 6 received



forrestang View Post
Post the .cs file if you could.

Guess I should have done this earlier... anyways help me out people

The logic is extremely simple... enter with a initial stop loss of previous bar's low; exit when either the stoploss is hit or MA crossover indicates sell.

Attached Files
Register to download File Type: cs tutorial.cs (3.9 KB, 13 views)
Reply With Quote

Reply



futures io > > > > > Please help with simple strategy with SMA

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
SMA Simple Trading websouth NinjaTrader 5 July 14th, 2012 09:56 AM
Simple RSI Strategy frostengine NinjaTrader Programming 2 October 30th, 2011 01:12 PM
Simple HMA Strategy honkin NinjaTrader Programming 5 January 4th, 2011 06:35 PM
Simple strategy vast NinjaTrader Programming 19 August 5th, 2010 06:39 PM
Need help writing a simple strategy soumi71 The Elite Circle 4 November 17th, 2009 01:05 PM


All times are GMT -4. The time now is 05:32 AM.

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-16 in 0.16 seconds with 20 queries on phoenix via your IP 54.160.245.121