Click here to Login





                                                   Enter on Trailing Stop

  1

0
Dave W.
2013-11-02 21:34:05


Hi. I'd like to have some systems where I enter via a trailing stop once my setup condition is met. Is this currently possible to do in the Simulator without needing a custom MM script?

If I need a custom money management script, can you give me the code, please?

Also, if this isn't currently do-able without a custom MM script, I'd like to propose it as a feature for a future version of QuantShare.

Thank you.



QuantShare
2013-11-04 14:33:17

  0

Please try this:

stopLossValue = 20; // 20%
a = iff(yourcondition, stopLossValue, 1000);
SetSimStop(_StopTrailing, _Percent, a, 0);



Dave W.
2013-11-10 21:01:08

  0

Hi. I may be doing something wrong, but your suggested solution doesn't appear to be working. Here are two sets of code that are the same except they should enter at different trailing stop entry values. Unfortunately, both sets of code appear to enter at the exact same price.

I also tried the code without a Buy rule, but that didn't take any positions.

// FIRST SET OF CODE
// Buy rules

stopLossValue = 2; // 3%
a = iff(Hhv(close,20), stopLossValue, 1000);
SetSimStop(_StopTrailing, _Percent, a, 0);

Rule1 = Hhv(close,20);
buy = (Rule1);


// SECOND SET OF CODE
// Buy rules

stopLossValue = 10; // 3%
a = iff(Hhv(close,20), stopLossValue, 1000);
SetSimStop(_StopTrailing, _Percent, a, 0);

Rule1 = Hhv(close,20);
buy = (Rule1);






QuantShare
2013-11-11 13:47:45

  0

It doesn't work because "Hhv(close,20)" returns always a value higher than 0 (TRUE). And thus, the "iff" function will always return "stopLossValue".

hhv: Highest over a specific period (It is not a condition)



Dave W.
2013-11-11 18:22:23

  0

Ok... thanks. I fixed that part in the code below, but I'm still getting the same entry price regardless of the stopLossValue. I'm guessing something else is wrong... can you help?



// Buy rules

stopLossValue = 15; // 3%
a = iff(Close > ref(Hhv(close,20),1), stopLossValue, 1000);
SetSimStop(_StopTrailing, _Percent, a, 0);

Rule1 = Close > ref(Hhv(close,20),1);
buy = Rule1;



QuantShare
2013-11-11 19:00:58

  0

In this case, your trailing stop will always be equal to "stopLossValue" since you are using the same rule than the buy rule.
On bars where "buy" is true, the value of "a" variable will be equal to "15".



Dave W.
2013-11-11 21:17:11

  0

Ok. So, this conversation started with my objective: ENTER on a trailing stop when my buy condition is true. My buy condition is to buy when the close > ref(hhv(close,20),1). Given that condition and my objective, what do I do to enter on a trailing stop?

Thanks.



QuantShare
2013-11-12 11:53:25

  1

If you want to have a trailing stop each time you enter a position then simply type:

SetSimStop(_StopTrailing, _Percent, 10, 0);

If you want to have a different trailing stop level then type for example:

stopLossValue1 = 15;
stopLossValue2 = 30;
condTS = close > open;
a = iff(condTS, stopLossValue1, stopLossValue2);
SetSimStop(_StopTrailing, _Percent, a, 0);

Rule1 = Close > ref(Hhv(close,20),1);
buy = Rule1;


// If condTS is equal to Rule1 (like it was the case in your example) then you will always add a trailing stop with "stopLossValue1" as level




Dave W.
2013-11-12 18:47:26

  0

We may be having a communication issue. I want to ENTER A NEW POSITION using a TRAILING STOP ENTRY. I do NOT want to activate a trailing stop EXIT after I've already entered.

When you ENTER on a trailing stop, you get a buy condition first. Then, before the position is entered, the trailing stop entry logic is activated. For example, if you have an ENTRY trailing stop of 3%, after the buy logic is triggered, the entry price will change as the instrument being bought declines. The entry price will be 3% off the lowest low (AFTER the buy / setup logic has been triggered).

My apologies if you already understand what I'm looking for, but I'm sensing from your answered we may not be on the same page. Is an ENTRY on a trailing stop (as described above) something that can be done without a custom MM script? If you need a custom MM script, can you point me to some similar MM code I can leverage?

Thank you.



QuantShare
2013-11-12 20:51:56

  0

For this, you must set up a STOP order then adjusting the stop order in the "OnEndPeriod" event of your money management script.



QuantShare
2013-11-12 20:53:05

  0

Best Answer
Check this




Transform any order into a limit order selectively based on a trading rule (by Tom Huggens, uploaded several months ago)
No notes

Rate an item Rate an item Rate an item Rate an item Rate an item Number of downloads Notes Report an item

Dave W.
2013-11-13 19:15:47

  0

Ok. Thanks. I'll take a stab at creating a money management script to do it and will email you if I need help.


No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Entry Trailing Stop V2
Entry Trailing Stop
Conditional Trailing Stop Exit 2013-10-18
Decreasing the Trailing Stop Level every Trading Bar
Stop Mgmt v 1.1

How-to Lessons
How to optimize the stop limit of a trading system
How to create a volatility-based Stop - Dynamic stop based on the...
How to optimize the number of positions in a trading system
How to create a trading system
How to display the number of stocks per day for different RSI gro...

Related Forum Threads
Profit loss protection trailing stop line on chart .
Trailing stop value with Intraday data
Trailing Stop With Condition
Getting a Long Trailing stop to use Bid data
How can I build up an trailing stop limit buy order

Blog Posts
Limit and Market orders
Example of a trading system implemented in QuantShare Software
Trading Orders - Part 1
Trading System: Buy Stocks based on their Sharpe Ratio Rank
How to get buy and sell orders for a portfolio based on a trading...









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.