Click here to Login





                                                   Stop Loss effective only for 1st 2 bar of order ..

  0

0
Kiran
2015-06-05 01:22:58


I added this MM script to my strategy, that disables the Stop Loss orders in the strategy after N bars. I set it to 2, because i have other Exit Rules that exit more profitably after 2 bars.
http://www.quantshare.com/item-1159-stop-mgmt-v-11

This MM script seems to disable all Stop Loss orders even on the first few days, as no Stop Orders are generated - i tested with N=10 or 20, but same issue.
Below is the code (quite small) - is there some bug in it?

OnStartSimulation
-------------------------
Functions.SetNumericInput("Number of Bars", 10, "Number of bars to keep the Stop Loss active");


OnEndPeriod
------------------
double nbdays = (double)Variables.GetVariable("Number of Bars");
MMPosition[] positions = Portfolio.GetOpenPositions();
for(int i=0;i<positions.Length;i++)
{
if(positions[i].BarsSinceEntry > nbdays)
{
positions[i].StopSettings.StopLossEnabled = false;
}
}





Stop Loss for the N-first Trading Bars only (by The trader, 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

QuantShare
2015-06-06 00:09:17

  0

I see no issue in the code. it should be working and disabling stop loss only after "nbdays".
How are you entering orders? Using the script editor (QS language) or money management script?



Kiran
2015-06-14 18:55:32

  0

Orders are entered in the script editor - I have a Stop Loss order (sl*TickSize(), where sl is a parameter from 2->10) and a formula-based Sell Limit and Buy Limit orders.
The MM script seems to disable Stop Losses because none of the trades in my simulation are Stop Loss even if i have it enabled for multiple bars.
When i delete the MM script, i see Stop Loss executions with 1-2 bars (which should have triggered with the MM script).

-> I noticed that the StopLossEnabled flag is not prompted by the C# code-prompt when i click 'ctrl-space' , so i was wondering if the code is unsupported/legacy.

Pl try and advise ..

thanks
Kiran



QuantShare
2015-06-17 17:10:54

  0

Sorry Kiran. "StopLossEnabled" and "NBarsStopOption" are global settings. If you change it for one symbol, all other symbols will be affected.

Instead of disabling a stop, you should put a very far value that will never be triggered.




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
Stop Loss for the N-first Trading Bars only
Decreasing the Trailing Stop Level every Trading Bar
Return per Bar Stop - Money Management Strategy
Random Value for Each Trading Bar
Disable or Enable your Stop Rules

How-to Lessons
How to download EOD quotes for active and valid stocks only
How to set order type of a trading system programmatically
How to display the bar index of a stock on a chart
How to create a volatility-based Stop - Dynamic stop based on the...
How to optimize the stop limit of a trading system

Related Forum Threads
Stop Loss for Intraday Trading System
Setting stop loss for each trade
Stop Loss behavior
How can I build up an trailing stop limit buy order
example of advanced money management tool Stop Order

Blog Posts
How to Download Trading Data for Certain Securities Only
How to Select the Best Market Indicator for your Trading System
How to get buy and sell orders for a portfolio based on a trading...
How to Backtest Your Trading System for Each Industry
6 New Ways to Download Free Intraday Data for the U.S. Stock Mark...









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.