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

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

Any timeframe or just daily charts 34 EMA trading idea 24 replies

Seeing higher timeframe indicators on lower timeframe 4 replies

ATR indicator of candle body ignoring wick and tail 5 replies

EA for same open/close candle and same high/low wick 5 replies

Help with candle and wick range indicator 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe

How to place characters JUST above a candle wick on any Timeframe?

  • Post #1
  • Quote
  • First Post: Apr 30, 2010 2:19am Apr 30, 2010 2:19am
  •  f451
  • | Joined Mar 2010 | Status: Member | 281 Posts
I can place Objects above candle's wick using ObjectSet with the Price co-ordinate stored in vsa[b] (i.e. based on High[b] or Low[b] as appropriate.
BUT if I add a small gap based on points or a fixed factor, the characters will appear at different distances away from the candles wick depending on the timeframe - because the charts price scale varies.

How can I avoid this?
Get I get the charts current scale?

e.g.

int DisplaySignal(int b)
{

if (signal[b] != EMPTY_VALUE)
{
if (ObjectCreate(text[signal[b]]+" "+sctr, OBJ_ARROW, 0, Time[b], vsa[b]) == true)
{
ObjectSet(text[signal[b]]+" "+sctr, OBJPROP_ARROWCODE, code[signal[b]]);
if (signal[b] > 2)
{
ObjectSet(text[signal[b]]+" "+sctr, OBJPROP_COLOR, Crimson);
ObjectSet(text[signal[b]]+" "+sctr, OBJPROP_XDISTANCE, 20);
SetIndexArrow(3,code[signal[b]]);
//
}
else
{
ObjectSet(text[signal[b]]+" "+sctr, OBJPROP_COLOR, CornflowerBlue);
ObjectSet(text[signal[b]]+" "+sctr, OBJPROP_XDISTANCE, 20);
SetIndexArrow(3,code[signal[b]]);
}
sctr++; Print("Signal[",b,"]=",signal[b]);
}
}

return(0);
}

but the height
  • Post #2
  • Quote
  • Apr 30, 2010 2:53am Apr 30, 2010 2:53am
  •  CodeMeister
  • Joined Sep 2009 | Status: Making Code While Making Pips | 1,672 Posts
http://www.forexfactory.com/showthre...ow#post3582131

This is not an easy problem. I eventually solved it by making it a user setting.
  • Post #3
  • Quote
  • Apr 30, 2010 8:37am Apr 30, 2010 8:37am
  •  BlueMental
  • Joined Nov 2009 | Status: Don't Re- Member | 210 Posts
You have encountered one of the many Mq4 idiosyncrasies.

One of the ways that almost solves the problem is by setting a range variable.

Range=(WindowPriceMax()-WindowPriceMin)/20;

which then gets added to the value of the height. (Or subtracted if below Low[x])

ObjectCreate("Arrow",OBJ_ARROW,WindowVal,DateTimeValue,PriceValue+Range);

This gives you an acceptable gap that remains constant, but can also be a headache that needs the divisor variable altered.

If you want to delve deeper into solving this issue, then you do a high/low of bars viewed, and formulate the percentage height of each bars price related to the windows price range, and add a percentage to the objects height value.

double hi,lo;
hi=-9999;lo=9999;
for(int x=0; x<WindowFirstVisibleBar();x++)
{
hi=MathMax(hi,High[x];
lo=MathMin(lo,Low[x];
}
double PercentVar,PriceForObject;
PriceForObject=WhateverYouChoose;
PercentVar=(1/(hi-lo)*(PriceForObject-lo))*100;
NewPriceForObject=PriceForObject/PercentVar*(PercentVar+PercentAboveRequired)
ObjectCreate("Arrow",OBJ_ARROW,WindowVal,DateTimeValue,NewPriceForObject);

That little formula (the one in bold) puts low as 0 and high as 100.
If however your range changes then the new objects heights vary. But as long as your chart window remains a similar size, it is fine because the range remains the same locally.

In other words when you scroll back, the range goes back to where it was when the object was created.

You can (if you want to use more coding and eat a bit more cpu) reset the heights of all objects within the visible screen (same as the for loop from first visible bar)

BlueMental.
  • Post #4
  • Quote
  • Last Post: May 1, 2010 9:01am May 1, 2010 9:01am
  •  f451
  • | Joined Mar 2010 | Status: Member | 281 Posts
Thank you both!
This one has been driving me nuts.
  • Platform Tech
  • /
  • How to place characters JUST above a candle wick on any Timeframe?
  • 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 / ©2021