Download MetaTrader 5

[HELP/REQUEST] Need some help on getting started with EAs and Scripts

To add comments, please log in or register
Ming
9
Ming  

Hi there,

Firstly, thank you clicking on my post!

I've previously tried my hands on writing Indicators (good enough for personal use, despite having no prior training in programming)

but, please, assume that I have zero knowledge about programming when answering my queries.

I'd like to get started with automating my trades, and would love to have some pros on this forum give me a much needed boost.

The way I learn best is by observing what others do, so I'm going to blatantly ask you to help me write something I need (something fundamental) and then I'll try to learn from your code.

Before I proceed, here's an idea of how much I know about programming:

int init()
{
   return (0);
}

int deinit()
{
   ObjectDelete("Previous Day Low");
   ObjectDelete("Previous Day High");
   ObjectDelete("H1 EMA13");
   return(0);
}

int start()
{
//DEFINE PREVIOUS DAY HIGH & LOW
   double prev_day_high=iHigh(NULL,PERIOD_D1,1);
   double prev_day_low=iLow(NULL,PERIOD_D1,1);
   
//DRAW PREVIOUS DAY HIGH
   ObjectCreate("Previous Day High",OBJ_HLINE,0,0,prev_day_high);
   ObjectSet("Previous Day High",OBJPROP_COLOR,White);
   ObjectSet("Previous Day High",OBJPROP_WIDTH,2);
   ObjectSet("Previous Day High",OBJPROP_STYLE,STYLE_SOLID);
   ObjectSet("Previous Day High",OBJPROP_BACK,true);
   
//DRAW PREVIOUS DAY LOW
   ObjectCreate("Previous Day Low",OBJ_HLINE,0,0,prev_day_low);
   ObjectSet("Previous Day Low",OBJPROP_COLOR,White);
   ObjectSet("Previous Day Low",OBJPROP_WIDTH,2);
   ObjectSet("Previous Day Low",OBJPROP_STYLE,STYLE_SOLID);
   ObjectSet("Previous Day Low",OBJPROP_BACK,true);
   
//DEFINE EMA13
   double H1EMA13=iMA(NULL,PERIOD_H1,13,0,MODE_EMA,PRICE_CLOSE,0);
   
//DRAW EMA13
   ObjectCreate("H1 EMA13",OBJ_HLINE,0,0,H1EMA13);
   ObjectSet("H1 EMA13",OBJPROP_COLOR,Red);
   ObjectSet("H1 EMA13",OBJPROP_WIDTH,2);
   ObjectSet("H1 EMA13",OBJPROP_STYLE,STYLE_SOLID);
   ObjectSet("H1 EMA13",OBJPROP_BACK,true);

//REDRAW
   ObjectsRedraw();
   return (0);
}

Believe me when I tell you I have no clue what half of these stuff is meant for [e.g. init(), deinit(), return(0)]

and why it doesn't (fully) work like I "intended" it to [i.e why doesn't my red line update itself whenever its value changes]

it was good enough for me as an indicator, but I'm aware that it will not be adequate for me to write an EA or a Script.

To help me get started, I hope you can guide me in writing the following EA/Script:

  • BUY when H1 EMA13 (current symbol, apply to close, period 0, shift 0) is greater than the Previous Day's High
  • SELL when H1 EMA13 is lower than the Previous Day's Low
  • Take Profit of 20 pips
  • Stop Loss of 50 pips
This is purely for my educational purposes only (this is, by no means, a sound trading strategy!)

I would love to learn you pros code!

Thank you for reading, and more thanks in advance for teaching me!

Ming
9
Ming  
RaptorUK:

I removed your code . . . .


Please edit your post above and re-insert your code using the SRC button . . . please use the SRC button to post code: How to use the SRC button.

To edit your post . . .




Thanks for the heads up!

I'm new to this forum, apologies for the poor choice of format of my post.

Alain Verleyen
Moderator
32524
Alain Verleyen  

GunkyEnigma:...

Thank you for reading, and more thanks in advance for teaching me!

There are a lot of code to learn from in the Codebase.
whroeder1
15598
whroeder1  
GunkyEnigma: I have no clue what half of these stuff is meant

Since you haven't bothered to learn the language, there is no common language which to communicate. You are wasting everyone's time. RTFM, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.

To add comments, please log in or register