Hi everyone! This website has been super helpful as I'm very new to coding.
But there's just one thing I could not figure out myself, I really appreciate if someone can assist me.
I am trying to create a trailing stop system based on the AccountProfit() values within the trading period of a single trade.
I would like to know how I can record/store StopLossLevel value when highest AccountProfit() values > 0, on every tick move.
- double CurrentProfit = AccountProfit()
- double HighestProfit = highest AccountProfit() value within the trading period of a single trade
- double StopLossLevel = HighestProfit - 10;
So for example, when HighestProfit is 30, I want my StopLossLevel to be 20 (30 - 10 = 20).
If the CurrentProfit increases to 45, HighestProfit value also becomes 45, then I want my StopLossLevel to be 35 (45 - 10 = 35).
*No new trade will be created when existing positions are open.
*I will use my code which closes open position(s) when CurrentProfit hits StopLessLevel.
*I would like to use AccountProfit() instead of OrderProfit() as I will have more than 1 position depending on conditions.
I hope my explanation makes sense. Really appreciate any input. Thanks!
Keith
- Script for trailing stop needed please?
- How to code?
- Ema Cross!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register