Signal Trailing stop loss not working as per code. - futures io
futures io futures trading



Signal Trailing stop loss not working as per code.


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one KumarHarsh with 3 posts (0 thanks)
    2. looks_two Timot with 2 posts (0 thanks)
    3. looks_3 Nicolas11 with 2 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 4,461 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 7 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
 

Signal Trailing stop loss not working as per code.

(login for full post details)
  #1 (permalink)
Mumbai Maharashta India
 
 
Posts: 4 since Sep 2012
Thanks: 3 given, 1 received

I am using a trailing dollar stop loss by following exponential moving average. I have modified trailing stop loss so that I can set stop loss to the ema value at the end of each bar. So only if the price hits the ema value the position is exited.

However, I noticed that the stop loss is being hit even when the ema is still far away from the lowest point. Is there an error in the way I have coded this?

I have attached the image.

[IntrabarOrderGeneration = False]
inputs: PositionBasis( false ), EMA_Length ( 10 );

variables: Amount ( 0 );

Amount = Close - XAverage(Close, EMA_Length );

if PositionBasis then
SetStopPosition
else
SetStopShare ;

if MarketPosition = 1 then
setdollartrailing( Amount) ;

Reply With Quote

Can you help answer these questions
from other members on futures io?
Work with historical tcks data on MUltichart NET PowerLa …
MultiCharts
If ES tracks SPX, why do support/resistance, Level 2, vo …
Emini and Emicro Index
COTbase for quant trading?
Elite Algorithmic NinjaTrader Trading
Cross border fund flows / fx correlations
Treasury Notes and Bonds
NT8 indicator to simulate a Funding Evaluation where to …
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Selling Options on Futures?
109 thanks
Battlestations: Show us your trading desks!
108 thanks
Rank your Futures vs Stocks trading priority
55 thanks
Want your NinjaTrader indicator created, free?
27 thanks
Whats this confusion with margins?
21 thanks
 
(login for full post details)
  #3 (permalink)
London
 
 
Posts: 26 since May 2011



KumarHarsh View Post
I am using a trailing dollar stop loss by following exponential moving average. I have modified trailing stop loss so that I can set stop loss to the ema value at the end of each bar. So only if the price hits the ema value the position is exited.

Then I don't understand why you use the trailing stop function. Just use a stop order at the value of the ema. Unless I am missing something.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
 
Nicolas11's Avatar
 
Posts: 1,071 since Aug 2011
Thanks: 2,232 given, 1,751 received

Hi,

It may also depend on the instrument you trade.

You use:
setdollartrailing( Amount) ;

But are you sure that Amount as defined in your code is expressed in $?
For sure, it is expressed in price (I mean: the price displayed on the screen).
But, except for equities (?), this is not $.
In order to obtain $, you have to multiply it with the value of a full point in $.

Nicolas

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #5 (permalink)
Mumbai Maharashta India
 
 
Posts: 4 since Sep 2012
Thanks: 3 given, 1 received

Dear Nicolas,

How do I go about doing this? How do I modify the code to take this into account?

Regards

Harsh


Nicolas11 View Post
Hi,

It may also depend on the instrument you trade.

You use:
setdollartrailing( Amount) ;

But are you sure that Amount as defined in your code is expressed in $?
For sure, it is expressed in price (I mean: the price displayed on the screen).
But, except for equities (?), this is not $.
In order to obtain $, you have to multiply it with the value of a full point in $.

Nicolas


Reply With Quote
 
(login for full post details)
  #6 (permalink)
Mumbai Maharashta India
 
 
Posts: 4 since Sep 2012
Thanks: 3 given, 1 received


Timot View Post
Then I don't understand why you use the trailing stop function. Just use a stop order at the value of the ema. Unless I am missing something.

Dear Timot,

Thanks but I tired it. It just started trailing the close price. I am sure I have made a mistake. How can I rectify it?

Regards

Harsh

Reply With Quote
 
(login for full post details)
  #7 (permalink)
London
 
 
Posts: 26 since May 2011


KumarHarsh View Post
Dear Nicolas,

How do I go about doing this? How do I modify the code to take this into account?

Regards

Harsh

I think you must multiply it by BigPointValue. Good suggestion by Nicolas11. But still my question stands.

Reply With Quote
 
(login for full post details)
  #8 (permalink)
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
 
Nicolas11's Avatar
 
Posts: 1,071 since Aug 2011
Thanks: 2,232 given, 1,751 received


KumarHarsh View Post
Dear Nicolas,

How do I go about doing this? How do I modify the code to take this into account?

Regards

Harsh

First, I do not pretend that my answer closes the issue. There may be other problems in your code. I am not in position to review it. Read carefully the comments made by other futures.io (formerly BMT) members.

To implement my suggestion, just multiply Amount by the value of a full point in $.
You should know it for the instruments you trade.
Otherwise, you can use BigPointValue.
But I think it requires this field to be correctly input in QuoteManager (to be checked).

Nicolas

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Nicolas11 for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Signal Trailing stop loss not working as per code.


Last Updated on September 17, 2012


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

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

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



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