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

Indicator Request
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4019
Page 4 of 7
Author:  Reaper [ Thu Jan 08, 2015 5:44 pm ]
Post subject:  Indicator Request

Code: Select all

  double haLowBar0 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,0);
  double haHighBar0 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,0);
  double haOpenBar0 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,0);
  double haCloseBar0 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,0);
 
  double haLowBar1 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,1);
  double haHighBar1 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,1);
  double haOpenBar1 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,1);
  double haCloseBar1 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,1);
 
  double haLowBar2 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,2);
  double haHighBar2 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,2);
  double haOpenBar2 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,2);
  double haCloseBar2 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,2);
 
  double haLowBar3 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,3);
  double haHighBar3 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,3);
  double haOpenBar3 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,3);
  double haCloseBar3 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,3);
 
  double haLowBar4 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,4);
  double haHighBar4 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,4);
  double haOpenBar4 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,4);
  double haCloseBar4 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,4);
 
  double haLowBar5 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,5);
  double haHighBar5 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,5);
  double haOpenBar5 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,5);
  double haCloseBar5 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,5);
 
  double haLowBar6 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,6);
  double haHighBar6 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,6);
  double haOpenBar6 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,6);
  double haCloseBar6 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,6);
Does this look right if I want to pull out the last 7 bars worth of HA data? It seems long winded but if it looks correct to you, I'll plough on.

Cheers
Author:  milanese [ Thu Jan 08, 2015 5:54 pm ]
Post subject:  Indicator Request

Angat » Thu Jan 08, 2015 5:44 pm wrote:

Code: Select all

  double haLowBar0 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,0);
  double haHighBar0 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,0);
  double haOpenBar0 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,0);
  double haCloseBar0 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,0);
 
  double haLowBar1 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,1);
  double haHighBar1 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,1);
  double haOpenBar1 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,1);
  double haCloseBar1 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,1);
 
  double haLowBar2 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,2);
  double haHighBar2 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,2);
  double haOpenBar2 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,2);
  double haCloseBar2 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,2);
 
  double haLowBar3 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,3);
  double haHighBar3 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,3);
  double haOpenBar3 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,3);
  double haCloseBar3 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,3);
 
  double haLowBar4 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,4);
  double haHighBar4 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,4);
  double haOpenBar4 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,4);
  double haCloseBar4 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,4);
 
  double haLowBar5 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,5);
  double haHighBar5 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,5);
  double haOpenBar5 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,5);
  double haCloseBar5 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,5);
 
  double haLowBar6 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,6);
  double haHighBar6 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,1,6);
  double haOpenBar6 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,2,6);
  double haCloseBar6 = iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,3,6);
Does this look right if I want to pull out the last 7 bars worth of HA data? It seems long winded but if it looks correct to you, I'll plough on.

Cheers
it would be easier if you would use arrays like :

Code: Select all

double haLowBar[7];// initializing array
//do the others the same way
//than
for (int i=7;i>=0;i--)
{
haLowBar[i]=iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,i);
//others in same way
}

 
if you want use less CPU resources you need only the i=0 reculate each tick and the others only every new bar, but for first steps this will be easier ..
Cheers :)

Tommaso
Author:  Reaper [ Thu Jan 08, 2015 6:21 pm ]
Post subject:  Indicator Request

milanese » Thu Jan 08, 2015 5:54 pm wrote: it would be easier if you would use arrays like :

Code: Select all

double haLowBar[7];// initializing array
//do the others the same way
//than
for (int i=7;i>=0;i--)
{
haLowBar[i]=iCustom(NULL,TimeFrame,"MyHeikenAshi",Red,Green,Gray,Gray,0,i);
//others in same way
}

 
if you want use less CPU resources you need only the i=0 reculate each tick and the others only every new bar, but for first steps this will be easier ..
Cheers :)

Tommaso
Excellent, I forgot about the iteration loop. Cheers you are a rockstar!
Author:  Reaper [ Sat Jan 10, 2015 9:53 am ]
Post subject:  Indicator Request

Hi just need to confirm something please.

Is it possible to have

Code: Select all

(haCloseBar0 < haOpenBar0)
where haCloseBar0 should represent the Close of the current bar 0.

Or is there no such thing as a Close of bar 0, as bar 0 is always current bar in progress so its impossible to get a close of bar 0?

I seem to be confuddling myself again :< :arrrg:
Author:  milanese [ Sat Jan 10, 2015 10:26 am ]
Post subject:  Indicator Request

Angat » Sat Jan 10, 2015 9:53 am wrote:Hi just need to confirm something please.

Is it possible to have

Code: Select all

(haCloseBar0 < haOpenBar0)
where haCloseBar0 should represent the Close of the current bar 0.

