|
Calc lowest low/use higher time frame trend/avoid spread problem
I'm trying to find some samples of coding that could provide for the following requirements:
In order to calculate placement of a stop I'd like to see coding that for any given time frame the EA could be told the LOWEST LOW (or highest high) during the last X number of bars...and then using THAT price less (or plus in the case of the highest high) X number of pips to set a stop level.
In order for any new short time frame order to be placed in the same direction as the trend of a larger time frame, I'd like to see coding that would allow new orders to be placed on the short time frame chart ONLY in the same direction as the trend of the larger time frame chart. As a simple example, assume an EA attached to a 15 minute chart wants to place a buy order on the crossing UP of MA1 over MA2 (with a stop placed as per the prior question at 5 pips below the lowest low of the last 5 bars) BUT I'm looking for coding that would only place that new order providing that on the one hour chart for that same pair, the current price is above (or below in the cases of a sell) an X period MA.
In order to avoid false openings/closings of orders due to unusual wide spreads, I'd like to see coding that would only trigger order action based on the CLOSE of the current (or even prior bar could be considered) rather than being triggered while a bar is still open. With IBFX for example I've seen spreads that were usually 5 pips often be as wide as 20 pips (and I once even saw 53 pips !). It seems that such wide spread action as often opened a new order because during the formation of the bar the MA's have temporarily crossed...but at the time the bar closed they had NOT crossed thereby leaving me with a buy order in place that was not wanted !
Any code samples to address of these things would be greatly appreciated.
|