NexusFi: Find Your Edge


Home Menu

 





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 5,446 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Signal Trailing stop loss not working as per code.

  #1 (permalink)
KumarHarsh
Mumbai Maharashta India
 
Posts: 4 since Sep 2012
Thanks Given: 3
Thanks Received: 1

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 NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
18 thanks
  #3 (permalink)
 Timot 
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
  #4 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

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 NexusFi Trade Journal Reply With Quote
  #5 (permalink)
KumarHarsh
Mumbai Maharashta India
 
Posts: 4 since Sep 2012
Thanks Given: 3
Thanks Received: 1

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
  #6 (permalink)
KumarHarsh
Mumbai Maharashta India
 
Posts: 4 since Sep 2012
Thanks Given: 3
Thanks Received: 1


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
  #7 (permalink)
 Timot 
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
  #8 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769


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 NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on September 17, 2012


© 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