Or is there no such thing as a Close of bar 0, as bar 0 is always current bar in progress so its impossible to get a close of bar 0?

I seem to be confuddling myself again :< :arrrg:
close of bar 0 is always the latest Bid, as no one can predict how an open bar will close in future ;)

Cheers :)

Tommaso
Author:  Reaper [ Sat Jan 10, 2015 7:15 pm ]
Post subject:  Indicator Request

I have put my HA variables within int Start() within a NewBar() function which pulls 5 HA corresponding bars for a particular bar.

Says the bar was X, it would pull back HA equilavent of X+2, X+1, X, X-1, X-2 using the icustom shift.

I'm not sure if this is the right way, coz now I want to do another check for the next bar i.e. the bar that comes next from X-2.

Another way of putting it would be I need the shift of -1.

Basically I want to create a CloseIfNextBarIsOpposite() function, but I think I have set my EA up wrong so far.

Is the right way, moving all HA Variables to the top out of int Start() and NewBar() then have a function in NewBar() that updates them.

I don't know. :arrrg:

Feels like 1 step forward, 2 steps back at the minute.
Author:  SteveHopwood [ Sat Jan 10, 2015 8:47 pm ]
Post subject:  Indicator Request

Angat » Sat Jan 10, 2015 7:15 pm wrote:I have put my HA variables within int Start() within a NewBar() function which pulls 5 HA corresponding bars for a particular bar.

Says the bar was X, it would pull back HA equilavent of X+2, X+1, X, X-1, X-2 using the icustom shift.

I'm not sure if this is the right way, coz now I want to do another check for the next bar i.e. the bar that comes next from X-2.

Another way of putting it would be I need the shift of -1.

Basically I want to create a CloseIfNextBarIsOpposite() function, but I think I have set my EA up wrong so far.

Is the right way, moving all HA Variables to the top out of int Start() and NewBar() then have a function in NewBar() that updates them.

I don't know. :arrrg:

Feels like 1 step forward, 2 steps back at the minute.
You cannot do this. A shift of -1 would be looking into the future, and that hasn't happened yet.

:xm:
Author:  Reaper [ Sun Jan 11, 2015 9:52 am ]
Post subject:  Indicator Request

Okay I slept on it.

Name convention on HA Variables are confusing and needs to be changed so they are not referencing a fix candle.

I'm using a 3-5 candle pattern for entry with entry on the 6th but to use a 3-5 entry pattern and entry on the 4th,5th or 6th respectively - I'm going to need to completely recreate and add a lot more signals variables.

Also if there are 10 different types of candles for each position in the HA set of 7. There are a lot more permutations than I first thought.

Using array iterations would help I guess. I think I initially underestimated the work involved in making my entries.

At least I get what's going on now. The power of having a good sleep, eh. :smile:
Author:  Reaper [ Sun Jan 11, 2015 1:57 pm ]
Post subject:  Indicator Request

Okay one question:

I'm trying to set an HA candle where the first complete bar's low is lower than the previous.

I thought it was (haLowBar1 < haLowBar2) where haLowBar1 should represent the first complete bar's low and haLowBar2 represents the previous.

But it's working out to be the opposite, anyone confirm?

That would mean that a 'Lower Low' is a bigger number than a 'Low'.

(I had a look at the HA indicator code, but I cant confirm.)

UPDATE: No one needs to confirm, I'm just going to go with it. I think that just how the HA Low's are calculated. The bigger the Low value the lower it actually is on a chart.
Author:  Reaper [ Sun Jan 11, 2015 5:12 pm ]
Post subject:  Indicator Request

Angat » Sun Jan 11, 2015 1:57 pm wrote:Okay one question:

I'm trying to set an HA candle where the first complete bar's low is lower than the previous.

I thought it was (haLowBar1 < haLowBar2) where haLowBar1 should represent the first complete bar's low and haLowBar2 represents the previous.

But it's working out to be the opposite, anyone confirm?

That would mean that a 'Lower Low' is a bigger number than a 'Low'.

(I had a look at the HA indicator code, but I cant confirm.)

UPDATE: No one needs to confirm, I'm just going to go with it. I think that just how the HA Low's are calculated. The bigger the Low value the lower it actually is on a chart.
If anyone is wondering, I had another look in the HA indicator code and just realised what it meant.

Code: Select all

      if(open[0]<close[0])
        {
         ExtLowHighBuffer[0]=low[0];
         ExtHighLowBuffer[0]=high[0];
        }
      else
        {
         ExtLowHighBuffer[0]=high[0];
         ExtHighLowBuffer[0]=low[0];
        }

     
Damn Heiken Ashi, such a pretty indicator but so weirdly coded. :P
All times are UTC Page 4 of 7