protected override void OnBar()
{
// Check if price is in a supply or demand zone
foreach (var zone in supplyAndDemand.sList)
{
// Check if current bar's high price is greater than zone's high price
// AND previous bar's high price was lower than zone's high price
if (Bars.HighPrices.Last(1) > zone.high && Bars.HighPrices.Last(2) <= zone.high)
{
// Enter short trade as price entered a supply zone
ExecuteMarketOrder(TradeType.Sell, Symbol, TradeVolume, Instance, null, null, null, "Supply Zone");
}
}
foreach (var zone in supplyAndDemand.dList)
{
// Check if current bar's low price is lower than zone's low price
// AND previous bar's low price was higher than zone's low price
if (Bars.LowPrices.Last(1) < zone.low && Bars.LowPrices.Last(2) >= zone.low)
{
// Enter long trade as price entered a demand zone
ExecuteMarketOrder(TradeType.Buy, Symbol, TradeVolume, Instance, null, null, null, "Demand Zone");
}
}
}
ctid6002427
19 Apr 2023, 17:02 ( Updated at: 19 Apr 2023, 17:46 )
RE:
bjarman16 said:
...
@ctid6002427