stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Help To Modify Range Indicator - ObjectCreate / Rectangle
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5327
Page 1 of 1
Author:  theforexedge [ Fri Nov 10, 2017 9:27 pm ]
Post subject:  Help To Modify Range Indicator - ObjectCreate / Rectangle

Hi.

I've been trying to modify this ranging indicator to add a rectangle on the chart when the market starts to range instead of the current histogram.

I've had a good look at the mql4 documentation on-line and several other indicators but I'm a bit stumped with how to start the first anchor point with the high & low of the bars and then the end point... ;)

I would appreciate any advice, direction to some on-line resource or ideally if someone could do the mod as my coding is quite limited, but slowly improving with the help of Steve et al :-)

I find the indicator really useful for identifying accumulation / distribution, so worth anyone giving it a try as i have been using it on my live account for the past few months!

Thanks, Jason
Author:  renexxxx [ Sat Nov 11, 2017 10:25 pm ]
Post subject:  Help To Modify Range Indicator - ObjectCreate / Rectangle

I've made some changes to the indicator, so that it draws some rectangles.

Rene.
Author:  SteveHopwood [ Sun Nov 12, 2017 12:09 am ]
Post subject:  Help To Modify Range Indicator - ObjectCreate / Rectangle

renexxxx » Sat Nov 11, 2017 10:25 pm wrote:I've made some changes to the indicator, so that it draws some rectangles.

Rene.
Thanks for stepping in Rene. You again offer help to a SHF member that the likes of me are incapable of offering. We are all deeply grateful for your help. :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap:

:xm:
Author:  theforexedge [ Sun Nov 12, 2017 6:44 pm ]
Post subject:  Help To Modify Range Indicator - ObjectCreate / Rectangle

renexxxx » Sat Nov 11, 2017 10:25 pm wrote:I've made some changes to the indicator, so that it draws some rectangles.

Rene.
Rene

Thank you very much for taking the time to do this...it's really useful for me as I try to learn by looking at the code to figure out what's actually going on, especially drawing anything on the chart is still quite a mystery for me! i know why Steve keeps away from indicators!

One other indicator that was coded by f451 (a SHF member) a few years back and i've been using is his VSA-Signals indicator. The indicator is working fine now, but one thing I've been trying to figure out is how to check the signals when the next bar closes up / down respectively, and then confirm the signal on the chart with a change of colour. I was thinking this might be able to be done with ObjectGetValueByShift( ); and waiting for the next bar, but how to do this is quite beyond me!

I have been using the indicator and shifting the bar back +1 but it would be nice to see both the unconfirmed & confirmed signals on the chart...then next is to make a dashboard! :smile:

Anyway its a really great indicator that other SHF members might find useful as is or modified :clap:

Code: Select all

int DisplaySignal(int s, int bar)
{
   if (s==EMPTY_VALUE)
   { return(0);}
   
   icolor = wrong_background;  // if wrong background, show signal in gray
   if (s < 9) 
   { 
     dprice = High[bar] + 0.1*CalcRange(bar, false);
     if (background == weakness) // background weakness, signal weakness, mark with red
     { icolor = weakness_color; }
   } 
   else 
   { 
     dprice = Low[bar] - 0.1*CalcRange(bar, false); 
     if (background == strength)  // background strength, signal strength, mark with blue
     { icolor = strength_color; }
   }
   if (ObjectCreate(objprefix+" "+text[s]+" ("+bar+")", OBJ_ARROW, 0, Time[bar], dprice) == true)
   {
      ObjectSet(objprefix+" "+text[s]+" ("+bar+")", OBJPROP_ARROWCODE, code[s]);     
      ObjectSet(objprefix+" "+text[s]+" ("+bar+")", OBJPROP_COLOR, icolor);
      SetIndexArrow(3,code[s]);
      sctr++; 
   }
   last_dprice = dprice; // might use last signal position to clear and rewrite signals for those that need confirmation
   return(0);
}
Author:  tomele [ Sun Nov 12, 2017 10:57 pm ]
Post subject:  Help To Modify Range Indicator - ObjectCreate / Rectangle

Pandora's box has opened.
Author:  theforexedge [ Sun Nov 12, 2017 11:01 pm ]
Post subject:  Help To Modify Range Indicator - ObjectCreate / Rectangle

tomele » Sun Nov 12, 2017 10:57 pm wrote:Pandora's box has opened.
:lol:
Author:  renexxxx [ Mon Nov 13, 2017 8:25 am ]
Post subject:  Help To Modify Range Indicator - ObjectCreate / Rectangle

theforexedge » Mon Nov 13, 2017 4:44 am wrote: One other indicator that was coded by f451 (a SHF member) a few years back and i've been using is his VSA-Signals indicator. The indicator is working fine now, but one thing I've been trying to figure out is how to check the signals when the next bar closes up / down respectively, and then confirm the signal on the chart with a change of colour. I was thinking this might be able to be done with ObjectGetValueByShift( ); and waiting for the next bar, but how to do this is quite beyond me!
Not sure what you mean with "confirm the signal". The signals are only calculated for candles 1 and higher (i.e. closed candles). The calculation of the signal for any candle n only needs price data for candle n and candle n+1. So, once a signal is calculated for a closed candle, it will never change -- it is set in stone. Therefore, the notion of "confirming the signal" is not clear.
Author:  theforexedge [ Mon Nov 13, 2017 12:01 pm ]
Post subject:  Help To Modify Range Indicator - ObjectCreate / Rectangle

Rene

Ah! sorry i really meant to reconfirm the signal that was on the previous bar. When trading with VSA (volume) the signals are much more powerful when the next bar closes up / down than the previous bar [bar+1]. Most people make the mistake by just trading the confirmed signal :)

I've attached a screen shot of what i hope we can achieve..

This is currently done with a Pinbar indicator and a mod of the indicator(two indicators are running on the same chart) that looks at candle n+1 and candle n+2 and confirms with the close of candle n and candle n+1 then prints the star symbol over the dot.

Let me know if you need any further clarification and apologies for my lack of terminology with the candles and confirmation :oops:

Jason
All times are UTC Page 1 of 1