• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 6:16pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 6:16pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

4H Stochs Email Alert Code Help Please 19 replies

Help - any tools that can easily convert MQL4 code to Easy Language code? 7 replies

Please help code addition to -AmazingEA- 1 reply

Need Help please : Check code on Divergence Indicator 4 replies

Please help add email alert to code 1 reply

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 3
Attachments: Help me with this code please!
Exit Attachments
Tags: Help me with this code please!
Cancel

Help me with this code please!

  • Post #1
  • Quote
  • First Post: Edited Jul 14, 2020 3:15am Jul 13, 2020 10:34am | Edited Jul 14, 2020 3:15am
  •  2tjv
  • | Joined Aug 2018 | Status: Member | 28 Posts
Hi guys,
I'm just a trader, not coder and I just want to create an indi for my trading purpose. So I started learning how to code a few weeks ago. Indi which I want to create displays numbers below the bars right at the time I want during the day. Then, it will repeat the next day. You can see the image below (the image has a gray background).
EX: At 08:00, number 1 is displayed on Low of the bar then 2, 3, 4, 5... then at 15:00, it will stop displaying and repeating tomorrow.
I tried to search and code. When I compiled and tested it (look at the image has a black background):

  1. The numbers weren't on Low of the bars, they were in the middle of the bars.
  2. The numbers didn't repeat. They did not go back to number 1 the next day. They just kept moving forward.

How can I fix guys???? Here the code:

Inserted Code
//+------------------------------------------------------------------+
#define HR2400 86400
#define SECONDS uint
SECONDS time(datetime when=0){return SECONDS(when==0?TimeCurrent():when)%HR2400;}
datetime date(datetime when=0){return datetime((when==0?TimeCurrent():when)-time(when));}
//---
bool TradingTime(SECONDS start,SECONDS end,datetime when=0)
{
SECONDS now=time(when);
return start<end?start<=now&&now<end:!TradingTime(end,start,when);
}
//--------------------------------------------------------------------
bool PlotText(string name, bool del=false, int win=0, datetime dt=0, double prc=0, string text="", int clr=0, int size=12, string font="Arial", double angle=0, bool bg=false, ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER)
{
if(del)ObjectDelete(name);
win=MathMax(win,0);
if(clr<0)clr=White;
size=MathMax(size,8);
if (ObjectFind(name)<0)
ObjectCreate(name,OBJ_TEXT,win,dt,prc);
ObjectSetText(name,text,size,font,clr);
ObjectSet(name,OBJPROP_BACK,bg);
ObjectSet(name,OBJPROP_ANGLE,angle);
ObjectSet(name,OBJPROP_ANCHOR,anchor);
return(true);
}
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
#define HR0900 32400
#define HR1500 54000
if(NewBar()&&TradingTime(HR0900,HR1500))
{
static int count=0;
count++;
PlotText("Number"+(string)count,true,0,Time[0],Low[0],(string)count,clrRed,8,"Arial",0,true,ANCHOR_UPPER);
}
return(rates_total);
}
//+------------------------------------------------------------------+
bool NewBar()
{
static datetime lastbar;
datetime curbar = Time[0];
if(lastbar!=curbar)
{
lastbar=curbar;
return(true);
}
else
{
return(false);
}
}
//+------------------------------------------------------------------+
Attached Image(s) (click to enlarge)
Click to Enlarge

Name: EURUSDM5__1.png
Size: 21 KB
Click to Enlarge

Name: EURUSDM5test.png
Size: 69 KB
  • Post #2
  • Quote
  • Jul 14, 2020 9:16am Jul 14, 2020 9:16am
  •  j11
  • | Joined Jun 2016 | Status: Member | 95 Posts
Hope this is what you meant?

HTH
Attached File(s)
File Type: mq4 2jtv.mq4   4 KB | 73 downloads
If it was easy then I would do it !!
 
1
  • Post #3
  • Quote
  • Jul 14, 2020 10:23pm Jul 14, 2020 10:23pm
  •  2tjv
  • | Joined Aug 2018 | Status: Member | 28 Posts
Quoting j11
Disliked
Hope this is what you meant? HTH {file}
Ignored
OMG Bruhhhhhh....................
Yes! This is what I meant.
Unbelievable! I searched a lot for this indicator until I found nothing. I started to learn how to code just for this indicator. Then, you came and showed up to me.
Did you write this code, j11?
Thank you so much! Thank you very much! Appreciated!
 
 
  • Post #4
  • Quote
  • Jul 15, 2020 1:18am Jul 15, 2020 1:18am
  •  j11
  • | Joined Jun 2016 | Status: Member | 95 Posts
Pleased it helped.

Yes I wrote it .... but not necessarily best way to do it.
If it was easy then I would do it !!
 
 
  • Post #5
  • Quote
  • Last Post: Jul 15, 2020 2:49am Jul 15, 2020 2:49am
  •  2tjv
  • | Joined Aug 2018 | Status: Member | 28 Posts
Quoting j11
Disliked
Pleased it helped. Yes I wrote it .... but not necessarily best way to do it.
Ignored
It works very well. I'm using it right now.
Again, Thank you so much for this!
 
 
  • Platform Tech
  • /
  • Help me with this code please!
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023