Click here to Login





                                                   Turn SetSimStop orders on/off in optimization using If statement

  0

0
Kiran
2015-05-31 13:56:41


Is there an IF statement in the strategy script so i can turn on and off SetSimStop orders? Below is example of what I'm trying to achieve, but "If" isn't a valid command
Pl suggest how to achieve this ..

Optimize("useSL",0,1,1);
if (useSL) SetSimStop(_StopLoss,_Point, sl*TickSize(),1);
if (useSL) SetSimStop(_StopProfit,_Point,pt*TickSize(),1);



QuantShare
2015-06-01 03:07:55

  0

There is no "if" command.

You can use "iff". Example:
a = iff(close > 10, 1, 0);

But as you can see this wouldn't work with the "SetSimStop". You need to use the money management script or use something like this:

Optimize("useSL",0,1,1);
t = iff(userSL, 1, 100000);
SetSimStop(_StopLoss,_Point, sl*TickSize()*t,1); // by multiplying the level with 100000, the stop will be reached



Kiran
2016-11-19 14:38:05

  0

I tried this code below, but it the SetSimStop doesn't recognize the iff condition 1. i.e. I see some trades where the StopProfit is triggered at 4.5% (not 1000%) even though ref(open,1)<ref(close,1).
It's the same issue with the other iff condition 2, so the issue isn't related to the peak-ahead I'm doing in condition1.

Pl advise how to fix it. The reason i'm using this condition is to remove the Peak-ahead bias that is introduced by the Same-Day-Stop (as entry), so I have more realistic backtest results.

pt=4.5;
sellPt = iff(ref(open,-1)<ref(close,-1),pt,1000); //iff condition1 - trigger SameDay Profit Stop only if UpCandle.
//sellPt = iff(open<close,pt,1000); // iff condition 2
SetSimStop(_StopProfit, _Percent, sellPt, 65);



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
Minimum Variance Optimization with Solver V1.1- AMM
Turn of the Month in Equity Indexes
Strategy Optimization on Random in-sample and out-of-sample Perio...
Market Volatility - Composite Indicator using Stocks Standard Dev...
Put-Call Ratio Index using Market Makers Trades

How-to Lessons
How to get trading orders from a portfolio programmatically
How to optimize a neural network using a genetic algorithm
How to plot a stock using different periods in the same chart
How to calculate the average of a time series using the money man...
How to draw an horizontal segment line using QS language

Related Forum Threads
Plotting 3D Surface Plots in Excel using Optimization Data
Trading system optimization using the QuantShare API Simulator
In-Sample and Out-Of-Sample Dates for Optimization
AI Optimization of Ranking
Default Value in Optimization

Blog Posts
How to Switch On/Off Trading Rules in Your Stock Trading System
Optimization of trading rules
Charting, Backtesting and Trading using Fundamental Data
Backtesting trading strategies using intraday data
Basic trading system implemented using the money management tool









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.