Click here to Login





                                                   Money Management Based on Trailing Stops

  0

0
Lars Karlsson
2016-05-31 15:20:02


I'm trying to set up an AMM script for a CFD trend following strategy that uses trailing stops and fixed risk per position.
I need the script to sum up all the "locked in" profits based upon the current trailing stop levels for each active position. These accumulated,
but not yet realized, profits from the trailing stops, plus the available cash in the account, is then used to finance the opening of new positions.

How do I go about to access the trailing stop price level for an open position?



QuantShare
2016-06-01 04:41:22

  0

Best Answer
You need to keep track of the highest high of each position:

MMPosition[] list = Portfolio.GetOpenPositions();
for(int i=0;i < list.Length;i++)
{
MMPosition pos = list[i];
double high = pos.GetValueFromFormula("a=high;", "a");
if(high > pos.Var2)
{
pos.Var2 = high;
}
}

Then get the trailing stop level with something like this:

MMPosition pos = Portfolio.GetPosition("Name");
double level = pos.Var2 + pos.StopSettings.TrailingStop;



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
Money management to Reject Trading Positions Based on their Past ...
Return per Bar Stop - Money Management Strategy
Investing in stocks using the Kelly criterion money management st...
Withdraw a Fixed Amount Every Month - Money Management
Correlation Filter Money Management Strategy

How-to Lessons
How to calculate the average of a time series using the money man...
How to debug a trading system using the money management tool
How to create a volatility-based Stop - Dynamic stop based on the...
How to create trading rules based on Put and Call volume data
How to quickly select stocks based on the last value of a databas...

Related Forum Threads
Example of Money Management
Money management not working correctly
Money Management vs. Trading System
Advanced Money Management
Money Management script and exit options in the wizard

Blog Posts
Several money management strategies in a trading system
Create a trading strategy using the money management tool - Part ...
Basic trading system implemented using the money management tool
Create a trading strategy using the money management tool - Part ...
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.