Hi,
I'm new to using MultiCharts, and have been starting to program my own systems. One of the things I am not sure on is how to set a hard stoploss or take profit in pips (Forex) rather than in % or $ value.
I'm also having troubles finding out to set trailing stops in pips as well.
I tried looking at the manual and searching, but all I can find is how to set up $ or % stops/targets.
Any help would be appreciated.
Setting a Hard Stop/Target in Pips
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Setting a Hard Stop/Target in Pips
You have to manually code this yourself instead of SetDollarTrailing or SetPercentTrailing.One of the things I am not sure on is how to set a hard stoploss or take profit in pips (Forex) rather than in % or $ value.
To do so, you'll need to do the following:
* Calculate the highest price reached during a trade (for long),
* Submit a stop-loss order for that trailed price,
* And reset the variable with the highest price reached when the position is closed.
For example:
Code: Select all
Variables:
highestPriceReached(0);
// Code for long positions
if (MarketPosition(0) = 1) then begin
// Stop-loss is trailed 10 pips here
highestPriceReached = MaxList(highestPriceReached, High - 0.0010);
// Submit trailing stoploss
Sell ("XL Trail") all contracts next bar at highestPriceReached stop;
end; //: Long position
// Reset variable
if (MarketPosition(0) = 0) then
highestPriceReached = 0;
Re: Setting a Hard Stop/Target in Pips
Awesome, thank you Josh. I appreciate it.
Is there a way to trail orders by the more recent swing high/low formed?
Based off of your code, I would assume it would look something like this:
Thanks again,
Clark
Is there a way to trail orders by the more recent swing high/low formed?
Based off of your code, I would assume it would look something like this:
Code: Select all
Vars: s_high (0);
If MarketPosition = 1 then begin
s_low = SwingLow(1, low, 2, 50);
Sell ("LE Stop") 1 contract next bar at s_low stop;
End;
Clark