NexusFi: Find Your Edge


Home Menu

 





Close position when EMA equals entry price


Discussion in NinjaTrader

Updated
    1. trending_up 1,811 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 1 attachments




 
Search this Thread

Close position when EMA equals entry price

  #1 (permalink)
AquaLife
Amsterdam
 
Posts: 3 since Oct 2014
Thanks Given: 1
Thanks Received: 0

Hi all,

I'm currently working on my first automated strategy and I'm having some problems with the following;

When the EMA is equal to the entry price --> Close position at market.
Im currently using the following coding, but I cant figure out why it doesn't work. Note that I don't get a coding error, but when I use the strategy analyser, the position is closed out on a different spot.

if (EMA(100)[0] == Position.AvgPrice);
{
ExitShort(0, 30000, "ExitEMAShort", "");
}

As you can see in the attached picture, the position is closed out only a few bars after the entry while the EMA is not near the entry price and I can't figure out why it closes the position at this specific price.
Could anyone help me out with this?

Thanks in advance!

Dennis

Attached Thumbnails
Click image for larger version

Name:	Clarification.png
Views:	194
Size:	63.6 KB
ID:	162324  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
27 thanks
Tao te Trade: way of the WLD
23 thanks
Diary of a simple price action trader
22 thanks
My NQ Trading Journal
14 thanks
GFIs1 1 DAX trade per day journal
9 thanks
  #3 (permalink)
 NW27 
Newcastle, Australia
 
Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker: IB
Trading: SPI,FTSE100, 6E, 6A
Posts: 285 since Oct 2010
Thanks Given: 108
Thanks Received: 188


Try removing the semicolon on the end of the if statement line.
Also don't use == but use <= the price will never be exactly the same.

Reply With Quote
Thanked by:
  #4 (permalink)
AquaLife
Amsterdam
 
Posts: 3 since Oct 2014
Thanks Given: 1
Thanks Received: 0

Thanks, it works now! The sollution is so simple. Now you notice I'm a beginner in coding ninjatrader strategy's.

I'm sure I will be comming with more questions. Is it best to create 1 topic with different questions as they arrise, or should I make a topic for each subject?

Reply With Quote
  #5 (permalink)
 NW27 
Newcastle, Australia
 
Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker: IB
Trading: SPI,FTSE100, 6E, 6A
Posts: 285 since Oct 2010
Thanks Given: 108
Thanks Received: 188

Which ever. Just hope someone responds.

Reply With Quote




Last Updated on October 20, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts