SMA calculation, previous day low, strategy tester issues

 

Hi Community.


I have managed to program an EA but cannot solve three main issues.

The logic behind this strategy is as follows:

  • Buy only on Monday 0545 pm, close only on Wednesday 0900am
  • If the current price on Monday 0545pm is below SMA 34 days (price close 0530pm) and touches the LOW of Monday during trading hours 0900am to 0530pm => buy


I am currently facing the following issues:

1. I managed to calculate the SMA, but only with PRICE_CLOSE and not the closing price at 0530pm.

int movingAverageDefinition=iMA(_Symbol,PERIOD_D1,34,0,MODE_SMA,PRICE_CLOSE);

2. at the moment the condition that the current price needs to touch the day low is missing

I would also highly appreciate if someone could give me the example of the code if I want to buy only if the previous day low has been touched between 0900am and 0545pm.

if(DayOfWeek()==1 && CurrentTime=="17:45" && PriceInfo[1].close<myMovingAverageArray[1];

3. When running the backtest, no matter of what date I introduce, the backtest always starts January 25th, 2010. I have no idea what is wrong with the code or whether any other issue occurs.


My so far programed EA is attached. Any help is highly appreciated. Many thanks in advance for your time and help.


Best regards, 

Wolfgang

Dateien:
 
  1. Hallo und schon mal viel Erfolg und schöne Weihnachten!
  2. Wir können hier deutsch sprechen :)
  3. Die Verwendung des Indikators ist falsch.
    Lies bitte entweder die Dok. und das Beispiel zu iCustom() und studiere das Beispiel ..\Experts\Examples\Moving Average\Moving Average.mq5, das sich im TerminalOrdner befindet.
Dokumentation zu MQL5: Technische Indikatoren / iCustom
Dokumentation zu MQL5: Technische Indikatoren / iCustom
  • www.mql5.com
iCustom - Technische Indikatoren - Nachschlagewerk MQL5 - Nachschlagewerk über die Sprache des algothitmischen/automatischen Handels für MetaTrader 5