MT-4 free source code

trendie

Legendary member
Messages
6,875
Likes
1,433
if anybody wants an alert-type thing using RSI or Stochastics, here is something I did, and have been using on MT-4.

NB: Bar-0 is current bar. Bar-1 is last bar, Bar-2 is bar before that. (ie, it counts backwards)

It looks for OverSold and OverBought conditions on RSI and Stochastics.
(if you dont one of them you "comment them out" by putting "//" in front of the line.)

what it does is see if the indicator has "hooked" beyond the user-defined values.
eg; on RSI, if Upper value is 80, it will give you an alert if the last closed bar (Bar-1) is lower than the bar before AND the bar-before (Bar-2) was above 80. This means the price has hooked down after rising above the threshold value of 80.
similar for Lower values, except the indicator value has to hook upwards after being below the threshold.

this concept is also applied to Stochastics.

the Alert shows:
the currency pair being alerted. eg, GBPUSD
the time-frame on which it triggered, eg, 5 (means on 5-min chart)
a short-code for the event. eg, RSI-OB, RSI-OS, STX-OB, STX-OS.
the date/time it happened, chart-time. NB: this can be different from PC-time, due to brokers, etc.
the CLOSE price of last closed bar. eg, 2.0244
the indicator values changing. eg, 18.50 >> 21.5. (this means the indicator hooked from 18.5 on Bar-2, and was 21.5 on last bar, showing indicator is hooking up)

the alert is by no means perfect, but has removed the psychological element of trying to dither over best-price of when to place a trade, and also takes me away from the screen, reducing over-analysis, and just letting the trade get on with it.

also, the alert acts as a reminder to come and check progress.
ultimately, it is only an aid, and the trader must press the buy and sell buttons themselves.

EDIT: first screen-shot shows the user-interface entering the triggering parameters, eg, RSI value, and the Upper and Lower levels that trigger an alert. similarly for Stochastics lower down in same frame.
second screen-shot shows what the alerts display on the screen. (these can also be sent via SMS to a mobile.)
The attached file, x_RSI_Stochs.txt needs to be saved to the indicators directory, and saved as x_RSI_Stochs.mq4.
 

Attachments

  • xrsi_001.gif
    xrsi_001.gif
    8.9 KB · Views: 720
  • xrsi_002.gif
    xrsi_002.gif
    102.8 KB · Views: 1,503
  • x_RSI_Stochs.txt
    4.6 KB · Views: 860
Last edited:
Pin-Bar noddy indicator.
shows bars where body size (Open-to-Close) is 25% or less of bar-size (High-to-Low).

if the open/close of the small body falls within the top 25% it is flagged as bullish. (blue diamond)
if the open/close of the small body falls within the bottom 25% it is flagged as bearish. (red diamond)
if the open/close of the small body falls within the middle 50% it is flagged as spinning-top.
(white diamond. Yeah, I know, useles if blackground is white!)

for some reason the flags reduce in size if recompiled onto the chart. so, best to close the chart and reload.

NB: the PinBar.txt needs to be renamed as PinBar.mq4 and compiled.

Did it just for fun!

EDIT: added a sample GBPUSD screen.

EDIT2: the indicator does not guarantee that you will make money, and is for educational purposes only. Please seek independant financial advice before blowing money on pretty patterns. :cheesy:
 

Attachments

  • PinBar.txt
    8.6 KB · Views: 1,485
  • pinbarsample.gif
    pinbarsample.gif
    44 KB · Views: 2,837
Last edited:
if anybody wants an alert-type thing using RSI or Stochastics, here is something I did, and have been using on MT-4.

NB: Bar-0 is current bar. Bar-1 is last bar, Bar-2 is bar before that. (ie, it counts backwards)

It looks for OverSold and OverBought conditions on RSI and Stochastics.
(if you dont one of them you "comment them out" by putting "//" in front of the line.)

what it does is see if the indicator has "hooked" beyond the user-defined values.
eg; on RSI, if Upper value is 80, it will give you an alert if the last closed bar (Bar-1) is lower than the bar before AND the bar-before (Bar-2) was above 80. This means the price has hooked down after rising above the threshold value of 80.
similar for Lower values, except the indicator value has to hook upwards after being below the threshold.

this concept is also applied to Stochastics.

the Alert shows:
the currency pair being alerted. eg, GBPUSD
the time-frame on which it triggered, eg, 5 (means on 5-min chart)
a short-code for the event. eg, RSI-OB, RSI-OS, STX-OB, STX-OS.
the date/time it happened, chart-time. NB: this can be different from PC-time, due to brokers, etc.
the CLOSE price of last closed bar. eg, 2.0244
the indicator values changing. eg, 18.50 >> 21.5. (this means the indicator hooked from 18.5 on Bar-2, and was 21.5 on last bar, showing indicator is hooking up)

the alert is by no means perfect, but has removed the psychological element of trying to dither over best-price of when to place a trade, and also takes me away from the screen, reducing over-analysis, and just letting the trade get on with it.

also, the alert acts as a reminder to come and check progress.
ultimately, it is only an aid, and the trader must press the buy and sell buttons themselves.

EDIT: first screen-shot shows the user-interface entering the triggering parameters, eg, RSI value, and the Upper and Lower levels that trigger an alert. similarly for Stochastics lower down in same frame.
second screen-shot shows what the alerts display on the screen. (these can also be sent via SMS to a mobile.)
The attached file, x_RSI_Stochs.txt needs to be saved to the indicators directory, and saved as x_RSI_Stochs.mq4.

Thanks Trendie.

Does this RSI/STOCH indicator draw the red & blue circles on the charts, as shown in your screenshot? or did you add the red/blue circles manually?

Should the MQL code work properly from the .txt file without any further modifications when added to an indicator?

I saved the code from the .txt file to an indicator, but am not getting the stochastic on the sub chart, and am not getting the red & blue circles :(.


:idea:If possible, It would be easier for all concerned I think, if you add the actual indicator to a .zip file, and upload the .zip file, rather than saving/uploading as a .txt file. That way user error does not/cannot be an issue (while transferring the MQL code from the .txt file to the MT4 indicator). :)

Thanks a lot.
:)


EDIT: The sooner T2W allows the uploading of metatrader4 files - the better :).
 
Last edited:
hi JT,

the indicator doesnt show the red and blue circles! those are "demark trend" circles.
(I use them to show me recent swing-highs and swing-lows, and if they congregate at certain prices, they show me potential sup/res points).

they are nothing to do with the RSI indicator I added.
the screen-shot really was meant to illustrate the format of the alerts, not my chart set-up!

all it does is take the ordinary RSI indicator and add alerts when the values hook for RSI.
I then piggy-back the Stochastics alerts only. It doesnt show the stochastics at all - just the alert.

the alert is a short-hand for things I look for. Ideally I should have an alert for the RSI and Stochs separately, but that doesnt interest me.

the .txt needs only to be renamed .mq4 and compiled once there.
 
Top