Hi there,
I have been assigned to do an Indicator with MQL4 and my knowledge on the whole thing is close to zero. This is what i need to do
Take a previous "working" day's stop loss, make it the current days' opening.
After a 10 day period, take an average of all the 9 day stop loss's and create a open trade.
I am not sure how to calculate a stop loss or open trade? i was looking for examples or documentation on this. Could not find any!
Can somebody give me a direction or some code examples to work with this?
Any help is highly appreciated.
Thanks
Vru
Kill two birds with one stone:
https://docs.mql4.com/trading/OrderSend
The link has stoploss, and opening orders information!
Hi c0d3,
Thanks for the response; will look into it - I have anothing question if you dont mind
If i have to regard
Monday as Day1
Tuesday as Day2
Wednesday as Day3
Thursday as Day4
Friday as Day5
Monday as Day6
Tuesday as Day7
Wednesday as Day8
Thursday as Day9
Friday as Day10 - Take profit is done here
and...
Monday becomes Day1
Tuesday is Day2 .....
i am not very sure how i should identify which Monday would be Day1 and which would be Day6 - any in-built functions are something to achieve this?
Thanks
Vru
Hi c0d3,
Thanks for the response; will look into it - I have anothing question if you dont mind
If i have to regard
Monday as Day1
Tuesday as Day2
Wednesday as Day3
Thursday as Day4
Friday as Day5
Monday as Day6
Tuesday as Day7
Wednesday as Day8
Thursday as Day9
Friday as Day10 - Take profit is done here
and...
Monday becomes Day1
Tuesday is Day2 .....
i am not very sure how i should identify which Monday would be Day1 and which would be Day6 - any in-built functions are something to achieve this?
Thanks
Vru
https://docs.mql4.com/dateandtime/DayOfWeek
Hi cod3, i did see that function to get day of week. Thanks for the help; i need a little more direction, i hope you guys dont mind
1. How can i know a previous day's stop loss?
Reason being, i need to set today's stop loss a little lower than the previous days' stop loss. Is it possible?
2. If am looking at weekend's stats; in other words; on a monday, if i am looking a previous day's data(which is sunday) what would i be seeing?
The script am trying to write is for a 10 day period trade;
Day 1 monday, stop loss is taken from 4 days before, wednesday, and set as today's stop loss with a little deduction
Day 2 tuesday, stop loss is taken from 4 days before, thursday, and set as today's stop loss with a little deduction
Day 3 wednesday, stop loss is taken from 4 days before, friday, and set as today's stop loss with a little deduction
Day 4 thursday, stop loss is taken from 4 days before, monday, and set as today's stop loss with a little deduction
Day 5 friday, stop loss is taken from 4 days before, tuesday, and set as today's stop loss with a little deduction
Day 6 monday, stop loss is taken from 4 days before, wednesday, and set as today's stop loss with a little deduction
Day 7 tuesday, stop loss is taken from 4 days before, thursday, and set as today's stop loss with a little deduction
Day 8 wednesday, stop loss is taken from 4 days before, friday, and set as today's stop loss with a little deduction
Day 9 thursday, stop loss is taken from 4 days before, monday, and set as today's stop loss with a little deduction
Day 10 friday, 50% of the difference between stop loss from Day 1 and Day 9 is considered as Open trade, and set for take profit.
The next monday becomes day 1 again and the cycle continues
As i mentioned earlier my knowledge on mql is very very limited. Am having trouble even starting this script(am basically a web developer).
Can somebody please help me with this - i know that the script is small, but it feels big for me.
Thanks
Veeru
Hi cod3, i did see that function to get day of week. Thanks for the help; i need a little more direction, i hope you guys dont mind
1. How can i know a previous day's stop loss?
Reason being, i need to set today's stop loss a little lower than the previous days' stop loss. Is it possible?
2. If am looking at weekend's stats; in other words; on a monday, if i am looking a previous day's data(which is sunday) what would i be seeing?
The script am trying to write is for a 10 day period trade;
Day 1 monday, stop loss is taken from 4 days before, wednesday, and set as today's stop loss with a little deduction
Day 2 tuesday, stop loss is taken from 4 days before, thursday, and set as today's stop loss with a little deduction
Day 3 wednesday, stop loss is taken from 4 days before, friday, and set as today's stop loss with a little deduction
Day 4 thursday, stop loss is taken from 4 days before, monday, and set as today's stop loss with a little deduction
Day 5 friday, stop loss is taken from 4 days before, tuesday, and set as today's stop loss with a little deduction
Day 6 monday, stop loss is taken from 4 days before, wednesday, and set as today's stop loss with a little deduction
Day 7 tuesday, stop loss is taken from 4 days before, thursday, and set as today's stop loss with a little deduction
Day 8 wednesday, stop loss is taken from 4 days before, friday, and set as today's stop loss with a little deduction
Day 9 thursday, stop loss is taken from 4 days before, monday, and set as today's stop loss with a little deduction
Day 10 friday, 50% of the difference between stop loss from Day 1 and Day 9 is considered as Open trade, and set for take profit.
The next monday becomes day 1 again and the cycle continues
As i mentioned earlier my knowledge on mql is very very limited. Am having trouble even starting this script(am basically a web developer).
Can somebody please help me with this - i know that the script is small, but it feels big for me.
Thanks
Veeru
are you setting 1 order per day?
Nope, setting an order on the 10th day
i'm not following what you mean, stoploss of a previous day. How do you know a stoploss has been hit? instead of a takeprofit?
Are you sure it is stoploss, and not previous days low or high, or close or open price?
hi c0d3,
Thanks for you response, probably i am wrong, am just trying to follow a request - i will get back to you, let me ask what exactly the needs are once again
Thanks once again
Edit: Yes he says stop loss; so is there a way to calculate it?
A stoploss is associated 1:1 with an open position, not with a day.
Have you any programming experience?
Seems to me you need to do some reading on a) forex trading and b) how to write in MQL4 - prior to sizing this request.
A stoploss is associated 1:1 with an open position, not with a day.
Have you any programming experience?
Seems to me you need to do some reading on a) forex trading and b) how to write in MQL4 - prior to sizing this request.
I sure am a programmer - but definitely not into forex trading, am into web application development; forex trading is not my cup of tea - this is totally new to me. yeah i guess i need to do some reading, but i thought i could use some tips and help from the forum.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
I have been assigned to do an Indicator with MQL4 and my knowledge on the whole thing is close to zero. This is what i need to do
Take a previous "working" day's stop loss, make it the current days' opening.
After a 10 day period, take an average of all the 9 day stop loss's and create a open trade.
I am not sure how to calculate a stop loss or open trade? i was looking for examples or documentation on this. Could not find any!
Can somebody give me a direction or some code examples to work with this?
Any help is highly appreciated.
Thanks
Vru