apologies i am new to this. i have just created my first "strategy"
i have created a hyperscaleper on the 1 second that is proving to be very succefull, however it keeps trying to take long positions on the 1 minute downtrend, i only want it to take long positions on the 1 minute uptrend. i have...deduced..that the 50 ema works well. im trying to get the script to only enter if its above the 50 ema and then when the 12,21 cross over, unfortunately its only entering when all 3 have crossed over at the same time. see script. PS i also have no idea what im doing and completely winging it.
FastMA = 12;
SlowMA = 21;
LongMA = 50;
AddPlot(Brushes.Pink, "FastMA"); // stored as Plots[0] and Values[0]
AddPlot(Brushes.Blue, "SlowMA"); // stored as Plots[1] and Values[1]
AddPlot(Brushes.Blue, "LongMA"); // stored as Plots[2] and Values[2]
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
//Add your custom strategy logic here.
// Check if RTH
bool market_open = ToTime(Time[0]) >= 150000 && ToTime(Time[0]) <= 210000;
// Moving Average
bool cross_above = CrossAbove(EMA(FastMA), EMA(SlowMA), 1);
bool cross_below = CrossBelow(EMA(FastMA), EMA(SlowMA), 1);
bool crossabove= CrossAbove(EMA(SlowMA), EMA(LongMA), 1);
Values[0][0] = EMA(FastMA)[0];
Values[1][0] = EMA(SlowMA)[0];
Values[2][0] = EMA(LongMA)[0];
//Etner Positions
if (market_open)
{
if (cross_above)
if (crossabove)
{
EnterLong(Convert.ToInt32(DefaultQuantity), "");
SetStopLoss("", CalculationMode.Ticks, 20, false);
SetProfitTarget("", CalculationMode.Ticks, 10);
}
// Exit Postitions
if (!market_open)
{
ExitLong();
}
}
Comment