I’m hoping you can help me. I originally wrote this in VB for another trading platform and have converted it to C#. (I’m brand new to C#, but think I have done this properly). When I compile I get a whole load of error messages that do not refer to any lines in my code. I really don’t have any easy way of debugging this.
I had thought about compiling the base template before I started adding code and then at each major step. However, if I try and compile the brand new template, as is, I get errors as well.
I’d really appreciate any help you can give me on this. My intention is to turn this into a system that will automatically move my profit stops on Forex trades at night.
Thanks,
Clyde
Code logic -- 3 bar reversal stop A three bar reversal stop looks three valid bars back and finds either the lowest low (for longs) or highest high (for shorts) of the prior 3 bars. [/font]
A valid bar is defined as being a bar that is not an inside bar (a bar completely within the trading range of the prior bar).[/font]
<snippet - bbs would not premit me to post the whole thing>
protectedoverridevoid Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = false;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
int constOneBarAgo = 1;
int CurrentBarToReview = 1; // Trade bar we are evaluating
int OneBarPriorToCurrentBar = 2;
double RangeLL = Low[0]; // the cumulative Lowest Low of the back test range (start with current bar)
double RangeHH = High[0]; // the cumulative Highest High of the back test range
int ValidBarCount = 0; // We need 3 valid look back bars
while (ValidBarCount < 3)
{
// Loop for three valid bars back
// is this a valid bar for testing?
// A valid bar must be either higher or lower (or both) than the prior bar (not an inside day)
if (High[CurrentBarToReview] > High[OneBarPriorToCurrentBar] | Low[CurrentBarToReview] < Low[OneBarPriorToCurrentBar])
{
if (High[CurrentBarToReview] > RangeHH) RangeHH = High[CurrentBarToReview];
if (Low[CurrentBarToReview] < RangeLL) RangeLL = Low[CurrentBarToReview];
ValidBarCount ++;
}
//Increment loop and index pointer variables
CurrentBarToReview ++;
OneBarPriorToCurrentBar ++;
}
if (longDirection == true)
Plot0.Set(RangeHH);
else
Plot0.Set(RangeLL);
}
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries Plot0
{
get { return Values[0]; }
}
[Description("")]
[Category("Parameters")]
publicbool LongDirection
{
get { return longDirection; }
set { longDirection = value; }
}
#endregion
}
}
Comment