Can someone help me to code a signal?
Its a ATR trailing stop. Period 10 and 3 % down.
Also a indicator that plot this on the chart
Thanks in advance!!
help with a code
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: help with a code
When you say, period 10 and 3% down, what does that mean? Do you mean that you're using a 10 period ATR? Also, what does 3% down mean?
Re: help with a code
Hi,
Yes i mean 10 ATR and a stop 3% down from where i bought. In daily chart.
Im sorry if i explain bad but im new in MC
Thank you for your responce!
Yes i mean 10 ATR and a stop 3% down from where i bought. In daily chart.
Im sorry if i explain bad but im new in MC
Thank you for your responce!
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: help with a code
It sounds like you're talking about two different stops:
1. Stop based on a 10-period ATR; and
2. Stop based on a 3% maximum loss.
Is that the case?
1. Stop based on a 10-period ATR; and
2. Stop based on a 3% maximum loss.
Is that the case?
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: help with a code
A really easy way to do this (if you're long) is:
Note that this will not work a stop on the first day you're entered because it calculates the stop for the next bar; therefore, you may want to have some kind of fixed stop for the first day a trade is taken.
To use this with a short position, it's:
Let me know if you have any problems with this.
Code: Select all
If MarketPosition = 1 Then Sell Next Bar At Highest(High,BarsSinceEntry(0)) - (3 * AvgTrueRange(10)) Stop;
To use this with a short position, it's:
Code: Select all
If MarketPosition = -1 Then BuyToCover Next Bar At Lowest(Low,BarsSinceEntry(0)) + (3 * AvgTrueRange(10)) Stop;
Re: help with a code
Thank you very much!!
I have another question:
How to plot this on the chart as dots? So i can visualy see where the stop is
thanks
I have another question:
How to plot this on the chart as dots? So i can visualy see where the stop is
thanks
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: help with a code
See the help information on the TL_ keywords - these are used for drawing trendlines.
TL_New
TL_Delete
TL_SetSize
TL_SetStyle
...
In your case, you will need to "update" the trendline as your stop changes. What I would do is calculate the level of the stop as a separate variable and then use that variable for placing your stop order as well as plotting the trendline.
Check out the samples in the help file regarding trendlines and this should help. If you have any problems, post them here and hopefully we can figure it out.
TL_New
TL_Delete
TL_SetSize
TL_SetStyle
...
In your case, you will need to "update" the trendline as your stop changes. What I would do is calculate the level of the stop as a separate variable and then use that variable for placing your stop order as well as plotting the trendline.
Check out the samples in the help file regarding trendlines and this should help. If you have any problems, post them here and hopefully we can figure it out.
- ABC
- Posts: 721
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 408 times
- Contact:
Re: help with a code
Since MC 9 you can use i_setplotvalue and i_getplotvalue to send plot values from a signal to an indicator and plot them from there. This might be a slightly simpler way to accomplish what you have in mind without having to use trendlines.
Regards,
ABC
Regards,
ABC
Re: help with a code
Thank you very much for your help!
Can you please explain how to use -i_setplotvalue and i_getplotvalue
Im really a beginner in MC
Can you please explain how to use -i_setplotvalue and i_getplotvalue
Im really a beginner in MC
- ABC
- Posts: 721
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 408 times
- Contact:
Re: help with a code
This should provide you with all the information you need: https://www.multicharts.com/trading-sof ... tplotvalue