Click here to Login

                                                   Trading System Target Profit and Loss prices


Scott Strobeck
2012-10-23 17:17:51


When my trading system makes a decision to buy, I want to be able to set target profit stop (limit order) and stop-loss prices based on the conditions at the time of the purchase? I haven't been able to make this work.

For example:
Buy at open Tomorrow, then sell using profit targets and stop loss:
Buy1 = (close > ref(close,1)*1.1);
Buy2 = (volume > 100000);
Buy3 = (close > 1);
buy = (Buy1) && (Buy2) && (Buy3);
ProfitTarget = ((close - ref(close,1))/ref(close,1))*close <--- I only want this evaluated when the buy trigger is made, not daily
StopLoss = ref(low,1); <--- I only want this evaluated when the buy trigger is made, not daily
SellPrice(StopLoss, ProfitTarget, -1);

When I use something similar to above, positions open, but never close. Is there a way to set specific OCO sell limit and stop orders?


2012-10-23 18:08:41


Best Answer
Here is how to specify a stop based on a custom formula:

To do it with the formula editor, type:
SetSimStop(_StopProfit, _Point, 5, 0); // $5 profit target

You can specify stop orders:
SetSimTiming(_Buy, _Stop, 0);
BuyPrice([Stop Value], 5);

Or stop limit orders:
SetSimTiming(_Buy, _StopLimit, 0);
BuyPrice([Stop Value], [Limit Value], 5);

Scott Strobeck
2013-01-28 16:34:51


Hi. . . Thanks for the reply. I'm coming back around to work on this again, and am still having trouble.

I don't want a constant, nor do I want a dynamic sell price. I want something in between the two. . . I want loss and profit stop prices calculated when entering the position, based on a formula. I want to use those same values until the position exits.

Thank you in advance!

2013-01-28 17:02:53


You can set any formula in place of "5" in "SetSimStop".

Andreas Herrmann
2017-04-02 03:38:53


I have a similar problem like the original post. I want to set a StopLoss to the "Low" of the purchase day. This can NOT be defined by a fixed, percent or indicator rule. Because NONE of those give me the "Low" of the purchase day. Thank you for any help.

No more messages


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"


Trading Items
Design and backtest a trading system with two strategies
Optimizable Fibonacci Long and Short Trading System
MAE and MFE of a Trading System
Adaptive Trading System - Minimum Percent Winners and Percent Inv...
Entry Price and Exit Price in Trading System Report

How-to Lessons
How to optimize the stop limit of a trading system
How to optimize an indicator in your trading system
How to debug a trading system using the money management tool
How to optimize the number of positions in a trading system
How to set order type of a trading system programmatically

Related Forum Threads
Stop Loss for Intraday Trading System
Profit loss protection trailing stop line on chart .
Add a trading system to the price volume chart
Ranking System with Trading System Help, Revisited
Adjust the Entry and exit prices of trades in AMM script

Blog Posts
Trading System Analysis: Backtesting report and custom measures
How to combine long, short and custom portfolio strategies within...
Inverse Fisher Transform: Indicator, composite and trading system
How to build and backtest a robust stock trading system
Day Trading: A trading system that combines intraday and EOD data

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2023
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
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.