So far I have the right pullback candle formation in tact as the prints are showing correctly.
However, I am now having trouble with creating logic to only EnterLong()
How do I create logic to make sure that from the holdValue candle to the candle entry have all had their lows greater than the middle bollinger band?
if from the holdValue candle low to the candle that triggers the entry have all lows greater than the middle bollinger band and the High[0] is greater than the high of holdValue than it will trigger long.
**As long as all the candle lows in between the holdvalue and entry candle are above the mid bb.
I provided a few examples of how to phrase what I need.
Here is my code now:
protected override void OnBarUpdate()
{
if (CurrentBars[0] < 5)
return;
if ((High[4] < High[3])
&& (Low[4] > midbbBull.Middle[4])
&& (Low[3] > midbbBull.Middle[3])
&& (Low[2] > midbbBull.Middle[2])
&& (Low[1] > midbbBull.Middle[1])
&& (High[3] > High[2])
&& (High[3] > High[1]))// pseudo condition, replace with your condition
{
holdValue = High[3]; //store the close when the condition was true
holdBarNumber = CurrentBar; // store the current bar number when the condition was true
}
if (holdValue != 0 && holdBarNumber != 0) // check if we have values for the variables
{
Print("Close price at last condition was " + holdValue);
}
if (High[0] > holdValue)
{
EnterLong();
}
if (Low[0] < SMA5[0])
{
ExitLong();
}
Comment