Download MetaTrader 5
To add comments, please log in or register
Having a great idea? Share it on the traders' Forum!
Super Freddy
45
Super Freddy 2014.12.18 08:00 
//|                                             single rectangle.mq4 |
//+------------------------------------------------------------------+
#property copyright "Chart Shapes 2014©"
#property version   "1.00"

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
string shape ="myRectangle";
ENUM_OBJECT myObjectType = OBJ_RECTANGLE;
int windowIndex = 0;
datetime P1_day = D'2014.12.18 00:57:00';
datetime P2_day = D'2014.12.18 02:08:00';
double price1 = 1.23389;
double price2 = 1.22885;

bool ObjectCreate(shape, myObjectType, windowIndex, P1_day, price1, P2_day ,price2);


void OnStart()
  {
//---
   
  }
//+------------------------------------------------------------------+

The aim is simple: draw a rectangle. I understand that I need only two points to plot it: a pair of date/price. I will attempt to fill with color and play with other properties, but first....this basic code won't work. It generates 1 error and 1 warning:


1) "expressions are not allowed ona global scope" (referring to Line 18 "bool ObjectCreate...")

2) missing ')' before ';' referring to Line 18 "...P2_day, price2); ...............don't know! I clearly see the semicolon there!

Keith Watford
Moderator
8023
Keith Watford 2014.12.18 08:52  
void OnStart()
  {
   ObjectCreate(shape, myObjectType, windowIndex, P1_day, price1, P2_day ,price2);

  }
Create the object in start() or init()
/
To add comments, please log in or register